2014-09-30 16:11:26 +02:00
|
|
|
{ stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper
|
2014-11-06 01:54:44 +01:00
|
|
|
, tzdata, git, valgrind
|
2014-09-30 16:11:26 +02:00
|
|
|
}:
|
2014-07-31 20:42:20 +02:00
|
|
|
|
2014-08-24 18:52:34 +02:00
|
|
|
assert stdenv.gcc.gcc != null;
|
|
|
|
|
2014-07-31 20:42:20 +02:00
|
|
|
/* Rust's build process has a few quirks :
|
|
|
|
|
|
|
|
- It requires some patched in llvm that haven't landed upstream, so it
|
|
|
|
compiles its own llvm. This might change in the future, so at some
|
|
|
|
point we may be able to switch to nix's llvm.
|
|
|
|
|
|
|
|
- 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-11-06 01:54:44 +01:00
|
|
|
with ((import ./common.nix) {inherit stdenv; version = "0.12.0-pre-961-g93c85eb";});
|
2014-07-31 20:42:20 +02:00
|
|
|
|
|
|
|
let snapshot = if stdenv.system == "i686-linux"
|
2014-11-06 01:54:44 +01:00
|
|
|
then "d827fbbd778b854923971873cf03bdb79c2e8575"
|
2014-07-31 20:42:20 +02:00
|
|
|
else if stdenv.system == "x86_64-linux"
|
2014-11-06 01:54:44 +01:00
|
|
|
then "1ddca522a8ba4a4f662dc17ca16b0f50f2c15f87"
|
2014-07-31 20:42:20 +02:00
|
|
|
else if stdenv.system == "i686-darwin"
|
2014-11-06 01:54:44 +01:00
|
|
|
then "597cd42301e1569df8ad090574cd535d19283387"
|
2014-07-31 20:42:20 +02:00
|
|
|
else if stdenv.system == "x86_64-darwin"
|
2014-11-06 01:54:44 +01:00
|
|
|
then "4bfb2aff1c3e3c57653b32adc34b399c5aeb759b"
|
2014-07-31 20:42:20 +02:00
|
|
|
else abort "no-snapshot for platform ${stdenv.system}";
|
2014-11-06 01:54:44 +01:00
|
|
|
snapshotDate = "2014-11-04";
|
|
|
|
snapshotRev = "1b2ad78";
|
2014-07-31 20:42:20 +02:00
|
|
|
snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshot}.tar.bz2";
|
|
|
|
|
|
|
|
in stdenv.mkDerivation {
|
|
|
|
inherit name;
|
|
|
|
inherit version;
|
|
|
|
inherit meta;
|
|
|
|
|
|
|
|
src = fetchgit {
|
|
|
|
url = https://github.com/rust-lang/rust;
|
2014-11-06 01:54:44 +01:00
|
|
|
rev = "93c85eb8bdcc910a27caf6abd20207a626ae98e5";
|
|
|
|
sha256 = "0zj84xsyg8jpd6ixmdv7jsjrnsd4zwrac98qqmwgrd78h74g8kpq";
|
2014-07-31 20:42:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# We need rust to build rust. If we don't provide it, configure will try to download it.
|
|
|
|
snapshot = stdenv.mkDerivation {
|
|
|
|
name = "rust-stage0";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}";
|
|
|
|
sha1 = snapshot;
|
|
|
|
};
|
|
|
|
dontStrip = true;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"
|
|
|
|
cp -r bin "$out/bin"
|
|
|
|
'' + (if stdenv.isLinux then ''
|
|
|
|
patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.gcc.dynamicLinker}" \
|
|
|
|
--set-rpath "${stdenv.gcc.gcc}/lib/:${stdenv.gcc.gcc}/lib64/" \
|
|
|
|
"$out/bin/rustc"
|
|
|
|
'' else "");
|
|
|
|
};
|
|
|
|
|
|
|
|
configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ];
|
|
|
|
|
|
|
|
# The compiler requires cc, so we patch the source to tell it where to find it
|
2014-10-05 00:55:45 +02:00
|
|
|
patches = [ ./hardcode_paths.HEAD.patch ./local_stage0.HEAD.patch ];
|
2014-07-31 20:42:20 +02:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/librustc/back/link.rs \
|
2014-09-24 00:22:30 +02:00
|
|
|
--subst-var-by "ccPath" "${stdenv.gcc}/bin/cc"
|
|
|
|
substituteInPlace src/librustc_back/archive.rs \
|
2014-07-31 20:42:20 +02:00
|
|
|
--subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar"
|
|
|
|
'';
|
|
|
|
|
2014-11-06 01:54:44 +01:00
|
|
|
buildInputs = [ which file perl curl python27 makeWrapper git valgrind ];
|
2014-09-30 16:11:26 +02:00
|
|
|
|
|
|
|
enableParallelBuilding = false; # disabled due to rust-lang/rust#16305
|
|
|
|
|
|
|
|
preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
|
|
|
|
|
|
|
|
doCheck = true;
|
2014-07-31 20:42:20 +02:00
|
|
|
}
|