2014-09-30 16:11:26 +02:00
|
|
|
{ stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper
|
2014-12-18 20:27:59 +01:00
|
|
|
, tzdata, git, valgrind, procps, coreutils
|
2014-09-30 16:11:26 +02:00
|
|
|
}:
|
2014-07-31 20:42:20 +02:00
|
|
|
|
2015-01-04 13:58:46 +01:00
|
|
|
assert !stdenv.isFreeBSD;
|
|
|
|
|
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-12-29 02:08:33 +01:00
|
|
|
with ((import ./common.nix) {inherit stdenv; version = "0.13.0-pre-2763-g6366631";});
|
2014-07-31 20:42:20 +02:00
|
|
|
|
|
|
|
let snapshot = if stdenv.system == "i686-linux"
|
2014-12-18 20:27:59 +01:00
|
|
|
then "3daf531aed03f5769402f2fef852377e2838db98"
|
2014-07-31 20:42:20 +02:00
|
|
|
else if stdenv.system == "x86_64-linux"
|
2014-12-18 20:27:59 +01:00
|
|
|
then "4f3c8b092dd4fe159d6f25a217cf62e0e899b365"
|
2014-07-31 20:42:20 +02:00
|
|
|
else if stdenv.system == "i686-darwin"
|
2014-12-18 20:27:59 +01:00
|
|
|
then "2a3e647b9c400505bd49cfe56091e866c83574ca"
|
2014-07-31 20:42:20 +02:00
|
|
|
else if stdenv.system == "x86_64-darwin"
|
2014-12-18 20:27:59 +01:00
|
|
|
then "5e730efc34d79a33f464a87686c10eace0760a2e"
|
2014-07-31 20:42:20 +02:00
|
|
|
else abort "no-snapshot for platform ${stdenv.system}";
|
2014-12-18 20:27:59 +01:00
|
|
|
snapshotDate = "2014-12-20";
|
|
|
|
snapshotRev = "8443b09";
|
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-12-29 02:08:33 +01:00
|
|
|
rev = "63666317214788329e0b7680929b09823f127d83";
|
|
|
|
sha256 = "1saf6ycy5dzp1bxypzqisi4g4p0y1czbgr82xbrw5c81x5c274zk";
|
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 ''
|
2014-12-17 19:11:30 +01:00
|
|
|
patchelf --interpreter "${stdenv.glibc}/lib/${stdenv.cc.dynamicLinker}" \
|
|
|
|
--set-rpath "${stdenv.cc.gcc}/lib/:${stdenv.cc.gcc}/lib64/" \
|
2014-07-31 20:42:20 +02:00
|
|
|
"$out/bin/rustc"
|
|
|
|
'' else "");
|
|
|
|
};
|
|
|
|
|
2014-12-17 19:11:30 +01:00
|
|
|
configureFlags = [ "--enable-local-rust" "--local-rust-root=$snapshot" ]
|
|
|
|
++ stdenv.lib.optional (stdenv.cc ? clang) "--enable-clang";
|
2014-07-31 20:42:20 +02:00
|
|
|
|
|
|
|
# The compiler requires cc, so we patch the source to tell it where to find it
|
2014-11-07 01:40:49 +01:00
|
|
|
patches = [ ./hardcode_paths.HEAD.patch ./local_stage0.HEAD.patch ]
|
|
|
|
++ stdenv.lib.optional stdenv.needsPax ./grsec.HEAD.patch;
|
|
|
|
|
2014-07-31 20:42:20 +02:00
|
|
|
postPatch = ''
|
2014-11-21 01:43:40 +01:00
|
|
|
substituteInPlace src/librustc_trans/back/link.rs \
|
2014-12-17 19:11:30 +01:00
|
|
|
--subst-var-by "ccPath" "${stdenv.cc}/bin/cc"
|
2014-09-24 00:22:30 +02:00
|
|
|
substituteInPlace src/librustc_back/archive.rs \
|
2014-12-17 19:11:30 +01:00
|
|
|
--subst-var-by "arPath" "${stdenv.cc.binutils}/bin/ar"
|
2014-12-18 20:27:59 +01:00
|
|
|
|
|
|
|
substituteInPlace src/rust-installer/gen-install-script.sh \
|
|
|
|
--replace /bin/echo "${coreutils}/bin/echo"
|
2014-07-31 20:42:20 +02:00
|
|
|
'';
|
|
|
|
|
2014-12-18 20:27:59 +01:00
|
|
|
buildInputs = [ which file perl curl python27 makeWrapper git valgrind procps ];
|
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-12-01 17:41:01 +01:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# Install documentation
|
|
|
|
cp -r doc "$out/share/doc"
|
|
|
|
'';
|
2014-07-31 20:42:20 +02:00
|
|
|
}
|