1
0
Fork 0

partial rust cleanup (#13)

This commit is contained in:
Sebastien Bourdeauducq 2019-04-13 15:36:16 +08:00
parent 68bddf00fb
commit 044332d178
3 changed files with 41 additions and 67 deletions

View File

@ -3,11 +3,6 @@ with pkgs;
let let
pythonDeps = callPackage ./pkgs/python-deps.nix {}; pythonDeps = callPackage ./pkgs/python-deps.nix {};
# this code was copied from nipxkgs rev. ffafe9 (nixcloud team) and slightly modified
rust = callPackage ./pkgs/rust
(stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
});
llvm-src = callPackage ./fetch-llvm-clang.nix {}; llvm-src = callPackage ./fetch-llvm-clang.nix {};
boards = [ boards = [
@ -36,10 +31,14 @@ let
}; };
in in
rec { rec {
inherit (rust) rustc;
inherit (pythonDeps) asyncserial levenshtein pythonparser quamash pyqtgraph-qt5 misoc migen microscope jesd204b lit outputcheck sphinx-argparse wavedrom sphinxcontrib-wavedrom; inherit (pythonDeps) asyncserial levenshtein pythonparser quamash pyqtgraph-qt5 misoc migen microscope jesd204b lit outputcheck sphinx-argparse wavedrom sphinxcontrib-wavedrom;
binutils-or1k = callPackage ./pkgs/binutils-or1k.nix {}; binutils-or1k = callPackage ./pkgs/binutils-or1k.nix {};
llvm-or1k = callPackage ./pkgs/llvm-or1k.nix { inherit llvm-src; }; llvm-or1k = callPackage ./pkgs/llvm-or1k.nix { inherit llvm-src; };
rustc = callPackage ./pkgs/rust
((stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) {
stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4'
}) //
{ inherit llvm-or1k; });
llvmlite-artiq = callPackage ./pkgs/llvmlite-artiq.nix { inherit llvm-or1k; }; llvmlite-artiq = callPackage ./pkgs/llvmlite-artiq.nix { inherit llvm-or1k; };
libartiq-support = callPackage ./pkgs/libartiq-support.nix { inherit rustc; }; libartiq-support = callPackage ./pkgs/libartiq-support.nix { inherit rustc; };
artiq = callPackage ./pkgs/artiq.nix { inherit binutils-or1k llvm-or1k llvmlite-artiq libartiq-support lit outputcheck; }; artiq = callPackage ./pkgs/artiq.nix { inherit binutils-or1k llvm-or1k llvmlite-artiq libartiq-support lit outputcheck; };

View File

@ -1,4 +1,4 @@
{ stdenv, callPackage, recurseIntoAttrs, makeRustPlatform, llvm, fetchurl { stdenv, callPackage, recurseIntoAttrs, makeRustPlatform, llvm-or1k, fetchurl
, targets ? [] , targets ? []
, targetToolchains ? [] , targetToolchains ? []
, targetPatches ? [] , targetPatches ? []
@ -15,8 +15,32 @@ let
rev = "f305fb024318e96997fbe6e4a105b0cc1052aad4"; # artiq-1.28.0 branch rev = "f305fb024318e96997fbe6e4a105b0cc1052aad4"; # artiq-1.28.0 branch
fetchSubmodules = true; fetchSubmodules = true;
}; };
in rec { rustc_internal = callPackage ./rustc.nix {
# nixcloud team code inherit stdenv llvm-or1k targets targetPatches targetToolchains rustPlatform version src;
patches = [
./patches/net-tcp-disable-tests.patch
# 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
];
#configureFlags = [ "--release-channel=stable" ];
# 1. Upstream is not running tests on aarch64:
# see https://github.com/rust-lang/rust/issues/49807#issuecomment-380860567
# So we do the same.
# 2. Tests run out of memory for i686
#doCheck = !stdenv.isAarch64 && !stdenv.isi686;
# Disabled for now; see https://github.com/NixOS/nixpkgs/pull/42348#issuecomment-402115598.
doCheck = false;
};
or1k-crates = stdenv.mkDerivation { or1k-crates = stdenv.mkDerivation {
name = "or1k-crates"; name = "or1k-crates";
inherit src; inherit src;
@ -36,9 +60,8 @@ in rec {
''${rustc} -Cpanic=unwind --crate-name panic_unwind src/libpanic_unwind/lib.rs --cfg llvm_libunwind ''${rustc} -Cpanic=unwind --crate-name panic_unwind src/libpanic_unwind/lib.rs --cfg llvm_libunwind
''; '';
}; };
# nixcloud team code in
# this is basically a wrapper, which uses rustc_internal and inserts or1k-crates into it stdenv.mkDerivation {
rustc = stdenv.mkDerivation {
name = "rustc"; name = "rustc";
src = ./.; src = ./.;
installPhase = '' installPhase = ''
@ -54,35 +77,4 @@ in rec {
license = [ licenses.mit licenses.asl20 ]; license = [ licenses.mit licenses.asl20 ];
platforms = platforms.linux ++ platforms.darwin; platforms = platforms.linux ++ platforms.darwin;
}; };
};
# nixcloud team code
# originally rustc but now renamed to rustc_internal
rustc_internal = callPackage ./rustc.nix {
inherit stdenv llvm targets targetPatches targetToolchains rustPlatform version src;
patches = [
./patches/net-tcp-disable-tests.patch
# 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
];
forceBundledLLVM = true;
#configureFlags = [ "--release-channel=stable" ];
# 1. Upstream is not running tests on aarch64:
# see https://github.com/rust-lang/rust/issues/49807#issuecomment-380860567
# So we do the same.
# 2. Tests run out of memory for i686
#doCheck = !stdenv.isAarch64 && !stdenv.isi686;
# Disabled for now; see https://github.com/NixOS/nixpkgs/pull/42348#issuecomment-402115598.
doCheck = false;
};
} }

View File

@ -1,9 +1,8 @@
{ 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-or1k, ncurses, zlib, darwin, rustPlatform, git, cmake, curl
, which, libffi, gdb , which, libffi, gdb
, version , version
, forceBundledLLVM ? false
, src , src
, configureFlags ? [] , configureFlags ? []
, patches , patches
@ -12,16 +11,12 @@
, targetToolchains , targetToolchains
, doCheck ? true , doCheck ? true
, broken ? false , broken ? false
, pkgs
}: }:
let let
inherit (stdenv.lib) optional optionalString; inherit (stdenv.lib) optional optionalString;
inherit (darwin.apple_sdk.frameworks) Security; inherit (darwin.apple_sdk.frameworks) Security;
llvmShared = llvm.override { enableSharedLibraries = true; };
llvmOR1k = (import ../../default.nix {}).llvm-or1k;
target = builtins.replaceStrings [" "] [","] (builtins.toString targets); target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
src_rustc = fetchurl { src_rustc = fetchurl {
url = "https://static.rust-lang.org/dist/rustc-1.28.0-src.tar.gz"; url = "https://static.rust-lang.org/dist/rustc-1.28.0-src.tar.gz";
@ -47,7 +42,7 @@ stdenv.mkDerivation {
# See https://github.com/NixOS/nixpkgs/pull/34227 # See https://github.com/NixOS/nixpkgs/pull/34227
stripDebugList = if stdenv.isDarwin then [ "bin" ] else null; stripDebugList = if stdenv.isDarwin then [ "bin" ] else null;
NIX_LDFLAGS = optionalString stdenv.isDarwin "-rpath ${llvmShared}/lib"; NIX_LDFLAGS = optionalString stdenv.isDarwin "-rpath ${llvm-or1k}/lib";
# Enable nightly features in stable compiles (used for # Enable nightly features in stable compiles (used for
# bootstrapping, see https://github.com/rust-lang/rust/pull/37265). # bootstrapping, see https://github.com/rust-lang/rust/pull/37265).
@ -63,12 +58,10 @@ stdenv.mkDerivation {
configureFlags = configureFlags configureFlags = configureFlags
++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ] ++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
++ [ "--enable-vendor" ] ++ [ "--enable-vendor" ]
# ++ [ "--jemalloc-root=${jemalloc}/lib"
++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" ] ++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
++ optional (!forceBundledLLVM) [ "--enable-llvm-link-shared" ] ++ [ "--enable-llvm-link-shared" ]
++ optional (targets != []) "--target=${target}" ++ optional (targets != []) "--target=${target}"
#++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}" ++ [ "--llvm-root=${llvm-or1k}" ] ;
++ [ "--llvm-root=${llvmOR1k}" ] ;
# The bootstrap.py will generated a Makefile that then executes the build. # The bootstrap.py will generated a Makefile that then executes the build.
# The BOOTSTRAP_ARGS used by this Makefile must include all flags to pass # The BOOTSTRAP_ARGS used by this Makefile must include all flags to pass
@ -83,7 +76,6 @@ stdenv.mkDerivation {
# HACK: we add the vendor folder from rustc 1.28 to make the compiling work # HACK: we add the vendor folder from rustc 1.28 to make the compiling work
tar xf ${src_rustc} tar xf ${src_rustc}
mv rustc-1.28.0-src/src/vendor/ src/vendor mv rustc-1.28.0-src/src/vendor/ src/vendor
cp -R ${llvmOR1k} src/llvm
''; '';
patches = patches ++ targetPatches; patches = patches ++ targetPatches;
@ -96,18 +88,10 @@ stdenv.mkDerivation {
postPatch = '' postPatch = ''
patchShebangs src/etc patchShebangs src/etc
# Fix dynamic linking against llvm
#${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 # Fix the configure script to not require curl as we won't use it
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. # Disable fragile tests.
rm -vr src/test/run-make/linker-output-non-utf8 || true rm -vr src/test/run-make/linker-output-non-utf8 || true
rm -vr src/test/run-make/issue-26092 || true rm -vr src/test/run-make/issue-26092 || true
@ -159,9 +143,8 @@ 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 llvm-or1k ] ++ targetToolchains
++ optional stdenv.isDarwin Security ++ optional stdenv.isDarwin Security;
++ optional (!forceBundledLLVM) llvmShared;
outputs = [ "out" "man" "doc" ]; outputs = [ "out" "man" "doc" ];
setOutputFlags = false; setOutputFlags = false;