-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
buildRustPackage: fix cross-compilation to aarch64-unknown-linux-musl #66617
buildRustPackage: fix cross-compilation to aarch64-unknown-linux-musl #66617
Conversation
pkgs/build-support/rust/default.nix
Outdated
@@ -86,6 +86,10 @@ in stdenv.mkDerivation (args // { | |||
${stdenv.lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) '' | |||
[target."${stdenv.hostPlatform.config}"] | |||
"linker" = "${ccForHost}" | |||
${stdenv.lib.optionalString (stdenv.hostPlatform.config == "aarch64-unknown-linux-musl") '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it have those symbols on any musl platform?
Otherwise we could set stdenv.hostPlatform.isMusl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does have these symbols on x86_64 musl platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I cannot find it:
$ nm -gC $(nix-build --no-out-link '<nixpkgs>' -A musl)/lib/libc.so | grep __addtf3
I ask since I also cannot find a definition in the musl source repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that's the case, but at the very least I'm absolutely sure that cross-compiled x86_64-unknown-linux-musl
executables work without this change. It seems that these symbols are used by LLVM for floating point arithmetic on AArch64 only.
Would like to merge as-is on September 12 unless anyone minds otherwise (cc @matthewbauer @Mic92), verified this introduces no regressions while allowing cross to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it turns out these flags are useful for other targets, we can extend this.
Sorry I didn't see the fixes and merge earlier! |
Motivation for this change
See: rust-lang/rust#46651
musl libc for aarch64 doesn't have
__addtf3
,__subtf3
,__multf3
symbols that Rust expects. This change allows to use statically linked in GCC for these symbols, allowing to build statically linked Rust binaries using Nixpkgs (Rust assumes that musl targets always want static linking).Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @Ericson2314 @matthewbauer @Mic92