diff --git a/third_party/nixpkgs/patches/buildrustcrate-aarch64-linux.patch b/third_party/nixpkgs/patches/buildrustcrate-aarch64-linux.patch new file mode 100644 index 0000000000..68954d9100 --- /dev/null +++ b/third_party/nixpkgs/patches/buildrustcrate-aarch64-linux.patch @@ -0,0 +1,56 @@ +diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +index 1c946764c758..637c9fc62f2e 100644 +--- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix ++++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +@@ -1,6 +1,7 @@ + { lib, stdenv, rust, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }: + { +- build ++ aarch64LinuxGccWorkaround ++, build + , buildDependencies + , codegenUnits + , colors +@@ -52,6 +53,7 @@ in '' + noisily cd "$cargo_toml_dir" + ''} + ++ export NIX_LDFLAGS+=" ${aarch64LinuxGccWorkaround}" + runHook preConfigure + + symlink_dependency() { +diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix +index 98030225bcbb..700e21a72237 100644 +--- a/pkgs/build-support/rust/build-rust-crate/default.nix ++++ b/pkgs/build-support/rust/build-rust-crate/default.nix +@@ -80,6 +80,8 @@ let + + installCrate = import ./install-crate.nix { inherit stdenv; }; + ++ aarch64LinuxGccWorkaround = lib.optionalString (stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU) "-lgcc"; ++ + # Allow access to the rust attribute set from inside buildRustCrate, which + # has a parameter that shadows the name. + rustAttrs = rust; +@@ -341,7 +343,7 @@ crate_: lib.makeOverridable + configurePhase = configureCrate { + inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription + crateFeatures crateRenames libName build workspace_member release libPath crateVersion +- extraLinkFlags extraRustcOptsForBuildRs ++ extraLinkFlags extraRustcOptsForBuildRs aarch64LinuxGccWorkaround + crateAuthors crateHomepage verbose colors codegenUnits; + }; + buildPhase = buildCrate { +diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix +index 819c43791048..4709bac36359 100644 +--- a/pkgs/top-level/all-packages.nix ++++ b/pkgs/top-level/all-packages.nix +@@ -15505,7 +15505,7 @@ with pkgs; + + makeRustPlatform = callPackage ../development/compilers/rust/make-rust-platform.nix {}; + +- buildRustCrate = callPackage ../build-support/rust/build-rust-crate { }; ++ buildRustCrate = callPackage ../build-support/rust/build-rust-crate { stdenv = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then gcc11Stdenv else stdenv; }; + buildRustCrateHelpers = callPackage ../build-support/rust/build-rust-crate/helpers.nix { }; + + cargo2junit = callPackage ../development/tools/rust/cargo2junit { }; diff --git a/third_party/nixpkgs/patches/series b/third_party/nixpkgs/patches/series index 387570bcc4..d9d628e304 100644 --- a/third_party/nixpkgs/patches/series +++ b/third_party/nixpkgs/patches/series @@ -1,2 +1,3 @@ kubo-multiaddr.patch prison-zxing.patch +buildrustcrate-aarch64-linux.patch diff --git a/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 1c946764c7..637c9fc62f 100644 --- a/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -1,6 +1,7 @@ { lib, stdenv, rust, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }: { - build + aarch64LinuxGccWorkaround +, build , buildDependencies , codegenUnits , colors @@ -52,6 +53,7 @@ in '' noisily cd "$cargo_toml_dir" ''} + export NIX_LDFLAGS+=" ${aarch64LinuxGccWorkaround}" runHook preConfigure symlink_dependency() { diff --git a/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/default.nix b/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/default.nix index 98030225bc..700e21a722 100644 --- a/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/default.nix +++ b/third_party/nixpkgs/pkgs/build-support/rust/build-rust-crate/default.nix @@ -80,6 +80,8 @@ let installCrate = import ./install-crate.nix { inherit stdenv; }; + aarch64LinuxGccWorkaround = lib.optionalString (stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU) "-lgcc"; + # Allow access to the rust attribute set from inside buildRustCrate, which # has a parameter that shadows the name. rustAttrs = rust; @@ -341,7 +343,7 @@ crate_: lib.makeOverridable configurePhase = configureCrate { inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription crateFeatures crateRenames libName build workspace_member release libPath crateVersion - extraLinkFlags extraRustcOptsForBuildRs + extraLinkFlags extraRustcOptsForBuildRs aarch64LinuxGccWorkaround crateAuthors crateHomepage verbose colors codegenUnits; }; buildPhase = buildCrate { diff --git a/third_party/nixpkgs/pkgs/top-level/all-packages.nix b/third_party/nixpkgs/pkgs/top-level/all-packages.nix index 32a484db71..09af730bf0 100644 --- a/third_party/nixpkgs/pkgs/top-level/all-packages.nix +++ b/third_party/nixpkgs/pkgs/top-level/all-packages.nix @@ -15491,7 +15491,7 @@ with pkgs; makeRustPlatform = callPackage ../development/compilers/rust/make-rust-platform.nix {}; - buildRustCrate = callPackage ../build-support/rust/build-rust-crate { }; + buildRustCrate = callPackage ../build-support/rust/build-rust-crate { stdenv = if stdenv.isLinux && stdenv.isAarch64 && stdenv.cc.isGNU then gcc11Stdenv else stdenv; }; buildRustCrateHelpers = callPackage ../build-support/rust/build-rust-crate/helpers.nix { }; cargo2junit = callPackage ../development/tools/rust/cargo2junit { };