-
Notifications
You must be signed in to change notification settings - Fork 104
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
Multiple issues when cross-compiling .NET runtime using official docker images #1002
Comments
[Triage] @richlander @sbomer do either of you have any input on this issue with cross-compiling the .NET runtime? |
@lauxjpn the image you are using (mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-arm64) was specifically added for our .NET 7 builds, before we transitioned to using CBL-Mariner in official builds in .NET 8 (and Azure Linux 3.0 in .NET 9). I'd recommend checking https://github.com/dotnet/runtime/blob/main/eng/pipelines/common/templates/pipeline-with-resources.yml which lists the images we use for cross-building in our ci. For 8.0.4, you'll have better luck with mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64. |
There are good instructions here: https://github.com/dotnet/runtime/blob/b194416ea68e2d1c93a91fc7abf80eb2607b4831/docs/workflow/building/coreclr/linux-instructions.md Also checkout https://github.com/dotnet/dotnet |
Yes, all those runtime workflow docs are the first ones I read. But since the docs say Assumption is the mother of all mistakes.
Thanks, yes, the I guess we can close this one. |
The table is accurate, however, I grasp the assumption. This issue has relevant context: dotnet/runtime#100942 It is on my list of TODOs to update that table to reflect the state of that merged PR. We use a cross build approach for everything and use very old targets to ensure that our users can run our binaries (for the most part) everywhere. It enables us to both satisfy secure supply chain requirements and offer binary compat. That's very hard to do well. |
The issue
I am trying to build the .NET runtime for different platforms, by using the Dockerfiles for .NET Core Builds.
There are multiple issues with the cross-compilation process.
Lets assume the following simple dockerfile to cross-compile the dotnet runtime on an
x64
machine forarm64
:If I build this dockerfile, I get the following error:
The reason is that while
.../prereqs:ubuntu-22.04-coredeps
(the base image used by.../prereqs:ubuntu-22.04-cross-arm64
) installs llvm/clang via script, it does not set the installed version as the default:Symbolic links missing for default llvm/clang usage
There are e.g. no symbolic links for
/usr/bin/clang
, but only for/usr/bin/clang-18
. The dotnet runtime build system does not check the installed llvm/clang versions by default, but just tries to callclang
, which then fails.I have to explicitly specifiying the
--clang18
parameter tobuild.sh
, which requires me to know that the installed llvm version is18
:(It probably would also work to add
/usr/lib/llvm-18/bin/
to thePATH
environment variable instead.)This now starts the compilation process, until it hits the following error:
Looks like the source code is incompatible with llvm/clang
18
.To fix this issue, I install and use llvm/clang
14
instead:If I build this docker file, the runtime build continues further, until I hit:
It appears that the wrong version of
objcopy
(the not-cross-compile version) is used by the build system.There seems to be an
ObjCopyName
msbuild property that can be set to the name of the file that should be used instead, which would bellvm-objcopy-14
:(Appending
-p:ObjCopyName=llvm-objcopy-14
to thebuild.sh
parameter list instead would probably work as well.)This dockerfile is now finally able to finish the build process successfully.
Suggestions
--clang<major_version>
parameter (or change thePATH
environment variable).It took me quite some time to analyze and fix these issues. Currently, it is unreasonably hard to build a cross-compiled version of the dotnet runtime for someone who has never done it before.
The text was updated successfully, but these errors were encountered: