Rust infrastructure refactoring

Rust infrastructure updates & refactoring
This commit is contained in:
Moritz Ulrich 2016-06-03 00:11:13 +02:00
commit b05f991f5f
12 changed files with 172 additions and 125 deletions

View File

@ -44,6 +44,7 @@ in stdenv.mkDerivation (args // {
export CARGO_HOME="$(realpath deps)"
export RUST_LOG=${logLevel}
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
# Let's find out which $indexHash cargo uses for file:///dev/null
(cd $sourceRoot && cargo fetch &>/dev/null) || true

View File

@ -147,7 +147,7 @@ EOF
done
# Create ad-hoc branches for the revs we need
echo "$revs" | while read rev; do
echo "$revs" | tr " " "\n" | while read -d " " rev; do
echo "Creating git branch b_$rev $rev"
git branch b_$rev $rev
done

View File

@ -0,0 +1,12 @@
{ stdenv, callPackage, rustcStable }:
callPackage ./generic.nix {
shortVersion = "beta-1.10.0";
forceBundledLLVM = false;
configureFlags = [ "--release-channel=beta" ];
srcRev = "39f3c16cca889ef3f1719d9177e3315258222a65";
srcSha = "01bx6616lslp2mbj4h8bb6m042fs0y1z8g0jgpxvbk3fbhzwafrx";
patches = [ ./patches/disable-lockfile-check.patch ] ++
stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = rustcStable;
}

View File

@ -0,0 +1,58 @@
{ stdenv, fetchurl }:
let
platform = if stdenv.system == "i686-linux"
then "linux-i386"
else if stdenv.system == "x86_64-linux"
then "linux-x86_64"
else if stdenv.system == "i686-darwin"
then "macos-i386"
else if stdenv.system == "x86_64-darwin"
then "macos-x86_64"
else abort "no snapshot to bootstrap for this platform (missing platform url suffix)";
/* Rust is bootstrapped from an earlier built version. We need
to fetch these earlier versions, which vary per platform.
The shapshot info you want can be found at
https://github.com/rust-lang/rust/blob/{$shortVersion}/src/snapshots.txt
with the set you want at the top. Make sure this is the latest snapshot
for the tagged release and not a snapshot in the current HEAD.
NOTE: Rust 1.9.0 is the last version that uses snapshots
*/
snapshotHashLinux686 = "0e0e4448b80d0a12b75485795244bb3857a0a7ef";
snapshotHashLinux64 = "1273b6b6aed421c9e40c59f366d0df6092ec0397";
snapshotHashDarwin686 = "9f9c0b4a2db09acbce54b792fb8839a735585565";
snapshotHashDarwin64 = "52570f6fd915b0210a9be98cfc933148e16a75f8";
snapshotDate = "2016-03-18";
snapshotRev = "235d774";
snapshotHash = if stdenv.system == "i686-linux"
then snapshotHashLinux686
else if stdenv.system == "x86_64-linux"
then snapshotHashLinux64
else if stdenv.system == "i686-darwin"
then snapshotHashDarwin686
else if stdenv.system == "x86_64-darwin"
then snapshotHashDarwin64
else abort "no snapshot for platform ${stdenv.system}";
snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshotHash}.tar.bz2";
in
stdenv.mkDerivation {
name = "rust-bootstrap";
src = fetchurl {
url = "http://static.rust-lang.org/stage0-snapshots/${snapshotName}";
sha1 = snapshotHash;
};
dontStrip = true;
installPhase = ''
mkdir -p "$out"
cp -r bin "$out/bin"
'' + stdenv.lib.optionalString stdenv.isLinux ''
patchelf --interpreter "${stdenv.glibc.out}/lib/${stdenv.cc.dynamicLinker}" \
--set-rpath "${stdenv.cc.cc.lib}/lib/:${stdenv.cc.cc.lib}/lib64/" \
"$out/bin/rustc"
'';
}

View File

@ -1,27 +0,0 @@
{ stdenv, callPackage }:
callPackage ./generic.nix {
shortVersion = "1.9.0";
isRelease = true;
forceBundledLLVM = false;
configureFlags = [ "--release-channel=stable" ];
srcSha = "0yg5admbypqld0gmxbhrh2yag5kxjklpjgldrp3pd5vczkl13aml";
/* Rust is bootstrapped from an earlier built version. We need
to fetch these earlier versions, which vary per platform.
The shapshot info you want can be found at
https://github.com/rust-lang/rust/blob/{$shortVersion}/src/snapshots.txt
with the set you want at the top. Make sure this is the latest snapshot
for the tagged release and not a snapshot in the current HEAD.
*/
snapshotHashLinux686 = "0e0e4448b80d0a12b75485795244bb3857a0a7ef";
snapshotHashLinux64 = "1273b6b6aed421c9e40c59f366d0df6092ec0397";
snapshotHashDarwin686 = "9f9c0b4a2db09acbce54b792fb8839a735585565";
snapshotHashDarwin64 = "52570f6fd915b0210a9be98cfc933148e16a75f8";
snapshotDate = "2016-03-18";
snapshotRev = "235d774";
patches = [ ./patches/remove-uneeded-git.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
}

View File

@ -1,14 +1,11 @@
{ stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
, llvm, jemalloc, ncurses, darwin, binutils
, llvm, jemalloc, ncurses, darwin, binutils, rustc
, shortVersion, isRelease
, isRelease ? false
, shortVersion
, forceBundledLLVM ? false
, srcSha, srcRev ? ""
, snapshotHashLinux686, snapshotHashLinux64
, snapshotHashDarwin686, snapshotHashDarwin64
, snapshotDate, snapshotRev
, srcSha, srcRev
, configureFlags ? []
, patches
} @ args:
@ -26,9 +23,8 @@ sure those derivations still compile. (racer, for example).
*/
assert (if isRelease then srcRev == "" else srcRev != "");
let version = if isRelease then
let
version = if isRelease then
"${shortVersion}"
else
"${shortVersion}-g${builtins.substring 0 7 srcRev}";
@ -39,16 +35,6 @@ let version = if isRelease then
llvmShared = llvm.override { enableSharedLibraries = true; };
platform = if stdenv.system == "i686-linux"
then "linux-i386"
else if stdenv.system == "x86_64-linux"
then "linux-x86_64"
else if stdenv.system == "i686-darwin"
then "macos-i386"
else if stdenv.system == "x86_64-darwin"
then "macos-x86_64"
else abort "no snapshot to bootstrap for this platform (missing platform url suffix)";
target = if stdenv.system == "i686-linux"
then "i686-unknown-linux-gnu"
else if stdenv.system == "x86_64-linux"
@ -66,20 +52,9 @@ let version = if isRelease then
license = [ licenses.mit licenses.asl20 ];
platforms = platforms.linux ++ platforms.darwin;
};
snapshotHash = if stdenv.system == "i686-linux"
then snapshotHashLinux686
else if stdenv.system == "x86_64-linux"
then snapshotHashLinux64
else if stdenv.system == "i686-darwin"
then snapshotHashDarwin686
else if stdenv.system == "x86_64-darwin"
then snapshotHashDarwin64
else abort "no snapshot for platform ${stdenv.system}";
snapshotName = "rust-stage0-${snapshotDate}-${snapshotRev}-${platform}-${snapshotHash}.tar.bz2";
in
with stdenv.lib; stdenv.mkDerivation {
stdenv.mkDerivation {
inherit name;
inherit version;
inherit meta;
@ -88,42 +63,19 @@ with stdenv.lib; stdenv.mkDerivation {
NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-rpath ${llvmShared}/lib";
src = if isRelease then
fetchzip {
url = "http://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
sha256 = srcSha;
}
else
fetchgit {
url = https://github.com/rust-lang/rust;
rev = srcRev;
sha256 = srcSha;
};
# 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 = snapshotHash;
};
dontStrip = true;
installPhase = ''
mkdir -p "$out"
cp -r bin "$out/bin"
'' + optionalString stdenv.isLinux ''
patchelf --interpreter "${stdenv.glibc.out}/lib/${stdenv.cc.dynamicLinker}" \
--set-rpath "${stdenv.cc.cc.lib}/lib/:${stdenv.cc.cc.lib}/lib64/" \
"$out/bin/rustc"
'';
src = fetchgit {
url = https://github.com/rust-lang/rust;
rev = srcRev;
sha256 = srcSha;
};
# We need rust to build rust. If we don't provide it, configure will try to download it.
configureFlags = configureFlags
++ [ "--enable-local-rust" "--local-rust-root=$snapshot" "--enable-rpath" ]
++ [ "--enable-local-rust" "--local-rust-root=${rustc}" "--enable-rpath" ]
# ++ [ "--jemalloc-root=${jemalloc}/lib"
++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ]
++ optional (stdenv.cc.cc ? isClang) "--enable-clang"
++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
++ stdenv.lib.optional (stdenv.cc.cc ? isClang) "--enable-clang"
++ stdenv.lib.optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
inherit patches;
@ -138,7 +90,7 @@ with stdenv.lib; stdenv.mkDerivation {
--replace "\$\$(subst /,//," "\$\$(subst /,/,"
# Fix dynamic linking against llvm
${optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
${stdenv.lib.optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
# Fix the configure script to not require curl as we won't use it
sed -i configure \
@ -160,9 +112,9 @@ with stdenv.lib; stdenv.mkDerivation {
'';
# ps is needed for one of the test cases
nativeBuildInputs = [ file python2 procps ];
nativeBuildInputs = [ file python2 procps rustc ];
buildInputs = [ ncurses ]
++ optional (!forceBundledLLVM) llvmShared;
++ stdenv.lib.optional (!forceBundledLLVM) llvmShared;
# https://github.com/rust-lang/rust/issues/30181
# enableParallelBuilding = false; # missing files during linking, occasionally

View File

@ -1,27 +1,13 @@
# Please make sure to check if rustfmt still builds when updating nightly
{ stdenv, callPackage }:
{ stdenv, callPackage, rustcStable }:
callPackage ./generic.nix {
shortVersion = "2016-03-22";
isRelease = false;
forceBundledLLVM = true;
srcRev = "6cc502c986d42da407e26a49d4f09f21d3072fcb";
srcSha = "096lsc8irh9a7w494yaji28kzy9frs2myqrfyj0fzbxkvs3yfhzz";
/* Rust is bootstrapped from an earlier built version. We need
to fetch these earlier versions, which vary per platform.
The shapshot info you want can be found at
https://github.com/rust-lang/rust/blob/{$shortVersion}/src/snapshots.txt
with the set you want at the top.
*/
snapshotHashLinux686 = "0e0e4448b80d0a12b75485795244bb3857a0a7ef";
snapshotHashLinux64 = "1273b6b6aed421c9e40c59f366d0df6092ec0397";
snapshotHashDarwin686 = "9f9c0b4a2db09acbce54b792fb8839a735585565";
snapshotHashDarwin64 = "52570f6fd915b0210a9be98cfc933148e16a75f8";
snapshotDate = "2016-03-18";
snapshotRev = "235d774";
patches = [ ./patches/remove-uneeded-git.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
shortVersion = "master-1.11.0";
forceBundledLLVM = false;
srcRev = "298730e7032cd55809423773da397cd5c7d827d4";
srcSha = "0hyz5j1z75sjkgsifzgxviv3b1lhgaz8wqwvmq80xx5vd78yd0c1";
patches = [ ./patches/disable-lockfile-check.patch
./patches/use-rustc-1.9.0.patch ] ++
stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = rustcStable;
}

View File

@ -0,0 +1,25 @@
From e7378e267bba203bd593b49705c24303b0a46cb7 Mon Sep 17 00:00:00 2001
From: David Craven <david@craven.ch>
Date: Wed, 1 Jun 2016 01:41:35 +0200
Subject: [PATCH] disable-lockfile-check
---
src/tools/tidy/src/main.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index 2839bbd..50142ff 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -47,7 +47,7 @@ fn main() {
errors::check(&path, &mut bad);
cargo::check(&path, &mut bad);
features::check(&path, &mut bad);
- cargo_lock::check(&path, &mut bad);
+ //cargo_lock::check(&path, &mut bad);
if bad {
panic!("some tidy checks failed");
--
2.8.3

View File

@ -0,0 +1,25 @@
From 2710f3c8ae142abe1720b3476cd1ca60cee0c077 Mon Sep 17 00:00:00 2001
From: David Craven <david@craven.ch>
Date: Wed, 1 Jun 2016 00:12:35 +0200
Subject: [PATCH] Patch stage0.txt to use rustc 1.9.0
---
src/stage0.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/stage0.txt b/src/stage0.txt
index 58b7f8f..3c84cab 100644
--- a/src/stage0.txt
+++ b/src/stage0.txt
@@ -12,6 +12,6 @@
# tarball for a stable release you'll likely see `1.x.0-$date` where `1.x.0` was
# released on `$date`
-rustc: beta-2016-04-13
-rustc_key: c2743eb4
+rustc: 1.9.0-2016-05-24
+rustc_key: d16b8f0e
cargo: nightly-2016-04-10
--
2.8.3

View File

@ -0,0 +1,13 @@
{ stdenv, callPackage }:
callPackage ./generic.nix {
shortVersion = "1.9.0";
isRelease = true;
forceBundledLLVM = false;
configureFlags = [ "--release-channel=stable" ];
srcRev = "e4e8b666850a763fdf1c3c2c142856ab51e32779";
srcSha = "1pz4qx70mqv78fxm4w1mq7csk5pssq4qmr2vwwb5v8hyx03caff8";
patches = [ ./patches/remove-uneeded-git.patch ]
++ stdenv.lib.optional stdenv.needsPax ./patches/grsec.patch;
rustc = callPackage ./bootstrap.nix {};
}

View File

@ -14,11 +14,11 @@ buildRustPackage rec {
# Needs to use fetchgit instead of fetchFromGitHub to fetch submodules
src = fetchgit {
url = "git://github.com/rust-lang/cargo";
rev = "132b82d75f607dcb1116b8d44fe60f202f1eb110";
sha256 = "0kx2m0p45zr0ils2ax19sr32cibjppgwj8xvsgrfvzvlnc540xpl";
rev = "7d79da08238e3d47e0bc4406155bdcc45ccb8c82";
sha256 = "190qdii53s4vk940yzs2iizhfs22y2v8bzw051bl6bk9bs3y4fdd";
};
depsSha256 = "19d2fl5p92108a0yjpix0qxdc23jy122xc87k69hk0pwwxa92l3a";
depsSha256 = "1xbb33aqnf5yyws6gjys9w8kznbh9rh6hw8mpg1hhq1ahipc2j1f";
buildInputs = [ file curl pkgconfig python openssl cmake zlib makeWrapper ];

View File

@ -5264,17 +5264,19 @@ in
rtags = callPackage ../development/tools/rtags/default.nix {};
rustcMaster = lowPrio (callPackage ../development/compilers/rustc/head.nix {});
rustc = callPackage ../development/compilers/rustc {};
rustc = rustcStable;
rustcStable = callPackage ../development/compilers/rustc/stable.nix {};
rustcBeta = lowPrio (callPackage ../development/compilers/rustc/beta.nix {});
rustcUnstable = lowPrio (callPackage ../development/compilers/rustc/head.nix {});
rustPlatform = rustStable;
rustStable = recurseIntoAttrs (makeRustPlatform cargo rustStable);
rustBeta = lowPrio (recurseIntoAttrs (makeRustPlatform cargoUnstable rustBeta));
rustUnstable = lowPrio (recurseIntoAttrs (makeRustPlatform cargoUnstable rustUnstable));
# rust platform to build cargo itself (with cargoSnapshot)
rustCargoPlatform = makeRustPlatform (cargoSnapshot rustc) rustCargoPlatform;
rustUnstableCargoPlatform = makeRustPlatform (cargoSnapshot rustcMaster) rustUnstableCargoPlatform;
rustCargoPlatform = makeRustPlatform (cargoSnapshot rustcStable) rustCargoPlatform;
rustUnstableCargoPlatform = makeRustPlatform (cargoSnapshot rustcUnstable) rustUnstableCargoPlatform;
makeRustPlatform = cargo: self:
let