Unverified Commit 88f09c87 authored by Audrey Dutcher's avatar Audrey Dutcher Committed by Artemis Tosini
Browse files

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: default avatarArtemis Tosini <me@artem.ist>
parent a3a8b0fb
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -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"
    ]
  )