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

buildRustPackage: fix cross-compilation to aarch64-unknown-linux-musl #66617

Open

Conversation

@yegortimoshenko
Copy link
Member

commented Aug 14, 2019

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
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @Ericson2314 @matthewbauer @Mic92

@yegortimoshenko yegortimoshenko force-pushed the transumption-unstable:201908/rust-aarch64-linux-musl branch from 553ad4d to 655ea7d Aug 14, 2019

@ofborg ofborg bot added the 6.topic: rust label Aug 14, 2019

yegortimoshenko added a commit to Holo-Host/holoportos that referenced this pull request Aug 14, 2019

@@ -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") ''

This comment has been minimized.

Copy link
@Mic92

Mic92 Aug 14, 2019

Contributor

Does it have those symbols on any musl platform?
Otherwise we could set stdenv.hostPlatform.isMusl.

This comment has been minimized.

Copy link
@yegortimoshenko

yegortimoshenko Aug 14, 2019

Author Member

It does have these symbols on x86_64 musl platform.

This comment has been minimized.

Copy link
@Mic92

Mic92 Aug 16, 2019

Contributor

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.

This comment has been minimized.

Copy link
@yegortimoshenko

yegortimoshenko Aug 16, 2019

Author Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.