From 3bf20e5bf80ebf221cf500412e6df2cb0601aaee Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 23 Jan 2024 15:51:03 +0100 Subject: [PATCH] rust.envVars: use wrapped LLD for aarch64 musl The unwrapped version doesn't know where to look for libraries, so this is required to e.g. build anything that uses openssl-sys with OPENSSL_NO_VENDOR. A randomly chosen example package that's fixed by this change is pkgsStatic.gitoxide. --- pkgs/build-support/rust/lib/default.nix | 5 +++-- pkgs/development/compilers/rust/1_75.nix | 2 +- pkgs/development/compilers/rust/default.nix | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/rust/lib/default.nix b/pkgs/build-support/rust/lib/default.nix index 4958a42fcdd9..e09f913bfbd3 100644 --- a/pkgs/build-support/rust/lib/default.nix +++ b/pkgs/build-support/rust/lib/default.nix @@ -1,6 +1,7 @@ { lib , stdenv , pkgsBuildHost +, pkgsBuildTarget , pkgsTargetTarget }: @@ -24,7 +25,7 @@ rec { cxxForHost = "${stdenv.cc}/bin/${stdenv.cc.targetPrefix}c++"; linkerForHost = if shouldUseLLD stdenv.targetPlatform && !stdenv.cc.bintools.isLLVM - then "${pkgsBuildHost.lld}/bin/ld.lld" + then "${pkgsBuildHost.llvmPackages.bintools}/bin/${stdenv.cc.targetPrefix}ld.lld" else ccForHost; # Unfortunately we must use the dangerous `pkgsTargetTarget` here @@ -35,7 +36,7 @@ rec { cxxForTarget = "${pkgsTargetTarget.stdenv.cc}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}c++"; linkerForTarget = if shouldUseLLD pkgsTargetTarget.stdenv.targetPlatform && !pkgsTargetTarget.stdenv.cc.bintools.isLLVM # whether stdenv's linker is lld already - then "${pkgsBuildHost.lld}/bin/ld.lld" + then "${pkgsBuildTarget.llvmPackages.bintools}/bin/${pkgsTargetTarget.stdenv.cc.targetPrefix}ld.lld" else ccForTarget; rustBuildPlatform = stdenv.buildPlatform.rust.rustcTarget; diff --git a/pkgs/development/compilers/rust/1_75.nix b/pkgs/development/compilers/rust/1_75.nix index d41a263c8a29..2ca1e2d294bc 100644 --- a/pkgs/development/compilers/rust/1_75.nix +++ b/pkgs/development/compilers/rust/1_75.nix @@ -56,4 +56,4 @@ import ./default.nix { rustcPatches = [ ]; } -(builtins.removeAttrs args [ "pkgsBuildTarget" "llvmPackages_17" "llvm_17"]) +(builtins.removeAttrs args [ "llvmPackages_17" "llvm_17"]) diff --git a/pkgs/development/compilers/rust/default.nix b/pkgs/development/compilers/rust/default.nix index f00c469cd19c..31501e668c89 100644 --- a/pkgs/development/compilers/rust/default.nix +++ b/pkgs/development/compilers/rust/default.nix @@ -16,6 +16,7 @@ , CoreFoundation, Security, SystemConfiguration , pkgsBuildBuild , pkgsBuildHost +, pkgsBuildTarget , pkgsTargetTarget , makeRustPlatform , wrapRustcWith @@ -23,7 +24,9 @@ let # Use `import` to make sure no packages sneak in here. - lib' = import ../../../build-support/rust/lib { inherit lib stdenv pkgsBuildHost pkgsTargetTarget; }; + lib' = import ../../../build-support/rust/lib { + inherit lib stdenv pkgsBuildHost pkgsBuildTarget pkgsTargetTarget; + }; # Allow faster cross compiler generation by reusing Build artifacts fastCross = (stdenv.buildPlatform == stdenv.hostPlatform) && (stdenv.hostPlatform != stdenv.targetPlatform); in