93 lines
3.2 KiB
Nix
93 lines
3.2 KiB
Nix
{ stdenv, fetchurl, fetchgit, which, file, perl, curl, python27, makeWrapper
|
|
, tzdata, git, valgrind, procps, coreutils
|
|
}:
|
|
|
|
assert stdenv.gcc.gcc != null;
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
with ((import ./common.nix) {inherit stdenv; version = "0.13.0-pre-2600-g34d6800";});
|
|
|
|
let snapshot = if stdenv.system == "i686-linux"
|
|
then "3daf531aed03f5769402f2fef852377e2838db98"
|
|
else if stdenv.system == "x86_64-linux"
|
|
then "4f3c8b092dd4fe159d6f25a217cf62e0e899b365"
|
|
else if stdenv.system == "i686-darwin"
|
|
then "2a3e647b9c400505bd49cfe56091e866c83574ca"
|
|
else if stdenv.system == "x86_64-darwin"
|
|
then "5e730efc34d79a33f464a87686c10eace0760a2e"
|
|
else abort "no-snapshot for platform ${stdenv.system}";
|
|
snapshotDate = "2014-12-20";
|
|
snapshotRev = "8443b09";
|
|
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;
|
|
rev = "34d680009205de2302b902d8f9f5f7ae7a042f1a";
|
|
sha256 = "0qj9b8yzvks42kqr5kxmrq9jwsaj1hmnb156sqjcfywcsdvkzjfw";
|
|
};
|
|
|
|
# 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
|
|
patches = [ ./hardcode_paths.HEAD.patch ./local_stage0.HEAD.patch ]
|
|
++ stdenv.lib.optional stdenv.needsPax ./grsec.HEAD.patch;
|
|
|
|
postPatch = ''
|
|
substituteInPlace src/librustc_trans/back/link.rs \
|
|
--subst-var-by "ccPath" "${stdenv.gcc}/bin/cc"
|
|
substituteInPlace src/librustc_back/archive.rs \
|
|
--subst-var-by "arPath" "${stdenv.gcc.binutils}/bin/ar"
|
|
|
|
substituteInPlace src/rust-installer/gen-install-script.sh \
|
|
--replace /bin/echo "${coreutils}/bin/echo"
|
|
'';
|
|
|
|
buildInputs = [ which file perl curl python27 makeWrapper git valgrind procps ];
|
|
|
|
enableParallelBuilding = false; # disabled due to rust-lang/rust#16305
|
|
|
|
preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
|
|
|
|
doCheck = true;
|
|
|
|
postInstall = ''
|
|
# Install documentation
|
|
cp -r doc "$out/share/doc"
|
|
'';
|
|
}
|