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

This commit is contained in:
Sebastien Bourdeauducq 2019-04-06 19:16:34 +08:00
parent b913a92a82
commit 96b7248514
5 changed files with 27 additions and 79 deletions

View File

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

View File

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

View File

@ -2,27 +2,23 @@
, targets ? [] , targets ? []
, targetToolchains ? [] , targetToolchains ? []
, targetPatches ? [] , targetPatches ? []
, fetchFromGitHub
}: }:
let let
rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {})); rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}));
version = "1.28.0"; version = "1.32.0";
src = fetchFromGitHub { src = fetchurl {
owner = "m-labs"; url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
repo = "rust"; sha256 = "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac";
sha256 = "03lfps3xvvv7wv1nnwn3n1ji13z099vx8c3fpbzp9rnasrwzp5jy";
rev = "f305fb024318e96997fbe6e4a105b0cc1052aad4"; # artiq-1.28.0 branch
fetchSubmodules = true;
}; };
# nixcloud team code # nixcloud team code
or1k-crates = stdenv.mkDerivation { riscv32imac-crates = stdenv.mkDerivation {
name = "or1k-crates"; name = "riscv32imac-crates";
inherit src; inherit src;
phases = [ "unpackPhase" "buildPhase" ]; phases = [ "unpackPhase" "buildPhase" ];
buildPhase = '' buildPhase = ''
destdir=$out 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} mkdir -p ''${destdir}
''${rustc} --crate-name core src/libcore/lib.rs ''${rustc} --crate-name core src/libcore/lib.rs
@ -45,11 +41,6 @@ let
# Re-evaluate if this we need to disable this one # Re-evaluate if this we need to disable this one
#./patches/stdsimd-disable-doctest.patch #./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: # 1. Upstream is not running tests on aarch64:
@ -67,8 +58,8 @@ in
src = ./.; src = ./.;
installPhase = '' installPhase = ''
mkdir $out mkdir $out
mkdir -p $out/lib/rustlib/or1k-unknown-none/lib/ mkdir -p $out/lib/rustlib/riscv32imac-unknown-none/lib/
cp -r ${or1k-crates}/* $out/lib/rustlib/or1k-unknown-none/lib/ cp -r ${riscv32imac-crates}/* $out/lib/rustlib/riscv32imac-unknown-none/lib/
cp -r ${rustc_internal}/* $out cp -r ${rustc_internal}/* $out
''; '';
meta = with stdenv.lib; { meta = with stdenv.lib; {

View File

@ -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;

View File

@ -1,7 +1,7 @@
{ stdenv, targetPackages { stdenv, targetPackages
, fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps , fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps
, llvm, jemalloc, ncurses, darwin, rustPlatform, git, cmake, curl , llvm, jemalloc, ncurses, darwin, rustPlatform, git, cmake, curl
, which, libffi, gdb , which, libffi, gdb, zlib
, version , version
, src , src
, configureFlags ? [] , configureFlags ? []
@ -11,7 +11,6 @@
, targetToolchains , targetToolchains
, doCheck ? true , doCheck ? true
, broken ? false , broken ? false
, pkgs
}: }:
let let
@ -19,11 +18,6 @@ let
inherit (darwin.apple_sdk.frameworks) Security; inherit (darwin.apple_sdk.frameworks) Security;
target = builtins.replaceStrings [" "] [","] (builtins.toString targets); 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 in
stdenv.mkDerivation { stdenv.mkDerivation {
@ -71,14 +65,6 @@ stdenv.mkDerivation {
substituteInPlace Makefile --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)' 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; patches = patches ++ targetPatches;
# the rust build system complains that nix alters the checksums # the rust build system complains that nix alters the checksums
@ -93,29 +79,13 @@ stdenv.mkDerivation {
sed -i configure \ sed -i configure \
-e '/probe_need CFG_CURL curl/d' -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)' # On Hydra: `TcpListener::bind(&addr)`: Address already in use (os error 98)'
sed '/^ *fn fast_rebind()/i#[ignore]' -i src/libstd/net/tcp.rs sed '/^ *fn fast_rebind()/i#[ignore]' -i src/libstd/net/tcp.rs
# https://github.com/rust-lang/rust/issues/39522 # https://github.com/rust-lang/rust/issues/39522
echo removing gdb-version-sensitive tests... echo removing gdb-version-sensitive tests...
find src/test/debuginfo -type f -execdir grep -q ignore-gdb-version '{}' \; -print -delete 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 # Useful debugging parameter
# export VERBOSE=1 # export VERBOSE=1
@ -123,18 +93,18 @@ stdenv.mkDerivation {
# Disable all lldb tests. # Disable all lldb tests.
# error: Can't run LLDB test because LLDB's python path is not set # error: Can't run LLDB test because LLDB's python path is not set
rm -vr src/test/debuginfo/* 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 # 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. # Disable tests that fail when sandboxing is enabled.
substituteInPlace src/libstd/sys/unix/ext/net.rs \ substituteInPlace src/libstd/sys/unix/ext/net.rs \
--replace '#[test]' '#[test] #[ignore]' --replace '#[test]' '#[test] #[ignore]'
substituteInPlace src/test/run-pass/env-home-dir.rs \ substituteInPlace src/test/run-pass/env-home-dir.rs \
--replace 'home_dir().is_some()' true --replace 'home_dir().is_some()' true
rm -v src/test/run-pass/fds-are-cloexec.rs # FIXME: pipes? rm -v src/test/run-pass/fds-are-cloexec.rs || true # FIXME: pipes?
rm -v src/test/run-pass/sync-send-in-std.rs # FIXME: ??? 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 # rustc unfortunately need cmake for compiling llvm-rt but doesn't
@ -149,7 +119,7 @@ stdenv.mkDerivation {
# Only needed for the debuginfo tests # Only needed for the debuginfo tests
++ optional (!stdenv.isDarwin) gdb; ++ optional (!stdenv.isDarwin) gdb;
buildInputs = [ ncurses pkgs.zlib ] ++ targetToolchains buildInputs = [ ncurses zlib ] ++ targetToolchains
++ optional stdenv.isDarwin Security; ++ optional stdenv.isDarwin Security;
outputs = [ "out" "man" "doc" ]; outputs = [ "out" "man" "doc" ];