git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #106790 from lopsided98/rustc-host-std

rustc: add host platform to --target when building cross-compiler

commitc2c0d57339c436744471b1337f362810ae8de340 authorJohn Ericson <git@JohnEricson.me> dateSat 12 Dec 2020, 17:27 (6 years ago) parent8f546be5a923e5
1 file changed+9−2
pkgs/development/compilers/rust/rustc.nix+9−2
pkgs/development/compilers/rust/rustc.nix+9−2
@@ -11,7 +11,7 @@
1111}:
1212
1313let
14− inherit (stdenv.lib) optionals optional optionalString;
14+ inherit (stdenv.lib) optionals optional optionalString concatStringsSep;
1515 inherit (darwin.apple_sdk.frameworks) Security;
1616
1717 llvmSharedForBuild = pkgsBuildBuild.llvm_10.override { enableSharedLibraries = true; };
@@ -72,7 +72,14 @@ in stdenv.mkDerivation rec {
7272 "--enable-vendor"
7373 "--build=${rust.toRustTargetSpec stdenv.buildPlatform}"
7474 "--host=${rust.toRustTargetSpec stdenv.hostPlatform}"
75− "--target=${rust.toRustTargetSpec stdenv.targetPlatform}"
75+ # std is built for all platforms in --target. When building a cross-compiler
76+ # we need to add the host platform as well so rustc can compile build.rs
77+ # scripts.
78+ "--target=${concatStringsSep "," ([
79+ (rust.toRustTargetSpec stdenv.targetPlatform)
80+ ] ++ optionals (stdenv.hostPlatform != stdenv.targetPlatform) [
81+ (rust.toRustTargetSpec stdenv.hostPlatform)
82+ ])}"
7683
7784 "${setBuild}.cc=${ccForBuild}"
7885 "${setHost}.cc=${ccForHost}"