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

rust: fix on aarch64-linux by using GCC 11 and passing -lgcc #209113

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/build-support/rust/hooks/cargo-setup-hook.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cargoSetupPostUnpackHook() {
echo "Executing cargoSetupPostUnpackHook"

export NIX_LDFLAGS+=" @aarch64LinuxGccWorkaround@"
Mindavi marked this conversation as resolved.
Show resolved Hide resolved

# Some cargo builds include build hooks that modify their own vendor
# dependencies. This copies the vendor directory into the build tree and makes
# it writable. If we're using a tarball, the unpackFile hook already handles
Expand Down
3 changes: 3 additions & 0 deletions pkgs/build-support/rust/hooks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ in {
host-config = true
target-applies-to-host = true
'';

# https://github.com/NixOS/nixpkgs/issues/201254
aarch64LinuxGccWorkaround = lib.optionalString (stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU) "-lgcc";
};
} ./cargo-setup-hook.sh) {};

Expand Down
4 changes: 3 additions & 1 deletion pkgs/development/compilers/rust/rustc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ in stdenv.mkDerivation rec {
# when linking stage1 libstd: cc: undefined reference to `__cxa_begin_catch'
optional (stdenv.isLinux && !withBundledLLVM) "--push-state --as-needed -lstdc++ --pop-state"
++ optional (stdenv.isDarwin && !withBundledLLVM) "-lc++"
++ optional stdenv.isDarwin "-rpath ${llvmSharedForHost}/lib");
++ optional stdenv.isDarwin "-rpath ${llvmSharedForHost}/lib"
# https://github.com/NixOS/nixpkgs/issues/201254
++ optional (stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU) "-lgcc");

# Increase codegen units to introduce parallelism within the compiler.
RUSTFLAGS = "-Ccodegen-units=10";
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15386,6 +15386,8 @@ with pkgs;
rust_1_66 = callPackage ../development/compilers/rust/1_66.nix {
inherit (darwin.apple_sdk.frameworks) CoreFoundation Security SystemConfiguration;
llvm_14 = llvmPackages_14.libllvm;
# https://github.com/NixOS/nixpkgs/issues/201254
stdenv = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then gcc11Stdenv else stdenv;
};
rust = rust_1_66;

Expand Down