Skip to content

Commit

Permalink
rustc: fix cross compilation of LLVM with shared libs
Browse files Browse the repository at this point in the history
The PR which fixed `useLLVM` native rustc builds (NixOS#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 <me@artem.ist>
  • Loading branch information
rhelmot and artemist committed Nov 2, 2024
1 parent a3a8b0f commit 88f09c8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkgs/development/compilers/rust/1_82.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
pkgsBuildTarget,
pkgsBuildBuild,
pkgsBuildHost,
pkgsHostTarget,
pkgsTargetTarget,
makeRustPlatform,
wrapRustcWith,
Expand All @@ -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;
};
}
);
Expand All @@ -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 =
Expand All @@ -74,7 +75,7 @@ import ./default.nix
pkg.override {
stdenv = stdenv.override {
allowedRequisites = null;
cc = llvmPackages.clangUseLLVM;
cc = pkgsBuildHost.llvmPackages_18.clangUseLLVM;
};
};
in
Expand All @@ -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;
};
Expand Down Expand Up @@ -142,5 +143,6 @@ import ./default.nix
"wrapCCWith"
"overrideCC"
"fetchpatch"
"pkgsHostTarget"
]
)

0 comments on commit 88f09c8

Please sign in to comment.