Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Linking NativeAOT (ILC) Compiled Object File for EFI Application on macOS (.NET8 RC1) #48

Open
ZeroLP opened this issue Sep 23, 2023 · 0 comments

Comments

@ZeroLP
Copy link

ZeroLP commented Sep 23, 2023

Hello,

I am encountering issues while trying to build and link a NativeAOT compiled object file for an EFI application on macOS. Below are the details of the problem and the steps I have taken so far:

Problem Description:
I am working on a project where I need to compile C# code using ILC and link the resulting object file to create an EFI application. The development environment is macOS M1, and I am targeting the x86_64 architecture on .NET8 RC1.

Steps Taken:
Compilation with ILC:
I used the following command to compile the C# code using .NET Native:

csc /nologo /debug:embedded /noconfig /nostdlib /runtimemetadataversion:v4.0.30319 <source_files> /out:EFINet8Test /langversion:latest /unsafe
ilc EFINet8Test -o EFINet8Test.obj --systemmodule EFINet8Test--map EFINet8Test.map -O

Project-Level Compilation with dotnet build:
I also tried defining the csc arguments at the project level in the .csproj file properties and then built the project using dotnet build to ensure that the correct C# version and .NET 8 SDK were being used. However, this did not resolve the issue.

Linking with Clang:
I attempted to link the compiled object file using clang with the following command:
clang -o BOOTX64.EFI -target x86_64-unknown-windows -ffreestanding -nostdlib -e EfiMain EFINet8Test.obj -fuse-ld=/usr/local/opt/llvm/bin/lld-link

However, this resulted in an "unknown file type" error, indicating that lld-link does not recognise the format of the .obj file produced by ILC.

Exploration of Alternatives:

  • I explored using different linkers such as lld-link and ld from MinGW-w64, but none recognised the ILC-produced .obj file format.
  • I considered converting the object file format using objcopy, but this approach has its complexities.
  • I also attempted to pass custom clang arguments through the .csproj file using the IlcArg property, but the issue persisted.

Questions:

  • Is there a known solution or workaround for linking ILC-compiled object files for EFI applications on macOS?
  • Are there alternative linkers or tools that can recognise and link the .obj file produced by NativeAOT on macOS?
  • Is it possible to provide custom clang arguments or specify a custom linker through MSBuild or .csproj settings to address this issue?

Any guidance, suggestions, or insights into this problem would be greatly appreciated. Thank you in advance for your help!

@ZeroLP ZeroLP changed the title Issues with Linking NativeAOT (ILC) Compiled Object File for EFI Application on macOS Issues with Linking NativeAOT (ILC) Compiled Object File for EFI Application on macOS (.NET8 RC1) Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant