3p/nixpkgs: fix aarch64-linux in buildRustCrate by using GCC11 and -lgcc

This commit is contained in:
Luke Granger-Brown 2023-01-22 22:57:09 +00:00
parent 0d9fc34957
commit d1ba763c67
5 changed files with 64 additions and 3 deletions

View file

@ -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 { };

View file

@ -1,2 +1,3 @@
kubo-multiaddr.patch kubo-multiaddr.patch
prison-zxing.patch prison-zxing.patch
buildrustcrate-aarch64-linux.patch

View file

@ -1,6 +1,7 @@
{ lib, stdenv, rust, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }: { lib, stdenv, rust, echo_colored, noisily, mkRustcDepArgs, mkRustcFeatureArgs }:
{ {
build aarch64LinuxGccWorkaround
, build
, buildDependencies , buildDependencies
, codegenUnits , codegenUnits
, colors , colors
@ -52,6 +53,7 @@ in ''
noisily cd "$cargo_toml_dir" noisily cd "$cargo_toml_dir"
''} ''}
export NIX_LDFLAGS+=" ${aarch64LinuxGccWorkaround}"
runHook preConfigure runHook preConfigure
symlink_dependency() { symlink_dependency() {

View file

@ -80,6 +80,8 @@ let
installCrate = import ./install-crate.nix { inherit stdenv; }; 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 # Allow access to the rust attribute set from inside buildRustCrate, which
# has a parameter that shadows the name. # has a parameter that shadows the name.
rustAttrs = rust; rustAttrs = rust;
@ -341,7 +343,7 @@ crate_: lib.makeOverridable
configurePhase = configureCrate { configurePhase = configureCrate {
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription
crateFeatures crateRenames libName build workspace_member release libPath crateVersion crateFeatures crateRenames libName build workspace_member release libPath crateVersion
extraLinkFlags extraRustcOptsForBuildRs extraLinkFlags extraRustcOptsForBuildRs aarch64LinuxGccWorkaround
crateAuthors crateHomepage verbose colors codegenUnits; crateAuthors crateHomepage verbose colors codegenUnits;
}; };
buildPhase = buildCrate { buildPhase = buildCrate {

View file

@ -15491,7 +15491,7 @@ with pkgs;
makeRustPlatform = callPackage ../development/compilers/rust/make-rust-platform.nix {}; 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 { }; buildRustCrateHelpers = callPackage ../build-support/rust/build-rust-crate/helpers.nix { };
cargo2junit = callPackage ../development/tools/rust/cargo2junit { }; cargo2junit = callPackage ../development/tools/rust/cargo2junit { };