···11-#!/bin/sh
11+#!/usr/bin/env bash
22+33+# All rust-related downloads can be found at
44+# https://static.rust-lang.org/dist/index.html. To find the date on
55+# which a particular thing was last updated, look for the *-date.txt
66+# file, e.g.
77+# https://static.rust-lang.org/dist/channel-rust-beta-date.txt
2839PLATFORMS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu i686-apple-darwin x86_64-apple-darwin"
410BASEURL="https://static.rust-lang.org/dist"
55-VERSION=$1
1111+DATE=$1
1212+VERSION=$2
1313+1414+if [[ -z $DATE ]]
1515+then
1616+ echo "No date supplied"
1717+ exit -1
1818+fi
619720if [[ -z $VERSION ]]
821then
···12251326for PLATFORM in $PLATFORMS
1427do
1515- URL="$BASEURL/rust-$VERSION-$PLATFORM.tar.gz.sha256"
2828+ URL="$BASEURL/$DATE/rust-$VERSION-$PLATFORM.tar.gz.sha256"
1629 curl $URL
1730done
+37-37
pkgs/development/compilers/rust/rustc.nix
···11{ stdenv, fetchurl, fetchgit, fetchzip, file, python2, tzdata, procps
22, llvm, jemalloc, ncurses, darwin, binutils, rustPlatform, git, cmake, curl
33-44-, isRelease ? false
55-, shortVersion
33+, which, libffi, gdb
44+, version
65, forceBundledLLVM ? false
77-, srcSha, srcRev
66+, src
87, configureFlags ? []
98, patches
109, targets
1110, targetPatches
1211, targetToolchains
1212+, doCheck ? true
1313} @ args:
14141515let
1616 inherit (stdenv.lib) optional optionalString;
17171818- version = if isRelease then
1919- "${shortVersion}"
2020- else
2121- "${shortVersion}-g${builtins.substring 0 7 srcRev}";
2222-2318 procps = if stdenv.isDarwin then darwin.ps else args.procps;
24192520 llvmShared = llvm.override { enableSharedLibraries = true; };
···3126stdenv.mkDerivation {
3227 name = "rustc-${version}";
3328 inherit version;
2929+3030+ inherit src;
34313532 __impureHostDeps = [ "/usr/lib/libedit.3.dylib" ];
3633···4542 # Increase codegen units to introduce parallelism within the compiler.
4643 RUSTFLAGS = "-Ccodegen-units=10";
47444848- src = fetchgit {
4949- url = https://github.com/rust-lang/rust;
5050- rev = srcRev;
5151- sha256 = srcSha;
5252- };
5353-5445 # We need rust to build rust. If we don't provide it, configure will try to download it.
5546 configureFlags = configureFlags
5647 ++ [ "--enable-local-rust" "--local-rust-root=${rustPlatform.rust.rustc}" "--enable-rpath" ]
4848+ ++ [ "--enable-vendor" "--disable-locked-deps" ]
4949+ ++ [ "--enable-llvm-link-shared" ]
5750 # ++ [ "--jemalloc-root=${jemalloc}/lib"
5851 ++ [ "--default-linker=${stdenv.cc}/bin/cc" "--default-ar=${binutils.out}/bin/ar" ]
5959- # TODO: Remove when fixed build with rustbuild
6060- ++ [ "--disable-rustbuild" ]
6152 ++ optional (stdenv.cc.cc ? isClang) "--enable-clang"
6253 ++ optional (targets != []) "--target=${target}"
6354 ++ optional (!forceBundledLLVM) "--llvm-root=${llvmShared}";
···6758 passthru.target = target;
68596960 postPatch = ''
7070- substituteInPlace src/rust-installer/gen-install-script.sh \
7171- --replace /bin/echo "$(type -P echo)"
7272- substituteInPlace src/rust-installer/gen-installer.sh \
7373- --replace /bin/echo "$(type -P echo)"
7474-7575- # Workaround for NixOS/nixpkgs#8676
7676- substituteInPlace mk/rustllvm.mk \
7777- --replace "\$\$(subst /,//," "\$\$(subst /,/,"
7878-7961 # Fix dynamic linking against llvm
8080- ${optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
6262+ #${optionalString (!forceBundledLLVM) ''sed -i 's/, kind = \\"static\\"//g' src/etc/mklldeps.py''}
81638264 # Fix the configure script to not require curl as we won't use it
8365 sed -i configure \
···9880 # https://reviews.llvm.org/rL281650
9981 rm -vr src/test/run-pass/issue-36474.rs || true
100828383+ # Disable some failing gdb tests. Try re-enabling these when gdb
8484+ # is updated past version 7.12.
8585+ rm src/test/debuginfo/basic-types-globals.rs
8686+ rm src/test/debuginfo/basic-types-mut-globals.rs
8787+ rm src/test/debuginfo/c-style-enum.rs
8888+ rm src/test/debuginfo/lexical-scopes-in-block-expression.rs
8989+ rm src/test/debuginfo/limited-debuginfo.rs
9090+ rm src/test/debuginfo/simple-struct.rs
9191+ rm src/test/debuginfo/simple-tuple.rs
9292+ rm src/test/debuginfo/union-smoke.rs
9393+ rm src/test/debuginfo/vec-slices.rs
9494+ rm src/test/debuginfo/vec.rs
9595+9696+ # this can probably be removed when rust is updated beyond 1.17
9797+ # fixes a warning in the test harness (I think?) which fails the build due
9898+ # to strict warnings
9999+ sed -i '/static_in_const/d' src/tools/compiletest/src/main.rs
100100+101101 # Useful debugging parameter
102102 # export VERBOSE=1
103103- '' +
104104- # In src/compiler-rt/cmake/config-ix.cmake, the cmake build falls
105105- # back to darwin 10.4. This causes the OS name to be recorded as
106106- # "10.4" rather than the expected "osx". But mk/rt.mk expects the
107107- # built library name to have an "_osx" suffix on darwin.
108108- optionalString stdenv.isDarwin ''
109109- substituteInPlace mk/rt.mk --replace "_osx" "_10.4"
103103+ ''
104104+ + optionalString stdenv.isDarwin ''
105105+ # Disable all lldb tests.
106106+ # error: Can't run LLDB test because LLDB's python path is not set
107107+ rm -vr src/test/debuginfo/*
110108 '';
111109112110 preConfigure = ''
···120118 dontUseCmakeConfigure = true;
121119122120 # ps is needed for one of the test cases
123123- nativeBuildInputs = [ file python2 procps rustPlatform.rust.rustc git cmake ];
121121+ nativeBuildInputs = [ file python2 procps rustPlatform.rust.rustc git cmake
122122+ which libffi gdb ];
124123125124 buildInputs = [ ncurses ] ++ targetToolchains
126125 ++ optional (!forceBundledLLVM) llvmShared;
···141140 sed -i '28s/home_dir().is_some()/true/' ./src/test/run-pass/env-home-dir.rs
142141 '';
143142144144- doCheck = true;
143143+ inherit doCheck;
144144+145145 dontSetConfigureCross = true;
146146147147 # https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764
···151151 meta = with stdenv.lib; {
152152 homepage = http://www.rust-lang.org/;
153153 description = "A safe, concurrent, practical language";
154154- maintainers = with maintainers; [ madjar cstrahan wizeman globin havvy wkennington retrry ];
154154+ maintainers = with maintainers; [ madjar cstrahan wizeman globin havvy wkennington ];
155155 license = [ licenses.mit licenses.asl20 ];
156156 platforms = platforms.linux ++ platforms.darwin;
157157 };