use upstream rust/llvm
This commit is contained in:
parent
c3992220e5
commit
25fe837684
@ -1,61 +0,0 @@
|
||||
{ stdenv
|
||||
, fetchurl, runCommand
|
||||
, perl, groff, cmake, libxml2, python, libffi, valgrind
|
||||
, ...
|
||||
}:
|
||||
|
||||
let
|
||||
llvm-src = fetchurl {
|
||||
url = "https://releases.llvm.org/7.0.1/llvm-7.0.1.src.tar.xz";
|
||||
sha256 = "16s196wqzdw4pmri15hadzqgdi926zln3an2viwyq0kini6zr3d3";
|
||||
};
|
||||
clang-src = fetchurl {
|
||||
url = "https://releases.llvm.org/7.0.1/cfe-7.0.1.src.tar.xz";
|
||||
sha256 = "067lwggnbg0w1dfrps790r5l6k8n5zwhlsw7zb6zvmfpwpfn4nx4";
|
||||
};
|
||||
combined-src = runCommand "llvm-clang-src" {}
|
||||
''
|
||||
mkdir -p $out
|
||||
mkdir -p $out/tools/clang
|
||||
tar xf ${llvm-src} -C $out --strip-components=1
|
||||
tar xf ${clang-src} -C $out/tools/clang --strip-components=1
|
||||
'';
|
||||
in
|
||||
stdenv.mkDerivation rec {
|
||||
name = "llvm-hx";
|
||||
src = combined-src;
|
||||
|
||||
buildInputs = [ perl groff cmake libxml2 python libffi ] ++ stdenv.lib.optional stdenv.isLinux valgrind;
|
||||
|
||||
preBuild = ''
|
||||
NIX_BUILD_CORES=4
|
||||
makeFlagsArray=(-j''$NIX_BUILD_CORES)
|
||||
mkdir -p $out/
|
||||
'';
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCMAKE_BUILD_TYPE=Release"
|
||||
"-DLLVM_BUILD_LLVM_DYLIB=ON"
|
||||
"-DLLVM_LINK_LLVM_DYLIB=ON"
|
||||
"-DLLVM_TARGETS_TO_BUILD=X86"
|
||||
"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=RISCV"
|
||||
"-DLLVM_ENABLE_ASSERTIONS=OFF"
|
||||
"-DLLVM_INSTALL_UTILS=ON"
|
||||
"-DLLVM_INCLUDE_TESTS=OFF"
|
||||
"-DLLVM_INCLUDE_DOCS=OFF"
|
||||
"-DLLVM_INCLUDE_EXAMPLES=OFF"
|
||||
"-DCLANG_ENABLE_ARCMT=OFF"
|
||||
"-DCLANG_ENABLE_STATIC_ANALYZER=OFF"
|
||||
"-DCLANG_INCLUDE_TESTS=OFF"
|
||||
"-DCLANG_INCLUDE_DOCS=OFF"
|
||||
];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
meta = {
|
||||
description = "Collection of modular and reusable compiler and toolchain technologies";
|
||||
homepage = http://llvm.org/;
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
maintainers = with stdenv.lib.maintainers; [ sb0 ];
|
||||
platforms = stdenv.lib.platforms.all;
|
||||
};
|
||||
}
|
21
compilers/riscv32imc-crates.nix
Normal file
21
compilers/riscv32imc-crates.nix
Normal file
@ -0,0 +1,21 @@
|
||||
{ stdenv, rustc }:
|
||||
stdenv.mkDerivation {
|
||||
name = "riscv32imc-crates";
|
||||
src = rustc.src;
|
||||
phases = [ "unpackPhase" "buildPhase" ];
|
||||
buildPhase = ''
|
||||
destdir=$out/lib/rustlib/riscv32imac-unknown-none-elf/lib/
|
||||
rustc="${rustc}/bin/rustc --out-dir ''${destdir} -L ''${destdir} --target riscv32imc-unknown-none-elf -g -C opt-level=s --crate-type rlib"
|
||||
|
||||
mkdir -p ''${destdir}
|
||||
export RUSTC_BOOTSTRAP=1
|
||||
''${rustc} --crate-name core src/libcore/lib.rs
|
||||
''${rustc} --crate-name compiler_builtins src/libcompiler_builtins/src/lib.rs --cfg 'feature="compiler-builtins"' --cfg 'feature="mem"'
|
||||
''${rustc} --crate-name alloc src/liballoc/lib.rs
|
||||
'';
|
||||
# ''${rustc} --crate-name libc ${./libc_mini.rs}
|
||||
# ''${rustc} --crate-name unwind src/libunwind/lib.rs
|
||||
# ''${rustc} --crate-name std src/libstd/lib.rs
|
||||
# ''${rustc} -Cpanic=abort --crate-name panic_abort src/libpanic_abort/lib.rs
|
||||
# ''${rustc} -Cpanic=unwind --crate-name panic_unwind src/libpanic_unwind/lib.rs --cfg llvm_libunwind
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
{ stdenv, makeWrapper, bash, curl, darwin
|
||||
, version
|
||||
, src
|
||||
, platform
|
||||
, versionType
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (stdenv.lib) optionalString;
|
||||
inherit (darwin.apple_sdk.frameworks) Security;
|
||||
|
||||
bootstrapping = versionType == "bootstrap";
|
||||
|
||||
installComponents
|
||||
= "rustc,rust-std-${platform}"
|
||||
+ (optionalString bootstrapping ",cargo")
|
||||
;
|
||||
in
|
||||
|
||||
rec {
|
||||
rustc = stdenv.mkDerivation rec {
|
||||
name = "rustc-${versionType}-${version}";
|
||||
|
||||
inherit version;
|
||||
inherit src;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
homepage = http://www.rust-lang.org/;
|
||||
description = "A safe, concurrent, practical language";
|
||||
maintainers = with maintainers; [ sb0 ];
|
||||
license = [ licenses.mit licenses.asl20 ];
|
||||
};
|
||||
|
||||
buildInputs = [ bash ] ++ stdenv.lib.optional stdenv.isDarwin Security;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs .
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
./install.sh --prefix=$out \
|
||||
--components=${installComponents}
|
||||
|
||||
${optionalString (stdenv.isLinux && bootstrapping) ''
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/rustc"
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/rustdoc"
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/cargo"
|
||||
''}
|
||||
|
||||
${optionalString (stdenv.isDarwin && bootstrapping) ''
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustc"
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/rustdoc"
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
||||
for f in $out/lib/lib*.dylib; do
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$f"
|
||||
done
|
||||
''}
|
||||
|
||||
# Do NOT, I repeat, DO NOT use `wrapProgram` on $out/bin/rustc
|
||||
# (or similar) here. It causes strange effects where rustc loads
|
||||
# the wrong libraries in a bootstrap-build causing failures that
|
||||
# are very hard to track down. For details, see
|
||||
# https://github.com/rust-lang/rust/issues/34722#issuecomment-232164943
|
||||
'';
|
||||
};
|
||||
|
||||
cargo = stdenv.mkDerivation rec {
|
||||
name = "cargo-${versionType}-${version}";
|
||||
|
||||
inherit version;
|
||||
inherit src;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
homepage = http://www.rust-lang.org/;
|
||||
description = "A safe, concurrent, practical language";
|
||||
maintainers = with maintainers; [ sb0 ];
|
||||
license = [ licenses.mit licenses.asl20 ];
|
||||
};
|
||||
|
||||
buildInputs = [ makeWrapper bash ] ++ stdenv.lib.optional stdenv.isDarwin Security;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs .
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
patchShebangs ./install.sh
|
||||
./install.sh --prefix=$out \
|
||||
--components=cargo
|
||||
|
||||
${optionalString (stdenv.isLinux && bootstrapping) ''
|
||||
patchelf \
|
||||
--set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
|
||||
"$out/bin/cargo"
|
||||
''}
|
||||
|
||||
${optionalString (stdenv.isDarwin && bootstrapping) ''
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib '${darwin.libiconv}/lib/libiconv.2.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libresolv.9.dylib '${darwin.libresolv}/lib/libresolv.9.dylib' "$out/bin/cargo"
|
||||
install_name_tool -change /usr/lib/libcurl.4.dylib '${stdenv.lib.getLib curl}/lib/libcurl.4.dylib' "$out/bin/cargo"
|
||||
''}
|
||||
|
||||
wrapProgram "$out/bin/cargo" \
|
||||
--suffix PATH : "${rustc}/bin"
|
||||
'';
|
||||
};
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
{ stdenv, fetchurl, callPackage }:
|
||||
|
||||
let
|
||||
# Note: the version MUST be one version prior to the version we're
|
||||
# building
|
||||
version = "1.31.1";
|
||||
|
||||
# fetch hashes by running `print-hashes.sh 1.31.1`
|
||||
hashes = {
|
||||
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 =
|
||||
if stdenv.hostPlatform.system == "i686-linux"
|
||||
then "i686-unknown-linux-gnu"
|
||||
else if stdenv.hostPlatform.system == "x86_64-linux"
|
||||
then "x86_64-unknown-linux-gnu"
|
||||
else if stdenv.hostPlatform.system == "armv7l-linux"
|
||||
then "armv7-unknown-linux-gnueabihf"
|
||||
else if stdenv.hostPlatform.system == "aarch64-linux"
|
||||
then "aarch64-unknown-linux-gnu"
|
||||
else if stdenv.hostPlatform.system == "i686-darwin"
|
||||
then "i686-apple-darwin"
|
||||
else if stdenv.hostPlatform.system == "x86_64-darwin"
|
||||
then "x86_64-apple-darwin"
|
||||
else throw "missing bootstrap url for platform ${stdenv.hostPlatform.system}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://static.rust-lang.org/dist/rust-${version}-${platform}.tar.gz";
|
||||
sha256 = hashes."${platform}";
|
||||
};
|
||||
|
||||
in callPackage ./binaryBuild.nix
|
||||
{ inherit version src platform;
|
||||
versionType = "bootstrap";
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
{ stdenv, callPackage, recurseIntoAttrs, makeRustPlatform, llvm, fetchurl
|
||||
, targets ? []
|
||||
, targetToolchains ? []
|
||||
, targetPatches ? []
|
||||
}:
|
||||
|
||||
let
|
||||
rustPlatform = recurseIntoAttrs (makeRustPlatform (callPackage ./bootstrap.nix {}));
|
||||
version = "1.32.0";
|
||||
src = fetchurl {
|
||||
url = "https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz";
|
||||
sha256 = "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac";
|
||||
};
|
||||
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 riscv32imac-unknown-none-elf -g -C opt-level=s --crate-type rlib"
|
||||
|
||||
mkdir -p ''${destdir}
|
||||
''${rustc} --crate-name core src/libcore/lib.rs
|
||||
''${rustc} --crate-name compiler_builtins src/libcompiler_builtins/src/lib.rs --cfg 'feature="compiler-builtins"' --cfg 'feature="mem"'
|
||||
''${rustc} --crate-name alloc src/liballoc/lib.rs
|
||||
'';
|
||||
# ''${rustc} --crate-name libc ${./libc_mini.rs}
|
||||
# ''${rustc} --crate-name unwind src/libunwind/lib.rs
|
||||
# ''${rustc} --crate-name std src/libstd/lib.rs
|
||||
# ''${rustc} -Cpanic=abort --crate-name panic_abort src/libpanic_abort/lib.rs
|
||||
# ''${rustc} -Cpanic=unwind --crate-name panic_unwind src/libpanic_unwind/lib.rs --cfg llvm_libunwind
|
||||
};
|
||||
# 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
|
||||
];
|
||||
|
||||
# 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;
|
||||
};
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
name = "rustc";
|
||||
src = ./.;
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
mkdir -p $out/lib/rustlib/riscv32imac-unknown-none-elf/lib/
|
||||
cp -r ${riscv32imac-crates}/* $out/lib/rustlib/riscv32imac-unknown-none-elf/lib/
|
||||
cp -r ${rustc_internal}/* $out
|
||||
'';
|
||||
meta = with stdenv.lib; {
|
||||
homepage = https://www.rust-lang.org/;
|
||||
description = "A safe, concurrent, practical language";
|
||||
maintainers = with maintainers; [ sb0 ];
|
||||
license = [ licenses.mit licenses.asl20 ];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
};
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs
|
||||
index 0f60b5b3e..9b08415e7 100644
|
||||
--- a/src/libstd/net/tcp.rs
|
||||
+++ b/src/libstd/net/tcp.rs
|
||||
@@ -962,6 +962,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn listen_localhost() {
|
||||
let socket_addr = next_test_ip4();
|
||||
@@ -1020,6 +1021,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn read_eof() {
|
||||
each_ip(&mut |addr| {
|
||||
@@ -1039,6 +1041,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn write_close() {
|
||||
each_ip(&mut |addr| {
|
||||
@@ -1065,6 +1068,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn multiple_connect_serial() {
|
||||
each_ip(&mut |addr| {
|
||||
@@ -1087,6 +1091,7 @@ mod tests {
|
||||
})
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn multiple_connect_interleaved_greedy_schedule() {
|
||||
const MAX: usize = 10;
|
||||
@@ -1123,6 +1128,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
fn multiple_connect_interleaved_lazy_schedule() {
|
||||
const MAX: usize = 10;
|
||||
each_ip(&mut |addr| {
|
||||
@@ -1401,6 +1407,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
fn clone_while_reading() {
|
||||
each_ip(&mut |addr| {
|
||||
let accept = t!(TcpListener::bind(&addr));
|
||||
@@ -1421,7 +1422,10 @@ mod tests {
|
||||
|
||||
// FIXME: re-enabled bitrig/openbsd tests once their socket timeout code
|
||||
// no longer has rounding errors.
|
||||
- #[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)]
|
||||
+ #[cfg_attr(any(target_os = "bitrig",
|
||||
+ target_os = "netbsd",
|
||||
+ target_os = "openbsd",
|
||||
+ target_os = "macos"), ignore)]
|
||||
#[test]
|
||||
fn timeouts() {
|
||||
let addr = next_test_ip4();
|
||||
@@ -1596,6 +1603,7 @@ mod tests {
|
||||
drop(listener);
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn nodelay() {
|
||||
let addr = next_test_ip4();
|
||||
@@ -1610,6 +1618,7 @@ mod tests {
|
||||
assert_eq!(false, t!(stream.nodelay()));
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn ttl() {
|
||||
let ttl = 100;
|
||||
@@ -1647,6 +1656,7 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
+ #[cfg_attr(target_os = "macos", ignore)]
|
||||
#[test]
|
||||
fn peek() {
|
||||
each_ip(&mut |addr| {
|
||||
@@ -1679,6 +1689,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
+ #[cfg_attr(any(target_os = "linux", target_os = "macos"), ignore)]
|
||||
fn connect_timeout_unroutable() {
|
||||
// this IP is unroutable, so connections should always time out,
|
||||
// provided the network is reachable to begin with.
|
@ -1,20 +0,0 @@
|
||||
diff --git a/src/stdsimd/coresimd/x86/mod.rs b/src/stdsimd/coresimd/x86/mod.rs
|
||||
index 32915c332..7cb54f31e 100644
|
||||
--- a/src/stdsimd/coresimd/x86/mod.rs
|
||||
+++ b/src/stdsimd/coresimd/x86/mod.rs
|
||||
@@ -279,7 +279,6 @@ types! {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
- /// ```
|
||||
/// # #![feature(cfg_target_feature, target_feature, stdsimd)]
|
||||
/// # #![cfg_attr(not(dox), no_std)]
|
||||
/// # #[cfg(not(dox))]
|
||||
@@ -301,7 +300,6 @@ types! {
|
||||
/// # }
|
||||
/// # if is_x86_feature_detected!("sse") { unsafe { foo() } }
|
||||
/// # }
|
||||
- /// ```
|
||||
pub struct __m256(f32, f32, f32, f32, f32, f32, f32, f32);
|
||||
|
||||
/// 256-bit wide set of four `f64` types, x86-specific
|
@ -1,38 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# All rust-related downloads can be found at
|
||||
# https://static.rust-lang.org/dist/index.html. To find the date on
|
||||
# which a particular thing was last updated, look for the *-date.txt
|
||||
# file, e.g.
|
||||
# https://static.rust-lang.org/dist/channel-rust-beta-date.txt
|
||||
|
||||
PLATFORMS=(
|
||||
i686-unknown-linux-gnu
|
||||
x86_64-unknown-linux-gnu
|
||||
armv7-unknown-linux-gnueabihf
|
||||
aarch64-unknown-linux-gnu
|
||||
i686-apple-darwin
|
||||
x86_64-apple-darwin
|
||||
)
|
||||
BASEURL=https://static.rust-lang.org/dist
|
||||
VERSION=${1:-}
|
||||
DATE=${2:-}
|
||||
|
||||
if [[ -z $VERSION ]]
|
||||
then
|
||||
echo "No version supplied"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [[ -n $DATE ]]
|
||||
then
|
||||
BASEURL=$BASEURL/$DATE
|
||||
fi
|
||||
|
||||
for PLATFORM in "${PLATFORMS[@]}"
|
||||
do
|
||||
URL="$BASEURL/rust-$VERSION-$PLATFORM.tar.gz.sha256"
|
||||
SHA256=$(curl -sSfL $URL | cut -d ' ' -f 1)
|
||||
echo "$PLATFORM = \"$SHA256\";"
|
||||
done
|
@ -1,157 +0,0 @@
|
||||
{ stdenv, targetPackages
|
||||
, fetchurl, fetchgit, fetchzip, file, python2, tzdata, ps
|
||||
, llvm, ncurses, darwin, rustPlatform, git, cmake, curl
|
||||
, which, libffi, gdb, zlib, libxml2
|
||||
, version
|
||||
, src
|
||||
, configureFlags ? []
|
||||
, patches
|
||||
, targets
|
||||
, targetPatches
|
||||
, targetToolchains
|
||||
, doCheck ? true
|
||||
, broken ? false
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (stdenv.lib) optional optionalString;
|
||||
inherit (darwin.apple_sdk.frameworks) Security;
|
||||
|
||||
target = builtins.replaceStrings [" "] [","] (builtins.toString targets);
|
||||
in
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "rustc-${version}";
|
||||
inherit version;
|
||||
|
||||
inherit src;
|
||||
|
||||
__darwinAllowLocalNetworking = true;
|
||||
|
||||
# rustc complains about modified source files otherwise
|
||||
dontUpdateAutotoolsGnuConfigScripts = true;
|
||||
|
||||
# Running the default `strip -S` command on Darwin corrupts the
|
||||
# .rlib files in "lib/".
|
||||
#
|
||||
# See https://github.com/NixOS/nixpkgs/pull/34227
|
||||
stripDebugList = if stdenv.isDarwin then [ "bin" ] else null;
|
||||
|
||||
NIX_LDFLAGS = optionalString stdenv.isDarwin "-rpath ${llvm}/lib";
|
||||
|
||||
# Enable nightly features in stable compiles (used for
|
||||
# bootstrapping, see https://github.com/rust-lang/rust/pull/37265).
|
||||
# This loosens the hard restrictions on bootstrapping-compiler
|
||||
# versions.
|
||||
RUSTC_BOOTSTRAP = "1";
|
||||
|
||||
# Increase codegen units to introduce parallelism within the compiler.
|
||||
RUSTFLAGS = "-Ccodegen-units=10";
|
||||
|
||||
# We need rust to build rust. If we don't provide it, configure will try to download it.
|
||||
# Reference: https://github.com/rust-lang/rust/blob/master/src/bootstrap/configure.py
|
||||
configureFlags = configureFlags
|
||||
++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
|
||||
++ [ "--enable-vendor" ]
|
||||
++ [ "--default-linker=${targetPackages.stdenv.cc}/bin/cc" ]
|
||||
++ optional (targets != []) "--target=${target}"
|
||||
++ [ "--llvm-root=${llvm}" ] ;
|
||||
|
||||
# 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
|
||||
# to the bootstrap builder.
|
||||
postConfigure = ''
|
||||
substituteInPlace Makefile --replace 'BOOTSTRAP_ARGS :=' 'BOOTSTRAP_ARGS := --jobs $(NIX_BUILD_CORES)'
|
||||
'';
|
||||
|
||||
patches = patches ++ targetPatches;
|
||||
|
||||
# the rust build system complains that nix alters the checksums
|
||||
dontFixLibtool = true;
|
||||
|
||||
passthru.target = target;
|
||||
|
||||
postPatch = ''
|
||||
patchShebangs src/etc
|
||||
|
||||
# Fix the configure script to not require curl as we won't use it
|
||||
sed -i configure \
|
||||
-e '/probe_need CFG_CURL curl/d'
|
||||
|
||||
# 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.rs,generic-enum-with-different-disr-sizes.rs}
|
||||
|
||||
# Useful debugging parameter
|
||||
# export VERBOSE=1
|
||||
'' + optionalString stdenv.isDarwin ''
|
||||
# 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 || true
|
||||
|
||||
# error: No such file or directory
|
||||
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 || 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
|
||||
# use it for the normal build. This disables cmake in Nix.
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
# ps is needed for one of the test cases
|
||||
nativeBuildInputs =
|
||||
[ file python2 ps rustPlatform.rust.rustc git cmake
|
||||
which libffi
|
||||
]
|
||||
# Only needed for the debuginfo tests
|
||||
++ optional (!stdenv.isDarwin) gdb;
|
||||
|
||||
buildInputs = [ ncurses zlib libxml2 ] ++ targetToolchains
|
||||
++ optional stdenv.isDarwin Security;
|
||||
|
||||
outputs = [ "out" "man" "doc" ];
|
||||
setOutputFlags = false;
|
||||
|
||||
# Disable codegen units and hardening for the tests.
|
||||
preCheck = ''
|
||||
export RUSTFLAGS=
|
||||
export TZDIR=${tzdata}/share/zoneinfo
|
||||
export hardeningDisable=all
|
||||
'' +
|
||||
# Ensure TMPDIR is set, and disable a test that removing the HOME
|
||||
# variable from the environment falls back to another home
|
||||
# directory.
|
||||
optionalString stdenv.isDarwin ''
|
||||
export TMPDIR=/tmp
|
||||
sed -i '28s/home_dir().is_some()/true/' ./src/test/run-pass/env-home-dir.rs
|
||||
'';
|
||||
|
||||
inherit doCheck;
|
||||
|
||||
configurePlatforms = [];
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764
|
||||
# https://github.com/rust-lang/rust/issues/30181
|
||||
# enableParallelBuilding = false;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
homepage = https://www.rust-lang.org/;
|
||||
description = "A safe, concurrent, practical language";
|
||||
#maintainers = with maintainers; [ sb0 ];
|
||||
license = [ licenses.mit licenses.asl20 ];
|
||||
platforms = platforms.linux ++ platforms.darwin;
|
||||
broken = broken;
|
||||
};
|
||||
}
|
@ -16,7 +16,9 @@ rec {
|
||||
heavycomps = pkgs.callPackage ./heavycomps.nix { inherit nmigen; };
|
||||
|
||||
binutils-riscv = pkgs.callPackage ./compilers/binutils.nix { platform = "riscv32"; };
|
||||
binutils-or1k = pkgs.callPackage ./compilers/binutils.nix { platform = "or1k"; };
|
||||
llvm-hx = pkgs.callPackage ./compilers/llvm-hx.nix {};
|
||||
rustc = pkgs.callPackage ./compilers/rust { llvm = llvm-hx; };
|
||||
llvm = pkgs.llvm_7.overrideAttrs(oa: {
|
||||
cmakeFlags = oa.cmakeFlags ++ ["-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=RISCV"];
|
||||
});
|
||||
rustc = pkgs.rustc.override { inherit llvm; };
|
||||
riscv32imc-crates = pkgs.callPackage ./compilers/riscv32imc-crates.nix { inherit rustc; };
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user