Browse Source

rustc: use more up-to-date upstream, build for riscv

pull/1/head
parent
commit
96b7248514
  1. 8
      compilers/rust/binaryBuild.nix
  2. 17
      compilers/rust/bootstrap.nix
  3. 27
      compilers/rust/default.nix
  4. 10
      compilers/rust/patches/disable-test-inherit-env.patch
  5. 44
      compilers/rust/rustc.nix

8
compilers/rust/binaryBuild.nix

@ -1,4 +1,4 @@
{ stdenv, makeWrapper, bash, buildRustPackage, curl, darwin
{ stdenv, makeWrapper, bash, curl, darwin
, version
, src
, platform
@ -18,8 +18,6 @@ let
in
rec {
inherit buildRustPackage;
rustc = stdenv.mkDerivation rec {
name = "rustc-${versionType}-${version}";
@ -29,7 +27,7 @@ rec {
meta = with stdenv.lib; {
homepage = http://www.rust-lang.org/;
description = "A safe, concurrent, practical language";
#maintainers = with maintainers; [ sb0 ];
maintainers = with maintainers; [ sb0 ];
license = [ licenses.mit licenses.asl20 ];
};
@ -83,7 +81,7 @@ rec {
meta = with stdenv.lib; {
homepage = http://www.rust-lang.org/;
description = "A safe, concurrent, practical language";
#maintainers = with maintainers; [ sb0 ];
maintainers = with maintainers; [ sb0 ];
license = [ licenses.mit licenses.asl20 ];
};

17
compilers/rust/bootstrap.nix

@ -3,16 +3,16 @@
let
# Note: the version MUST be one version prior to the version we're
# building
version = "1.28.0";
version = "1.31.1";
# fetch hashes by running `print-hashes.sh 1.24.1`
# fetch hashes by running `print-hashes.sh 1.31.1`
hashes = {
i686-unknown-linux-gnu = "de7cdb4e665e897ea9b10bf6fd545f900683296456d6a11d8510397bb330455f";
x86_64-unknown-linux-gnu = "2a1390340db1d24a9498036884e6b2748e9b4b057fc5219694e298bdaa37b810";
armv7-unknown-linux-gnueabihf = "346558d14050853b87049e5e1fbfae0bf0360a2f7c57433c6985b1a879c349a2";
aarch64-unknown-linux-gnu = "9b6fbcee73070332c811c0ddff399fa31965bec62ef258656c0c90354f6231c1";
i686-apple-darwin = "752e2c9182e057c4a54152d1e0b3949482c225d02bb69d9d9a4127dc2a65fb68";
x86_64-apple-darwin = "5d7a70ed4701fe9410041c1eea025c95cad97e5b3d8acc46426f9ac4f9f02393";
i686-unknown-linux-gnu = "1e77e5e8c745320faad9ce6f319a77b4a2e75d972eb68a195acd081ad910ab6d";
x86_64-unknown-linux-gnu = "a64685535d0c457f49a8712a096a5c21564cd66fd2f7da739487f028192ebe3c";
armv7-unknown-linux-gnueabihf = "11c717b781a7af5bdc829894139f8f45d4c12a061f7f9e39481f21426a04eb21";
aarch64-unknown-linux-gnu = "29a7c6eb536fefd0ca459e48dfaea006aa8bff8a87aa82a9b7d483487033632a";
i686-apple-darwin = "46566dc25fcbd8badc9950b8c9f9b0faeca065b5a09cd96258e4f4b10d686aed";
x86_64-apple-darwin = "8398b1b303bdf0e7605d08b87070a514a4f588797c6fb3593718cb9cec233ad6";
};
platform =
@ -37,6 +37,5 @@ let
in callPackage ./binaryBuild.nix
{ inherit version src platform;
buildRustPackage = null;
versionType = "bootstrap";
}

27
compilers/rust/default.nix

@ -2,27 +2,23 @@
, targets ? []
, targetToolchains ? []
, targetPatches ? []
, fetchFromGitHub
}:
let
rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}));
version = "1.28.0";
src = fetchFromGitHub {
owner = "m-labs";
repo = "rust";
sha256 = "03lfps3xvvv7wv1nnwn3n1ji13z099vx8c3fpbzp9rnasrwzp5jy";
rev = "f305fb024318e96997fbe6e4a105b0cc1052aad4"; # artiq-1.28.0 branch
fetchSubmodules = true;
version = "1.32.0";
src = fetchurl {
url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
sha256 = "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac";
};
# nixcloud team code
or1k-crates = stdenv.mkDerivation {
name = "or1k-crates";
riscv32imac-crates = stdenv.mkDerivation {
name = "riscv32imac-crates";
inherit src;
phases = [ "unpackPhase" "buildPhase" ];
buildPhase = ''
destdir=$out
rustc="${rustc_internal}/bin/rustc --out-dir ''${destdir} -L ''${destdir} --target or1k-unknown-none -g -C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s --crate-type rlib"
rustc="${rustc_internal}/bin/rustc --out-dir ''${destdir} -L ''${destdir} --target riscv32imac-unknown-none -g -C target-feature=+mul,+div,+ffl1,+cmov,+addc -C opt-level=s --crate-type rlib"
mkdir -p ''${destdir}
''${rustc} --crate-name core src/libcore/lib.rs
@ -45,11 +41,6 @@ let
# Re-evaluate if this we need to disable this one
#./patches/stdsimd-disable-doctest.patch
# Fails on hydra - not locally; the exact reason is unknown.
# Comments in the test suggest that some non-reproducible environment
# variables such $RANDOM can make it fail.
./patches/disable-test-inherit-env.patch
];
# 1. Upstream is not running tests on aarch64:
@ -67,8 +58,8 @@ in
src = ./.;
installPhase = ''
mkdir $out
mkdir -p $out/lib/rustlib/or1k-unknown-none/lib/
cp -r ${or1k-crates}/* $out/lib/rustlib/or1k-unknown-none/lib/
mkdir -p $out/lib/rustlib/riscv32imac-unknown-none/lib/
cp -r ${riscv32imac-crates}/* $out/lib/rustlib/riscv32imac-unknown-none/lib/
cp -r ${rustc_internal}/* $out
'';
meta = with stdenv.lib; {

10
compilers/rust/patches/disable-test-inherit-env.patch

@ -1,10 +0,0 @@
--- rustc-1.26.2-src.org/src/libstd/process.rs 2018-06-01 21:40:11.000000000 +0100
+++ rustc-1.26.2-src/src/libstd/process.rs 2018-06-08 07:50:23.023828658 +0100
@@ -1745,6 +1745,7 @@
}
#[test]
+ #[ignore]
fn test_inherit_env() {
use env;

44
compilers/rust/rustc.nix

@ -1,7 +1,7 @@
{ stdenv, targetPackages
, fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps
, llvm, jemalloc, ncurses, darwin, rustPlatform, git, cmake, curl
, which, libffi, gdb
, which, libffi, gdb, zlib
, version
, src
, configureFlags ? []
@ -11,7 +11,6 @@
, targetToolchains
, doCheck ? true
, broken ? false
, pkgs
}:
let
@ -19,11 +18,6 @@ let
inherit (darwin.apple_sdk.frameworks) Security;
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
src_rustc = fetchurl {
url = "https://static.rust-lang.org/dist/rustc-1.28.0-src.tar.gz";
sha256 = "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx";
};
in
stdenv.mkDerivation {
@ -71,14 +65,6 @@ stdenv.mkDerivation {
substituteInPlace Makefile --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)'
'';
# FIXME: qknight, readd deleted vendor folder from 1.28 rustc
preConfigure = ''
export HOME=$out
# HACK: we add the vendor folder from rustc 1.28 to make the compiling work
tar xf ${src_rustc}
mv rustc-1.28.0-src/src/vendor/ src/vendor
'';
patches = patches ++ targetPatches;
# the rust build system complains that nix alters the checksums
@ -93,29 +79,13 @@ stdenv.mkDerivation {
sed -i configure \
-e '/probe_need CFG_CURL curl/d'
# Fix the use of jemalloc prefixes which our jemalloc doesn't have
# TODO: reenable if we can figure out how to get our jemalloc to work
#[ -f src/liballoc_jemalloc/lib.rs ] && sed -i 's,je_,,g' src/liballoc_jemalloc/lib.rs
#[ -f src/liballoc/heap.rs ] && sed -i 's,je_,,g' src/liballoc/heap.rs # Remove for 1.4.0+
# Disable fragile tests.
rm -vr src/test/run-make/linker-output-non-utf8 || true
rm -vr src/test/run-make/issue-26092 || true
# Remove test targeted at LLVM 3.9 - https://github.com/rust-lang/rust/issues/36835
rm -vr src/test/run-pass/issue-36023.rs || true
# Disable test getting stuck on hydra - possible fix:
# https://reviews.llvm.org/rL281650
rm -vr src/test/run-pass/issue-36474.rs || true
# On Hydra: `TcpListener::bind(&addr)`: Address already in use (os error 98)'
sed '/^ *fn fast_rebind()/i#[ignore]' -i src/libstd/net/tcp.rs
# https://github.com/rust-lang/rust/issues/39522
echo removing gdb-version-sensitive tests...
find src/test/debuginfo -type f -execdir grep -q ignore-gdb-version '{}' \; -print -delete
rm src/test/debuginfo/{borrowed-c-style-enum.rs,c-style-enum-in-composite.rs,gdb-pretty-struct-and-enums-pre-gdb-7-7.rs,generic-enum-with-different-disr-sizes.rs}
rm src/test/debuginfo/{borrowed-c-style-enum.rs,c-style-enum-in-composite.rs,gdb-pretty-struct-and-enums.rs,generic-enum-with-different-disr-sizes.rs}
# Useful debugging parameter
# export VERBOSE=1
@ -123,18 +93,18 @@ stdenv.mkDerivation {
# Disable all lldb tests.
# error: Can't run LLDB test because LLDB's python path is not set
rm -vr src/test/debuginfo/*
rm -v src/test/run-pass/backtrace-debuginfo.rs
rm -v src/test/run-pass/backtrace-debuginfo.rs || true
# error: No such file or directory
rm -v src/test/run-pass/issue-45731.rs
rm -v src/test/ui/run-pass/issues/issue-45731.rs || true
# Disable tests that fail when sandboxing is enabled.
substituteInPlace src/libstd/sys/unix/ext/net.rs \
--replace '#[test]' '#[test] #[ignore]'
substituteInPlace src/test/run-pass/env-home-dir.rs \
--replace 'home_dir().is_some()' true
rm -v src/test/run-pass/fds-are-cloexec.rs # FIXME: pipes?
rm -v src/test/run-pass/sync-send-in-std.rs # FIXME: ???
rm -v src/test/run-pass/fds-are-cloexec.rs || true # FIXME: pipes?
rm -v src/test/ui/run-pass/threads-sendsync/sync-send-in-std.rs || true # FIXME: ???
'';
# rustc unfortunately need cmake for compiling llvm-rt but doesn't
@ -149,7 +119,7 @@ stdenv.mkDerivation {
# Only needed for the debuginfo tests
++ optional (!stdenv.isDarwin) gdb;
buildInputs = [ ncurses pkgs.zlib ] ++ targetToolchains
buildInputs = [ ncurses zlib ] ++ targetToolchains
++ optional stdenv.isDarwin Security;
outputs = [ "out" "man" "doc" ];

Loading…
Cancel
Save