2014-09-30 15:11:26 +01:00
|
|
|
{ stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper
|
2014-11-06 00:54:44 +00:00
|
|
|
, tzdata, git, valgrind
|
2014-09-30 15:11:26 +01:00
|
|
|
}:
|
2014-07-31 19:42:20 +01:00
|
|
|
|
2014-08-24 17:52:34 +01:00
|
|
|
assert stdenv.gcc.gcc != null;
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-11-28 20:00:58 +00:00
|
|
|
with ((import ./common.nix) {inherit stdenv; version = "0.12.0-pre-1635-g29e928f";});
|
2014-07-31 19:42:20 +01:00
|
|
|
|
|
|
|
let snapshot = if stdenv.system == "i686-linux"
|
2014-11-28 20:00:58 +00:00
|
|
|
then "c8342e762a1720be939ed7c6a39bdaa27892f66f"
|
2014-07-31 19:42:20 +01:00
|
|
|
else if stdenv.system == "x86_64-linux"
|
2014-11-28 20:00:58 +00:00
|
|
|
then "7a7fe6f5ed47b9cc66261f880e166c7c8738b73e"
|
2014-07-31 19:42:20 +01:00
|
|
|
else if stdenv.system == "i686-darwin"
|
2014-11-28 20:00:58 +00:00
|
|
|
then "63e8644512bd5665c14389a83d5af564c7c0b103"
|
2014-07-31 19:42:20 +01:00
|
|
|
else if stdenv.system == "x86_64-darwin"
|
2014-11-28 20:00:58 +00:00
|
|
|
then "7933ae0e974d1b897806138b7052cb2b4514585f"
|
2014-07-31 19:42:20 +01:00
|
|
|
else abort "no-snapshot for platform ${stdenv.system}";
|
2014-11-28 20:00:58 +00:00
|
|
|
snapshotDate = "2014-11-21";
|
|
|
|
snapshotRev = "c9f6d69";
|
2014-07-31 19:42:20 +01: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-28 20:00:58 +00:00
|
|
|
rev = "29e928f2ba3501d37660314f6186d0e2ac18b9db";
|
|
|
|
sha256 = "1ndg920hnb8r9bblqvmqfflcrppzj68vzbhxf2zghmnx2z7svhxn";
|
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}";
|
|
|
|
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-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-09-23 23:22:30 +01:00
|
|
|
--subst-var-by "ccPath" "${stdenv.gcc}/bin/cc"
|
|
|
|
substituteInPlace src/librustc_back/archive.rs \
|
2014-07-31 19:42:20 +01:00
|
|
|
--subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar"
|
|
|
|
'';
|
|
|
|
|
2014-11-06 00:54:44 +00:00
|
|
|
buildInputs = [ which file perl curl python27 makeWrapper git valgrind ];
|
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-12-01 16:41:01 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# Install documentation
|
|
|
|
cp -r doc "$out/share/doc"
|
|
|
|
'';
|
2014-07-31 19:42:20 +01:00
|
|
|
}
|