rustc: Enable crosscompiling std crates

This commit is contained in:
David Craven 2016-06-07 20:53:25 +02:00
parent 0720373dfc
commit 447dce99da
3 changed files with 12 additions and 25 deletions

View File

@ -1,4 +1,4 @@
{ stdenv, callPackage, rustcStable }:
{ stdenv, callPackage, rustcStable, targets ? [], targetToolchains ? [] }:
callPackage ./generic.nix {
shortVersion = "beta-1.10.0";
@ -9,4 +9,6 @@ callPackage ./generic.nix {
patches = [ ./patches/disable-lockfile-check.patch ] ++
stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = rustcStable;
inherit targets;
inherit targetToolchains;
}

View File

@ -7,22 +7,10 @@
, srcSha, srcRev
, configureFlags ? []
, patches
, targets
, targetToolchains
} @ args:
/* Rust's build process has a few quirks :
- The Rust compiler is written is Rust, so it requires a bootstrap
compiler, which is downloaded during the build. To make the build
pure, we download it ourself before and put it where it is
expected. Once the language is stable (1.0) , we might want to
switch it to use nix's packaged rust compiler. This might not be possible
as the compiler is highly coupled to the bootstrap.
NOTE : some derivation depend on rust. When updating this, please make
sure those derivations still compile. (racer, for example).
*/
let
version = if isRelease then
"${shortVersion}"
@ -35,15 +23,7 @@ let
llvmShared = llvm.override { enableSharedLibraries = true; };
target = if stdenv.system == "i686-linux"
then "i686-unknown-linux-gnu"
else if stdenv.system == "x86_64-linux"
then "x86_64-unknown-linux-gnu"
else if stdenv.system == "i686-darwin"
then "i686-apple-darwin"
else if stdenv.system == "x86_64-darwin"
then "x86_64-apple-darwin"
else abort "no snapshot to bootstrap for this platform (missing target triple)";
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
meta = with stdenv.lib; {
homepage = http://www.rust-lang.org/;
@ -75,9 +55,11 @@ stdenv.mkDerivation {
# ++ [ "--jemalloc-root=${jemalloc}/lib"
++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ]
++ stdenv.lib.optional (stdenv.cc.cc ? isClang) "--enable-clang"
++ stdenv.lib.optional (targets != []) "--target=${target}"
++ stdenv.lib.optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
inherit patches;
passthru.target = target;
postPatch = ''
substituteInPlace src/rust-installer/gen-install-script.sh \
@ -125,4 +107,5 @@ stdenv.mkDerivation {
preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
doCheck = true;
dontSetConfigureCross = true;
}

View File

@ -1,5 +1,5 @@
# Please make sure to check if rustfmt still builds when updating nightly
{ stdenv, callPackage, rustcStable }:
{ stdenv, callPackage, rustcStable, targets ? [], targetToolchains ? [] }:
callPackage ./generic.nix {
shortVersion = "master-1.11.0";
@ -10,4 +10,6 @@ callPackage ./generic.nix {
./patches/use-rustc-1.9.0.patch ] ++
stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = rustcStable;
inherit targets;
inherit targetToolchains;
}