diff options
Diffstat (limited to 'pkgs/development/compilers/rust/rustc.nix')
-rw-r--r-- | pkgs/development/compilers/rust/rustc.nix | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index b1b33d57bb25..85e842176f47 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -1,7 +1,8 @@ { stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps -, llvm, jemalloc, ncurses, darwin, binutils, rustPlatform, git +, llvm, jemalloc, ncurses, darwin, binutils, rustPlatform, git, cmake, curl , isRelease ? false +, needsCmake ? false , shortVersion , forceBundledLLVM ? false , srcSha, srcRev @@ -13,26 +14,28 @@ } @ args: let - version = if isRelease then - "${shortVersion}" - else - "${shortVersion}-g${builtins.substring 0 7 srcRev}"; + inherit (stdenv.lib) optional optionalString; - name = "rustc-${version}"; + version = if isRelease then + "${shortVersion}" + else + "${shortVersion}-g${builtins.substring 0 7 srcRev}"; - procps = if stdenv.isDarwin then darwin.ps else args.procps; + name = "rustc-${version}"; - llvmShared = llvm.override { enableSharedLibraries = true; }; + procps = if stdenv.isDarwin then darwin.ps else args.procps; - target = builtins.replaceStrings [" "] [","] (builtins.toString targets); + llvmShared = llvm.override { enableSharedLibraries = true; }; - meta = with stdenv.lib; { - homepage = http://www.rust-lang.org/; - description = "A safe, concurrent, practical language"; - maintainers = with maintainers; [ madjar cstrahan wizeman globin havvy wkennington retrry ]; - license = [ licenses.mit licenses.asl20 ]; - platforms = platforms.linux ++ platforms.darwin; - }; + target = builtins.replaceStrings [" "] [","] (builtins.toString targets); + + meta = with stdenv.lib; { + homepage = http://www.rust-lang.org/; + description = "A safe, concurrent, practical language"; + maintainers = with maintainers; [ madjar cstrahan wizeman globin havvy wkennington retrry ]; + license = [ licenses.mit licenses.asl20 ]; + platforms = platforms.linux ++ platforms.darwin; + }; in stdenv.mkDerivation { @@ -42,7 +45,7 @@ stdenv.mkDerivation { __impureHostDeps = [ "/usr/lib/libedit.3.dylib" ]; - NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isDarwin "-rpath ${llvmShared}/lib"; + NIX_LDFLAGS = optionalString stdenv.isDarwin "-rpath ${llvmShared}/lib"; src = fetchgit { url = https://github.com/rust-lang/rust; @@ -55,11 +58,12 @@ stdenv.mkDerivation { ++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ] # ++ [ "--jemalloc-root=${jemalloc}/lib" ++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ] - ++ stdenv.lib.optional (stdenv.cc.cc ? isClang) "--enable-clang" - ++ stdenv.lib.optional (targets != []) "--target=${target}" - ++ stdenv.lib.optional (!forceBundledLLVM) "--llvm-root=${llvmShared}"; + ++ optional (stdenv.cc.cc ? isClang) "--enable-clang" + ++ optional (targets != []) "--target=${target}" + ++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}"; patches = patches ++ targetPatches; + passthru.target = target; postPatch = '' @@ -73,7 +77,7 @@ stdenv.mkDerivation { --replace "\$\$(subst /,//," "\$\$(subst /,/," # Fix dynamic linking against llvm - ${stdenv.lib.optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''} + ${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 \ @@ -84,6 +88,9 @@ stdenv.mkDerivation { #[ -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 linker-output-non-utf8 test + rm -vr src/test/run-make/linker-output-non-utf8/ + # Useful debugging parameter #export VERBOSE=1 ''; @@ -94,10 +101,17 @@ stdenv.mkDerivation { configureFlagsArray+=("--infodir=$out/share/info") ''; + # New -beta and -unstable unfortunately need cmake for compiling + # llvm-rt but don't use it for the normal build. This disables cmake + # in Nix. + dontUseCmakeConfigure = needsCmake; + # ps is needed for one of the test cases - nativeBuildInputs = [ file python2 procps rustPlatform.rust.rustc git ]; + nativeBuildInputs = [ file python2 procps rustPlatform.rust.rustc git ] + ++ stdenv.lib.optional needsCmake [ cmake curl ]; + buildInputs = [ ncurses ] ++ targetToolchains - ++ stdenv.lib.optional (!forceBundledLLVM) llvmShared; + ++ optional (!forceBundledLLVM) llvmShared; # https://github.com/rust-lang/rust/issues/30181 # enableParallelBuilding = false; # missing files during linking, occasionally @@ -105,8 +119,12 @@ stdenv.mkDerivation { outputs = [ "out" "doc" ]; setOutputFlags = false; - preCheck = "export TZDIR=${tzdata}/share/zoneinfo"; + preCheck = '' + export TZDIR=${tzdata}/share/zoneinfo + ${optionalString stdenv.isDarwin "export TMPDIR=/tmp"} + ''; + # Disable doCheck on Darwin to work around upstream issue doCheck = true; dontSetConfigureCross = true; } |