2014-09-30 15:11:26 +01:00
|
|
|
{ stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper
|
2014-12-18 19:27:59 +00:00
|
|
|
, tzdata, git, valgrind, procps, coreutils
|
2014-09-30 15:11:26 +01:00
|
|
|
}:
|
2014-07-31 19:42:20 +01:00
|
|
|
|
2015-01-04 12:58:46 +00:00
|
|
|
assert !stdenv.isFreeBSD;
|
|
|
|
|
2014-07-31 19:42:20 +01: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.
|
|
|
|
|
2015-01-09 13:16:00 +00:00
|
|
|
|
|
|
|
NOTE : some derivation depend on rust. When updating this, please make
|
|
|
|
sure those derivations still compile. (racer, for example).
|
|
|
|
|
2014-07-31 19:42:20 +01:00
|
|
|
*/
|
|
|
|
|
2015-01-19 17:53:37 +00:00
|
|
|
let shortVersion = "1.0.0-dev";
|
|
|
|
rev = "a833337943300db1c310a4cf9c84b7b4ef4e9468";
|
2015-01-08 08:37:43 +00:00
|
|
|
revShort = builtins.substring 0 7 rev;
|
|
|
|
in
|
|
|
|
|
|
|
|
with ((import ./common.nix) {inherit stdenv; version = "${shortVersion}-g${revShort}"; });
|
2014-07-31 19:42:20 +01:00
|
|
|
|
2015-01-08 08:37:43 +00:00
|
|
|
let snapshotHash = if stdenv.system == "i686-linux"
|
2015-01-19 17:53:37 +00:00
|
|
|
then "0197ad7179d74eba06a8b46432548caf226aa03d"
|
2014-07-31 19:42:20 +01:00
|
|
|
else if stdenv.system == "x86_64-linux"
|
2015-01-19 17:53:37 +00:00
|
|
|
then "03459f8b216e96ed8b9abe25a42a75859195103d"
|
2014-07-31 19:42:20 +01:00
|
|
|
else if stdenv.system == "i686-darwin"
|
2015-01-19 17:53:37 +00:00
|
|
|
then "b5c004883ddff84159f11a3329cde682e0b7f75b"
|
2014-07-31 19:42:20 +01:00
|
|
|
else if stdenv.system == "x86_64-darwin"
|
2015-01-19 17:53:37 +00:00
|
|
|
then "b69ea42e1c995682adf0390ed4ef8a762c001a4e"
|
2015-01-08 08:37:43 +00:00
|
|
|
else abort "no snapshot for platform ${stdenv.system}";
|
2015-01-19 17:53:37 +00:00
|
|
|
snapshotDate = "2015-01-15";
|
|
|
|
snapshotRev = "9ade482";
|
2015-01-08 08:37:43 +00:00
|
|
|
snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshotHash}.tar.bz2";
|
|
|
|
in
|
2014-07-31 19:42:20 +01:00
|
|
|
|
2015-01-08 08:37:43 +00:00
|
|
|
stdenv.mkDerivation {
|
2014-07-31 19:42:20 +01:00
|
|
|
inherit name;
|
|
|
|
inherit version;
|
|
|
|
inherit meta;
|
|
|
|
|
|
|
|
src = fetchgit {
|
|
|
|
url = https://github.com/rust-lang/rust;
|
2015-01-08 08:37:43 +00:00
|
|
|
inherit rev;
|
2015-01-19 17:53:37 +00:00
|
|
|
sha256 = "1b9rnx3j37ckxa3vf20g8amsbffzvk2m9lzv5x1m04ci54w85f56";
|
2014-07-31 19:42:20 +01: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}";
|
2015-01-08 08:37:43 +00:00
|
|
|
sha1 = snapshotHash;
|
2014-07-31 19:42:20 +01:00
|
|
|
};
|
|
|
|
dontStrip = true;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"
|
|
|
|
cp -r bin "$out/bin"
|
|
|
|
'' + (if stdenv.isLinux then ''
|
2014-12-17 18:11:30 +00:00
|
|
|
patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.cc.dynamicLinker}" \
|
2015-01-15 04:25:26 +00:00
|
|
|
--set-rpath "${stdenv.cc.cc}/lib/:${stdenv.cc.cc}/lib64/" \
|
2014-07-31 19:42:20 +01:00
|
|
|
"$out/bin/rustc"
|
|
|
|
'' else "");
|
|
|
|
};
|
|
|
|
|
2014-12-17 18:11:30 +00:00
|
|
|
configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ]
|
|
|
|
++ stdenv.lib.optional (stdenv.cc ? clang) "--enable-clang";
|
2014-07-31 19:42:20 +01:00
|
|
|
|
|
|
|
# The compiler requires cc, so we patch the source to tell it where to find it
|
2014-11-07 00:40:49 +00:00
|
|
|
patches = [ ./hardcode_paths.HEAD.patch ./local_stage0.HEAD.patch ]
|
|
|
|
++ stdenv.lib.optional stdenv.needsPax ./grsec.HEAD.patch;
|
|
|
|
|
2014-07-31 19:42:20 +01:00
|
|
|
postPatch = ''
|
2014-11-21 00:43:40 +00:00
|
|
|
substituteInPlace src/librustc_trans/back/link.rs \
|
2014-12-17 18:11:30 +00:00
|
|
|
--subst-var-by "ccPath" "${stdenv.cc}/bin/cc"
|
2014-09-23 23:22:30 +01:00
|
|
|
substituteInPlace src/librustc_back/archive.rs \
|
2014-12-17 18:11:30 +00:00
|
|
|
--subst-var-by "arPath" "${stdenv.cc.binutils}/bin/ar"
|
2014-12-18 19:27:59 +00:00
|
|
|
|
|
|
|
substituteInPlace src/rust-installer/gen-install-script.sh \
|
|
|
|
--replace /bin/echo "${coreutils}/bin/echo"
|
2015-01-06 20:10:17 +00:00
|
|
|
substituteInPlace src/rust-installer/gen-installer.sh \
|
|
|
|
--replace /bin/echo "${coreutils}/bin/echo"
|
2014-07-31 19:42:20 +01:00
|
|
|
'';
|
|
|
|
|
2014-12-18 19:27:59 +00:00
|
|
|
buildInputs = [ which file perl curl python27 makeWrapper git valgrind procps ];
|
2014-09-30 15:11:26 +01:00
|
|
|
|
|
|
|
enableParallelBuilding = false; # disabled due to rust-lang/rust#16305
|
|
|
|
|
|
|
|
preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
|
|
|
|
|
|
|
|
doCheck = true;
|
2014-07-31 19:42:20 +01:00
|
|
|
}
|