Merge pull request #106790 from lopsided98/rustc-host-std

rustc: add host platform to --target when building cross-compiler
This commit is contained in:
John Ericson 2020-12-12 17:27:56 -05:00 committed by GitHub
commit c2c0d57339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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; };
@ -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}"