From 88f09c87d3715e83f0da17ee25f609f33909443e Mon Sep 17 00:00:00 2001 From: Audrey Dutcher Date: Thu, 5 Sep 2024 13:46:52 -0700 Subject: [PATCH] rustc: fix cross compilation of LLVM with shared libs The PR which fixed `useLLVM` native rustc builds (#320432) also broke cross builds. The C compiler it used to produce `llvmShared` and `llvmPackages`, `llvmPackages.clangUseLLVM`, was built to run on the host and create binaries for the target (`pkgsHostTarget`). Instead, the compiler should be built to run on the build machine and produce binaries for the host machine (`pkgsBuildHost`). Replace the overridden compilers with ones from `pkgsBuildHost` Co-Authored-By: Artemis Tosini --- pkgs/development/compilers/rust/1_82.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/rust/1_82.nix b/pkgs/development/compilers/rust/1_82.nix index 12cfbb80b2fb..8e74e8c3a3e6 100644 --- a/pkgs/development/compilers/rust/1_82.nix +++ b/pkgs/development/compilers/rust/1_82.nix @@ -20,6 +20,7 @@ pkgsBuildTarget, pkgsBuildBuild, pkgsBuildHost, + pkgsHostTarget, pkgsTargetTarget, makeRustPlatform, wrapRustcWith, @@ -40,7 +41,7 @@ let # Force LLVM to compile using clang + LLVM libs when targeting pkgsLLVM stdenv = pkgSet.stdenv.override { allowedRequisites = null; - cc = pkgSet.llvmPackages_18.clangUseLLVM; + cc = pkgSet.pkgsBuildHost.llvmPackages_18.clangUseLLVM; }; } ); @@ -55,7 +56,7 @@ import ./default.nix llvmSharedForTarget = llvmSharedFor pkgsBuildTarget; # For use at runtime - llvmShared = llvmSharedFor { inherit llvmPackages_18 stdenv; }; + llvmShared = llvmSharedFor pkgsHostTarget; # Expose llvmPackages used for rustc from rustc via passthru for LTO in Firefox llvmPackages = @@ -74,7 +75,7 @@ import ./default.nix pkg.override { stdenv = stdenv.override { allowedRequisites = null; - cc = llvmPackages.clangUseLLVM; + cc = pkgsBuildHost.llvmPackages_18.clangUseLLVM; }; }; in @@ -87,7 +88,7 @@ import ./default.nix libcxx = llvmPackages.libcxx.override { stdenv = stdenv.override { allowedRequisites = null; - cc = llvmPackages.clangNoLibcxx; + cc = pkgsBuildHost.llvmPackages_18.clangNoLibcxx; hostPlatform = stdenv.hostPlatform // { useLLVM = !stdenv.hostPlatform.isDarwin; }; @@ -142,5 +143,6 @@ import ./default.nix "wrapCCWith" "overrideCC" "fetchpatch" + "pkgsHostTarget" ] )