about summary refs log tree commit diff
path: root/pkgs/build-support/rust
diff options
context:
space:
mode:
authorWinter <winter@winter.cafe>2023-01-04 18:15:20 -0500
committerWinter <winter@winter.cafe>2023-01-04 18:15:20 -0500
commit8442601c6445894b350e8b2b10717c1f609bedaf (patch)
tree64e91fa74b1ce7e9e9a2e7214dcba06ea1897fb2 /pkgs/build-support/rust
parentccb3146bf27b954399648f7d12c3af8efeab1f13 (diff)
rust: fix on aarch64-linux by using GCC 11 and passing `-lgcc`
This change switches to using GCC 11 by default on aarch64-linux, as well as passing `-lgcc` to the linker, per #201485.

See #201254 and #208412 for wider context on the issue.
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r--pkgs/build-support/rust/hooks/cargo-setup-hook.sh2
-rw-r--r--pkgs/build-support/rust/hooks/default.nix3
2 files changed, 5 insertions, 0 deletions
diff --git a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
index aeddeef29d928..8146573e79dba 100644
--- a/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
+++ b/pkgs/build-support/rust/hooks/cargo-setup-hook.sh
@@ -1,6 +1,8 @@
 cargoSetupPostUnpackHook() {
     echo "Executing cargoSetupPostUnpackHook"
 
+    export NIX_LDFLAGS+=" @aarch64LinuxGccWorkaround@"
+
     # 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
diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix
index b9bbac3719859..9989e582d2e9a 100644
--- a/pkgs/build-support/rust/hooks/default.nix
+++ b/pkgs/build-support/rust/hooks/default.nix
@@ -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) {};