Skip to content

Commit

Permalink
rustc: add host platform to --target when building cross-compiler
Browse files Browse the repository at this point in the history
As of 1.48, std is only built for platforms in --target. If the host platform is
not included, the resulting rustc can't compile build.rs scripts.
  • Loading branch information
lopsided98 committed Dec 12, 2020
1 parent f947634 commit 5a923e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkgs/development/compilers/rust/rustc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}:

let
inherit (stdenv.lib) optionals optional optionalString;
inherit (stdenv.lib) optionals optional optionalString concatStringsSep;
inherit (darwin.apple_sdk.frameworks) Security;

llvmSharedForBuild = pkgsBuildBuild.llvm_10.override { enableSharedLibraries = true; };
Expand Down Expand Up @@ -72,7 +72,14 @@ in stdenv.mkDerivation rec {
"--enable-vendor"
"--build=${rust.toRustTargetSpec stdenv.buildPlatform}"
"--host=${rust.toRustTargetSpec stdenv.hostPlatform}"
"--target=${rust.toRustTargetSpec stdenv.targetPlatform}"
# std is built for all platforms in --target. When building a cross-compiler
# we need to add the host platform as well so rustc can compile build.rs
# scripts.
"--target=${concatStringsSep "," ([
(rust.toRustTargetSpec stdenv.targetPlatform)
] ++ optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
(rust.toRustTargetSpec stdenv.hostPlatform)
])}"

"${setBuild}.cc=${ccForBuild}"
"${setHost}.cc=${ccForHost}"
Expand Down

0 comments on commit 5a923e5

Please sign in to comment.