1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 David Craven <david@craven.ch>
3 ;;; Copyright © 2016 Eric Le Bihan <eric.le.bihan.dev@free.fr>
4 ;;; Copyright © 2016 Nikita <nikita@n0.is>
5 ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com>
6 ;;; Copyright © 2017, 2018 Nikolai Merinov <nikolai.merinov@member.fsf.org>
7 ;;; Copyright © 2017, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Danny Milosavljevic <dannym+a@scratchpost.org>
10 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
11 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
12 ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages rust)
30 #:use-module (gnu packages base)
31 #:use-module (gnu packages bison)
32 #:use-module (gnu packages bootstrap)
33 #:use-module (gnu packages cmake)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages curl)
36 #:use-module (gnu packages elf)
37 #:use-module (gnu packages flex)
38 #:use-module (gnu packages gcc)
39 #:use-module (gnu packages gdb)
40 #:use-module (gnu packages jemalloc)
41 #:use-module (gnu packages linux)
42 #:use-module (gnu packages llvm)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages ssh)
46 #:use-module (gnu packages tls)
47 #:use-module (gnu packages)
48 #:use-module (guix build-system cargo)
49 #:use-module (guix build-system gnu)
50 #:use-module (guix build-system trivial)
51 #:use-module (guix download)
52 #:use-module (guix git-download)
53 #:use-module ((guix licenses) #:prefix license:)
54 #:use-module (guix packages)
55 #:use-module ((guix build utils) #:select (alist-replace))
56 #:use-module (guix utils)
57 #:use-module (ice-9 match)
58 #:use-module (srfi srfi-26))
60 ;; This is the hash for the empty file, and the reason it's relevant is not
63 ;; The root of the problem is that Cargo keeps track of a file called
64 ;; Cargo.lock, that contains the hash of the tarball source of each dependency.
66 ;; However, tarball sources aren't handled well by Guix because of the need to
67 ;; patch shebangs in any helper scripts. This is why we use Cargo's vendoring
68 ;; capabilities, where instead of the tarball, a directory is provided in its
69 ;; place. (In the case of rustc, the source code already ships with vendored
70 ;; dependencies, but crates built with cargo-build-system undergo vendoring
73 ;; To preserve the advantages of checksumming, vendored dependencies contain
74 ;; a file called .cargo-checksum.json, which contains the hash of the tarball,
75 ;; as well as the list of files in it, with the hash of each file.
77 ;; The patch-cargo-checksums phase of cargo-build-system runs after
78 ;; any Guix-specific patches to the vendored dependencies and regenerates the
79 ;; .cargo-checksum.json files, but it's hard to know the tarball checksum that
80 ;; should be written to the file - and taking care of any unhandled edge case
81 ;; would require rebuilding everything that depends on rust. This is why we lie,
82 ;; and say that the tarball has the hash of an empty file. It's not a problem
83 ;; because cargo-build-system removes the Cargo.lock file. We can't do that
84 ;; for rustc because of a quirk of its build system, so we modify the lock file
85 ;; to substitute the hash.
86 (define %cargo-reference-hash
87 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
89 (define* (nix-system->gnu-triplet-for-rust
90 #:optional (system (%current-system)))
92 ("x86_64-linux" "x86_64-unknown-linux-gnu")
93 ("i686-linux" "i686-unknown-linux-gnu")
94 ("armhf-linux" "armv7-unknown-linux-gnueabihf")
95 ("aarch64-linux" "aarch64-unknown-linux-gnu")
96 ("mips64el-linux" "mips64el-unknown-linux-gnuabi64")
97 (_ (nix-system->gnu-triplet system))))
99 (define* (rust-uri version #:key (dist "static"))
100 (string-append "https://" dist ".rust-lang.org/dist/"
101 "rustc-" version "-src.tar.gz"))
103 (define* (rust-bootstrapped-package base-rust version checksum)
104 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
110 (inherit (package-source base-rust))
111 (uri (rust-uri version))
112 (sha256 (base32 checksum))))
114 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
115 (alist-replace "rustc-bootstrap" (list base-rust)
116 (package-native-inputs base-rust))))))
118 (define-public mrustc
119 (let ((rustc-version "1.19.0"))
126 (url "https://github.com/thepowersgang/mrustc")
127 (commit (string-append "v" version))))
128 (file-name (git-file-name name version))
131 "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2"))))
132 (outputs '("out" "cargo"))
133 (build-system gnu-build-system)
139 ;; Required for the libstd sources.
140 ("rustc" ,(package-source rust-1.19))))
142 `(#:test-target "test"
144 (list ,(string-append "RUSTC_TARGET="
145 (or (%current-target-system)
146 (nix-system->gnu-triplet-for-rust))))
148 (modify-phases %standard-phases
149 (add-after 'unpack 'patch-date
151 (substitute* "Makefile"
152 (("shell date") "shell date -d @1"))
153 (substitute* "run_rustc/Makefile"
154 (("[$]Vtime ") "$V "))
156 (add-after 'patch-date 'unpack-target-compiler
157 (lambda* (#:key inputs outputs #:allow-other-keys)
158 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
159 (chdir ,(string-append "rustc-" rustc-version "-src"))
160 (invoke "patch" "-p0" ,(string-append "../rustc-" rustc-version
163 (setenv "RUSTC_VERSION" ,rustc-version)
164 (setenv "MRUSTC_TARGET_VER"
165 ,(version-major+minor rustc-version))
166 (setenv "OUTDIR_SUF" "")
169 (lambda* (#:key inputs #:allow-other-keys)
170 (setenv "CC" (string-append (assoc-ref inputs "gcc")
172 (setenv "CXX" (string-append (assoc-ref inputs "gcc")
175 (add-after 'build 'build-minicargo
176 (lambda* (#:key make-flags #:allow-other-keys)
177 ;; TODO: minicargo.mk: RUSTC_VERSION=$(RUSTC_VERSION) RUSTC_CHANNEL=$(RUSTC_SRC_TY) OUTDIR_SUF=$(OUTDIR_SUF)
178 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags)
179 (apply invoke "make" "-C" "tools/minicargo" make-flags)))
180 ;(add-after 'check 'check-locally
181 ; (lambda* (#:key make-flags #:allow-other-keys)
182 ; ;; The enum test wouldn't work otherwise.
183 ; ;; See <https://github.com/thepowersgang/mrustc/issues/137>.
184 ; (setenv "MRUSTC_TARGET_VER" ,(version-major+minor rustc-version))
185 ; (apply invoke "make" "local_tests" make-flags)))
187 (lambda* (#:key inputs outputs #:allow-other-keys)
188 (let* ((out (assoc-ref outputs "out"))
189 (bin (string-append out "/bin"))
190 (tools-bin (string-append out "/tools/bin"))
191 (cargo-out (assoc-ref outputs "cargo"))
192 (cargo-bin (string-append cargo-out "/bin"))
193 (lib (string-append out "/lib"))
194 (lib/rust (string-append lib "/mrust"))
195 (gcc (assoc-ref inputs "gcc"))
196 (run_rustc (string-append out
197 "/share/mrustc/run_rustc")))
198 ;; These files are not reproducible.
199 (for-each delete-file (find-files "output" "\\.txt$"))
200 ;(delete-file-recursively "output/local_tests")
201 (mkdir-p (dirname lib/rust))
202 (copy-recursively "output" lib/rust)
205 (install-file "bin/mrustc" bin)
206 ;; minicargo uses relative paths to resolve mrustc.
207 (install-file "tools/bin/minicargo" tools-bin)
208 (install-file "tools/bin/minicargo" cargo-bin)
210 (copy-file "run_rustc/Makefile"
211 (string-append run_rustc "/Makefile"))
213 (synopsis "Compiler for the Rust programming language")
214 (description "Rust is a systems programming language that provides memory
215 safety and thread safety guarantees.")
216 (home-page "https://github.com/thepowersgang/mrustc")
218 (license (list license:asl2.0 license:expat)))))
227 (uri (rust-uri "1.19.0"))
228 (sha256 (base32 "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))
229 (modules '((guix build utils)))
230 (snippet '(begin (delete-file-recursively "src/llvm") #t))
231 (patches (search-patches "rust-1.19-mrustc.patch"))))
232 (outputs '("out" "cargo"))
233 (properties '((timeout . 72000) ;20 hours
234 (max-silent-time . 18000))) ;5 hours (for armel)
236 `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
237 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
239 (modify-phases %standard-phases
240 (add-after 'unpack 'set-env
241 (lambda* (#:key inputs #:allow-other-keys)
242 ;; Disable test for cross compilation support.
243 (setenv "CFG_DISABLE_CROSS_TESTS" "1")
244 (setenv "SHELL" (which "sh"))
245 (setenv "CONFIG_SHELL" (which "sh"))
246 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
247 ;; guix llvm-3.9.1 package installs only shared libraries
248 (setenv "LLVM_LINK_SHARED" "1")
250 (add-after 'unpack 'patch-cargo-tomls
251 (lambda* (#:key inputs outputs #:allow-other-keys)
252 (substitute* "src/librustc_errors/Cargo.toml"
253 (("[[]dependencies[]]") "
257 (substitute* "src/librustc/Cargo.toml"
258 (("[[]dependencies[]]") "
260 getopts = { path = \"../libgetopts\" }
262 (substitute* "src/librustdoc/Cargo.toml"
263 (("[[]dependencies[]]") "
265 test = { path = \"../libtest\" }
268 (add-after 'unpack 'patch-tests
269 (lambda* (#:key inputs #:allow-other-keys)
270 (let ((bash (assoc-ref inputs "bash")))
271 (substitute* "src/libstd/process.rs"
272 ;; The newline is intentional.
273 ;; There's a line length "tidy" check in Rust which would
275 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
276 (substitute* "src/libstd/net/tcp.rs"
277 ;; There is no network in build environment
278 (("fn connect_timeout_unroutable")
279 "#[ignore]\nfn connect_timeout_unroutable"))
280 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
281 (substitute* "src/libstd/sys/unix/process/process_common.rs"
282 (("fn test_process_mask") "#[allow(unused_attributes)]
284 fn test_process_mask"))
286 (add-after 'patch-tests 'patch-aarch64-test
288 (substitute* "src/librustc_back/dynamic_lib.rs"
289 ;; This test is known to fail on aarch64 and powerpc64le:
290 ;; https://github.com/rust-lang/rust/issues/45410
291 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
293 (add-after 'patch-tests 'use-readelf-for-tests
295 ;; nm doesn't recognize the file format because of the
296 ;; nonstandard sections used by the Rust compiler, but readelf
298 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
302 (add-after 'patch-tests 'remove-unsupported-tests
304 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
305 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
306 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
308 (add-after 'patch-source-shebangs 'patch-cargo-checksums
310 (use-modules (guix build cargo-utils))
311 (substitute* "src/Cargo.lock"
312 (("(\"checksum .* = )\".*\"" all name)
313 (string-append name "\"" ,%cargo-reference-hash "\"")))
314 (generate-all-checksums "src/vendor")
316 ;; This phase is overridden by newer versions.
319 ;; This phase is overridden by newer versions.
321 (lambda* (#:key inputs outputs #:allow-other-keys)
322 (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap")))
323 (setenv "CFG_COMPILER_HOST_TRIPLE"
324 ,(nix-system->gnu-triplet (%current-system)))
325 (setenv "CFG_RELEASE" "")
326 (setenv "CFG_RELEASE_CHANNEL" "stable")
327 (setenv "CFG_LIBDIR_RELATIVE" "lib")
328 (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
329 (setenv "MRUSTC_TARGET_VER" ,(version-major+minor version))
330 ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path.
332 ;; mrustc 0.9 doesn't check the search paths for crates anymore.
333 (copy-recursively (string-append rustc-bootstrap "/lib/mrust")
335 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
336 "src/rustc" "--vendor-dir" "src/vendor"
337 "--output-dir" "output/rustc-build"
338 "-L" (string-append rustc-bootstrap "/lib/mrust")
340 (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
341 (setenv "CFG_RELEASE" #f)
342 (setenv "CFG_RELEASE_CHANNEL" #f)
343 (setenv "CFG_VERSION" #f)
344 (setenv "CFG_PREFIX" #f)
345 (setenv "CFG_LIBDIR_RELATIVE" #f)
346 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
347 "src/tools/cargo" "--vendor-dir" "src/vendor"
348 "--output-dir" "output/cargo-build"
350 "-L" (string-append rustc-bootstrap "/lib/mrust")
352 ;; Now use the newly-built rustc to build the libraries.
353 ;; One day that could be replaced by:
354 ;; (invoke "output/cargo-build/cargo" "build"
355 ;; "--manifest-path" "src/bootstrap/Cargo.toml"
356 ;; "--verbose") ; "--locked" "--frozen"
357 ;; but right now, Cargo has problems with libstd's circular
359 (mkdir-p "output/target-libs")
360 (for-each (match-lambda
365 "output/rustc-build/rustc"
366 "-C" (string-append "linker="
368 ;; Required for libterm.
369 "-Z" "force-unstable-if-unmarked"
370 "-L" "output/target-libs"
371 (string-append "src/" name "/lib.rs")
373 (string-append "output/target-libs/"
374 (car (string-split name #\/))
382 ("liblibc/src" "--cfg" "stdbuild")
383 ("libunwind" "-l" "gcc_s")
384 ("libcompiler_builtins")
387 ;; Uses "cc" to link.
388 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
391 ;; Test dependencies:
397 ;; This phase is overridden by newer versions.
400 ;; This phase is overridden by newer versions.
402 (lambda* (#:key inputs outputs #:allow-other-keys)
403 (let* ((out (assoc-ref outputs "out"))
404 (target-system ,(or (%current-target-system)
405 (nix-system->gnu-triplet
407 (out-libs (string-append out "/lib/rustlib/"
408 target-system "/lib")))
409 ;(setenv "CFG_PREFIX" out)
411 (copy-recursively "output/target-libs" out-libs)
412 (install-file "output/rustc-build/rustc"
413 (string-append out "/bin"))
414 (install-file "output/rustc-build/rustdoc"
415 (string-append out "/bin"))
416 (install-file "output/cargo-build/cargo"
417 (string-append (assoc-ref outputs "cargo")
420 (build-system gnu-build-system)
422 `(("bison" ,bison) ; For the tests
423 ("cmake" ,cmake-minimal)
424 ("flex" ,flex) ; For the tests
425 ;; FIXME: Rust 1.27 and some later versions require GDB 8.2 specifically.
426 ;; See <https://bugs.gnu.org/37810>. Use it on all Rusts for simplicity.
427 ("gdb" ,gdb-8.2) ; For the tests
428 ("procps" ,procps) ; For the tests
429 ("python-2" ,python-2)
430 ("rustc-bootstrap" ,mrustc)
431 ("cargo-bootstrap" ,mrustc "cargo")
432 ("pkg-config" ,pkg-config) ; For "cargo"
435 `(("jemalloc" ,jemalloc-4.5.0)
437 ("openssl" ,openssl-1.0)
438 ("libssh2" ,libssh2) ; For "cargo"
439 ("libcurl" ,curl))) ; For "cargo"
441 ;; rustc invokes gcc, so we need to set its search paths accordingly.
442 ;; Note: duplicate its value here to cope with circular dependencies among
443 ;; modules (see <https://bugs.gnu.org/31392>).
445 (list (search-path-specification
446 (variable "C_INCLUDE_PATH")
447 (files '("include")))
448 (search-path-specification
449 (variable "CPLUS_INCLUDE_PATH")
450 (files '("include/c++" "include")))
451 (search-path-specification
452 (variable "LIBRARY_PATH")
453 (files '("lib" "lib64")))))
455 (synopsis "Compiler for the Rust programming language")
456 (description "Rust is a systems programming language that provides memory
457 safety and thread safety guarantees.")
458 (home-page "https://www.rust-lang.org")
460 (license (list license:asl2.0 license:expat))))
462 (define-public rust-1.20
464 (rust-bootstrapped-package rust-1.19 "1.20.0"
465 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
470 (inherit (package-source base-rust))
472 (delete-file-recursively "src/jemalloc")
473 (delete-file-recursively "src/llvm")
477 `(;; The tests fail with newer versions of GNU Make.
478 ("make" ,gnu-make-4.2)
479 ,@(package-native-inputs base-rust)))
480 (outputs '("out" "doc" "cargo"))
481 ;; Since rust-1.19 is local, it's quite probable that Hydra
482 ;; will build rust-1.19 only as a dependency of rust-1.20.
483 ;; But then Hydra will use the wrong properties, the ones here,
484 ;; for rust-1.19. Therefore, we copied the properties of
486 (properties '((timeout . 72000) ;20 hours
487 (max-silent-time . 18000))) ;5 hours (for armel)
489 (substitute-keyword-arguments (package-arguments rust-1.19)
491 `(modify-phases ,phases
492 (add-after 'patch-tests 'patch-cargo-tests
494 (substitute* "src/tools/cargo/tests/build.rs"
495 (("/usr/bin/env") (which "env"))
496 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
497 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
498 (substitute* "src/tools/cargo/tests/death.rs"
499 ;; This is stuck when built in container.
500 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
501 ;; Prints test output in the wrong order when built on
503 (substitute* "src/tools/cargo/tests/test.rs"
504 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
506 ;; These tests pull in a dependency on "git", which changes
507 ;; too frequently take part in the Rust toolchain.
508 (substitute* "src/tools/cargo/tests/new.rs"
509 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
510 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
511 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
513 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
514 ;; https://github.com/rust-lang/rust/issues/47863
516 (substitute* "src/test/run-pass/out-of-stack.rs"
517 (("// ignore-android") "// ignore-test\n// ignore-android"))
520 (lambda* (#:key inputs outputs #:allow-other-keys)
521 (let* ((out (assoc-ref outputs "out"))
522 (doc (assoc-ref outputs "doc"))
523 (gcc (assoc-ref inputs "gcc"))
524 (gdb (assoc-ref inputs "gdb"))
525 (binutils (assoc-ref inputs "binutils"))
526 (python (assoc-ref inputs "python-2"))
527 (rustc (assoc-ref inputs "rustc-bootstrap"))
528 (cargo (assoc-ref inputs "cargo-bootstrap"))
529 (llvm (assoc-ref inputs "llvm"))
530 (jemalloc (assoc-ref inputs "jemalloc")))
531 (call-with-output-file "config.toml"
533 (display (string-append "
536 cargo = \"" cargo "/bin/cargo" "\"
537 rustc = \"" rustc "/bin/rustc" "\"
539 python = \"" python "/bin/python2" "\"
540 gdb = \"" gdb "/bin/gdb" "\"
545 docdir = \"" doc "/share/doc/rust" "\"
548 default-linker = \"" gcc "/bin/gcc" "\"
551 " ;; There are 2 failed codegen tests:
552 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
553 ;; These tests require a patched LLVM
554 "codegen-tests = false
555 [target." ,(nix-system->gnu-triplet-for-rust) "]
556 llvm-config = \"" llvm "/bin/llvm-config" "\"
557 cc = \"" gcc "/bin/gcc" "\"
558 cxx = \"" gcc "/bin/g++" "\"
559 ar = \"" binutils "/bin/ar" "\"
560 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
564 (add-after 'configure 'provide-cc
565 (lambda* (#:key inputs #:allow-other-keys)
566 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
568 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
570 (add-after 'provide-cc 'configure-archiver
571 (lambda* (#:key inputs #:allow-other-keys)
572 (substitute* "src/build_helper/lib.rs"
573 ;; Make sure "ar" is always used as the archiver.
574 (("\"musl\"") "\"\"")
575 ;; Then substitute "ar" by our name.
576 (("\"ar\"") (string-append "\""
577 (assoc-ref inputs "binutils")
580 (delete 'patch-cargo-tomls)
581 (add-before 'build 'reset-timestamps-after-changes
585 ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist".
586 ;; Therefore, use timestamp 1.
587 (utime filename 1 1 1 1))
588 (find-files "." #:directories? #t))
592 (invoke "./x.py" "build")
593 (invoke "./x.py" "build" "src/tools/cargo")))
596 ;; Disable parallel execution to prevent EAGAIN errors when
598 (invoke "./x.py" "-j1" "test" "-vv")
599 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
602 (lambda* (#:key outputs #:allow-other-keys)
603 (invoke "./x.py" "install")
604 (substitute* "config.toml"
605 ;; replace prefix to specific output
606 (("prefix = \"[^\"]*\"")
607 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
608 (invoke "./x.py" "install" "cargo")))
609 (add-after 'install 'delete-install-logs
610 (lambda* (#:key outputs #:allow-other-keys)
611 (define (delete-manifest-file out-path file)
612 (delete-file (string-append out-path "/lib/rustlib/" file)))
614 (let ((out (assoc-ref outputs "out"))
615 (cargo-out (assoc-ref outputs "cargo")))
617 (lambda (file) (delete-manifest-file out file))
620 ,(string-append "manifest-rust-std-"
621 (nix-system->gnu-triplet-for-rust))
624 (lambda (file) (delete-manifest-file cargo-out file))
628 (add-after 'install 'wrap-rustc
629 (lambda* (#:key inputs outputs #:allow-other-keys)
630 (let ((out (assoc-ref outputs "out"))
631 (libc (assoc-ref inputs "libc"))
632 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
633 ;; Let gcc find ld and libc startup files.
634 (wrap-program (string-append out "/bin/rustc")
635 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
636 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
639 (define-public rust-1.21
640 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
641 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
645 (substitute-keyword-arguments (package-arguments base-rust)
647 `(modify-phases ,phases
648 (add-after 'configure 'remove-ar
649 (lambda* (#:key inputs #:allow-other-keys)
650 ;; Remove because toml complains about "unknown field".
651 (substitute* "config.toml"
655 (define-public rust-1.22
656 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
657 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
661 (substitute-keyword-arguments (package-arguments base-rust)
663 `(modify-phases ,phases
664 (add-after 'unpack 'remove-flaky-test
666 ;; See <https://github.com/rust-lang/rust/issues/43402>.
667 (when (file-exists? "src/test/run-make/issue-26092")
668 (delete-file-recursively "src/test/run-make/issue-26092"))
671 (define-public rust-1.23
672 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
673 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
677 (substitute-keyword-arguments (package-arguments base-rust)
679 `(modify-phases ,phases
680 (delete 'configure-archiver)
682 (add-after 'unpack 'dont-build-native
684 ;; XXX: Revisit this when we use gcc 6.
685 (substitute* "src/binaryen/CMakeLists.txt"
686 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
689 (define-public rust-1.24
691 (rust-bootstrapped-package rust-1.23 "1.24.1"
692 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
696 (substitute-keyword-arguments (package-arguments base-rust)
698 `(modify-phases ,phases
699 (delete 'use-readelf-for-tests)
700 (replace 'patch-aarch64-test
702 (substitute* "src/librustc_metadata/dynamic_lib.rs"
703 ;; This test is known to fail on aarch64 and powerpc64le:
704 ;; https://github.com/rust-lang/rust/issues/45410
705 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
708 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
709 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
710 ;;; Keep using llvm 3.9.1 until builds become determenistic
711 (define-public rust-1.25
713 (rust-bootstrapped-package rust-1.24 "1.25.0"
714 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")))
719 (inherit (package-source base-rust))
721 (delete-file-recursively "src/jemalloc")
722 (delete-file-recursively "src/llvm")
723 (delete-file-recursively "src/llvm-emscripten")
725 (patches (search-patches
726 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
728 (substitute-keyword-arguments (package-arguments base-rust)
730 `(modify-phases ,phases
731 (add-after 'patch-cargo-tests 'patch-cargo-index-update
733 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
734 ;; This test wants to update the crate index.
735 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
737 (replace 'patch-aarch64-test
739 (substitute* "src/librustc_metadata/dynamic_lib.rs"
740 ;; This test is known to fail on aarch64 and powerpc64le:
741 ;; https://github.com/rust-lang/rust/issues/45410
742 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
743 ;; This test fails on aarch64 with llvm@6.0:
744 ;; https://github.com/rust-lang/rust/issues/49807
745 ;; other possible solution:
746 ;; https://github.com/rust-lang/rust/pull/47688
747 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
749 (delete 'ignore-glibc-2.27-incompatible-test))))))))
751 (define-public rust-1.26
753 (rust-bootstrapped-package rust-1.25 "1.26.2"
754 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv")))
759 (inherit (package-source base-rust))
760 (patches (search-patches
761 "rust-coresimd-doctest.patch"
762 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
764 (alist-replace "openssl" (list openssl)
765 (package-inputs base-rust)))
767 (substitute-keyword-arguments (package-arguments base-rust)
769 `(modify-phases ,phases
770 ;; binaryen was replaced with LLD project from LLVM
771 (delete 'dont-build-native)
774 ;; Enable parallel execution.
775 (let ((parallel-job-spec
776 (string-append "-j" (number->string
778 (parallel-job-count))))))
779 (invoke "./x.py" parallel-job-spec "test" "-vv")
780 (invoke "./x.py" parallel-job-spec "test"
781 "src/tools/cargo"))))
782 (replace 'remove-unsupported-tests
784 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
785 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
786 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
788 (replace 'patch-cargo-tests
790 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
791 (("/usr/bin/env") (which "env"))
792 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
793 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
794 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
795 ;; This is stuck when built in container.
796 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
797 ;; Prints test output in the wrong order when built on
799 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
800 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
802 ;; Avoid dependency on "git".
803 (substitute* "src/tools/cargo/tests/testsuite/new.rs"
804 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
805 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
806 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
808 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
810 ;; This test failed to work on "nightly" channel builds
811 ;; https://github.com/rust-lang/cargo/issues/5648
812 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
813 (("fn test_resolving_minimum_version_with_transitive_deps")
814 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
816 (replace 'patch-cargo-index-update
818 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
819 ;; This test wants to update the crate index.
820 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
823 (define-public rust-1.27
825 (rust-bootstrapped-package rust-1.26 "1.27.2"
826 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs")))
831 (inherit (package-source base-rust))
832 (patches (search-patches "rust-coresimd-doctest.patch"
833 "rust-bootstrap-stage0-test.patch"
834 "rust-1.25-accept-more-detailed-gdb-lines.patch"
835 "rust-reproducible-builds.patch"))))
837 (substitute-keyword-arguments (package-arguments base-rust)
839 `(modify-phases ,phases
840 (add-before 'install 'mkdir-prefix-paths
841 (lambda* (#:key outputs #:allow-other-keys)
842 ;; As result of https://github.com/rust-lang/rust/issues/36989
843 ;; `prefix' directory should exist before `install' call
844 (mkdir-p (assoc-ref outputs "out"))
845 (mkdir-p (assoc-ref outputs "cargo"))
847 (add-after 'patch-cargo-tests 'disable-thinlto-test
849 ;; thinlto required llvm 6.0 for work
850 (substitute* "src/tools/cargo/tests/testsuite/path.rs"
851 (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works"))
854 (define-public rust-1.28
856 (rust-bootstrapped-package rust-1.27 "1.28.0"
857 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx")))
862 (inherit (package-source base-rust))
863 (patches (search-patches "rust-coresimd-doctest.patch"
864 "rust-bootstrap-stage0-test.patch"
865 "rust-1.25-accept-more-detailed-gdb-lines.patch"
866 "rust-reproducible-builds.patch"))))
869 (alist-replace "llvm" (list llvm-6)
870 (package-inputs base-rust)))
872 (substitute-keyword-arguments (package-arguments base-rust)
874 `(modify-phases ,phases
875 (add-after 'configure 'enable-codegen-tests
876 ;; Codegen tests should pass with llvm 6, so enable them.
878 (substitute* "config.toml"
879 (("codegen-tests = false") ""))
881 (add-after 'patch-tests 'disable-amd64-avx-test
882 ;; That test would fail on x86_64 machines without avx.
884 (substitute* "src/test/run-pass/issue-44056.rs"
885 (("only-x86_64") "ignore-test"))
887 ;; This is no longer needed as of 1.28
888 (delete 'disable-cargo-test-for-nightly-channel)
889 ;; The thinlto test should pass with llvm 6.
890 (delete 'disable-thinlto-test))))))))
892 (define-public rust-1.29
894 (rust-bootstrapped-package rust-1.28 "1.29.2"
895 "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h")))
900 (inherit (package-source base-rust))
901 (patches (search-patches "rust-1.25-accept-more-detailed-gdb-lines.patch"
902 "rust-reproducible-builds.patch")))))))
904 (define-public rust-1.30
906 (rust-bootstrapped-package rust-1.29 "1.30.1"
907 "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn")))
912 (inherit (package-source base-rust))
914 (delete-file-recursively "src/jemalloc")
915 (delete-file-recursively "src/llvm")
916 (delete-file-recursively "src/llvm-emscripten")
917 (delete-file-recursively "src/tools/clang")
918 (delete-file-recursively "src/tools/lldb")
921 (substitute-keyword-arguments (package-arguments base-rust)
923 `(modify-phases ,phases
924 (add-after 'patch-cargo-tests 'patch-cargo-env-shebang
925 (lambda* (#:key inputs #:allow-other-keys)
926 (let ((coreutils (assoc-ref inputs "coreutils")))
927 (substitute* "src/tools/cargo/tests/testsuite/fix.rs"
928 ;; Cargo has a test which explicitly sets a
929 ;; RUSTC_WRAPPER environment variable which points
930 ;; to /usr/bin/env. Since it's not a shebang, it
931 ;; needs to be manually patched
932 (("\"/usr/bin/env\"")
933 (string-append "\"" coreutils "/bin/env\"")))
935 (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
937 (substitute* "src/tools/cargo/tests/testsuite/package.rs"
938 ;; These tests largely check that cargo outputs warning/error
939 ;; messages as expected. It seems that cargo outputs an
940 ;; absolute path to something in the store instead of the
941 ;; expected relative path (e.g. `[..]`) so we'll ignore
943 (("fn include") "#[ignore]\nfn include")
944 (("fn exclude") "#[ignore]\nfn exclude"))
946 ;; The test has been moved elsewhere.
947 (replace 'disable-amd64-avx-test
949 (substitute* "src/test/ui/run-pass/issues/issue-44056.rs"
950 (("only-x86_64") "ignore-test"))
953 (define (patch-command-exec-tests-phase test-path)
954 "The command-exec.rs test moves around between releases. We need to apply
955 a Guix-specific patch to it for each release. This function generates the phase
956 that applies said patch, parametrized by the test-path. This is done this way
957 because the phase is more complex than the equivalents for other tests that
959 `(lambda* (#:key inputs #:allow-other-keys)
960 (let ((coreutils (assoc-ref inputs "coreutils")))
961 (substitute* ,test-path
962 ;; This test suite includes some tests that the stdlib's
963 ;; `Command` execution properly handles situations where
964 ;; the environment or PATH variable are empty, but this
965 ;; fails since we don't have `echo` available in the usual
966 ;; Linux directories.
967 ;; NB: the leading space is so we don't fail a tidy check
968 ;; for trailing whitespace, and the newlines are to ensure
969 ;; we don't exceed the 100 chars tidy check as well
970 ((" Command::new\\(\"echo\"\\)")
971 (string-append "\nCommand::new(\"" coreutils "/bin/echo\")\n")))
974 (define-public rust-1.31
976 (rust-bootstrapped-package rust-1.30 "1.31.1"
977 "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli")))
981 (substitute-keyword-arguments (package-arguments base-rust)
983 `(modify-phases ,phases
984 (add-after 'patch-tests 'patch-command-exec-tests
985 ,(patch-command-exec-tests-phase
986 "src/test/run-pass/command-exec.rs"))
987 ;; The test has been moved elsewhere.
988 (replace 'disable-amd64-avx-test
990 (substitute* "src/test/ui/issues/issue-44056.rs"
991 (("only-x86_64") "ignore-test"))
993 (add-after 'patch-tests 'patch-process-docs-rev-cmd
995 ;; Disable some doc tests which depend on the "rev" command
996 ;; https://github.com/rust-lang/rust/pull/58746
997 (substitute* "src/libstd/process.rs"
998 (("```rust") "```rust,no_run"))
1001 (define-public rust-1.32
1003 (rust-bootstrapped-package rust-1.31 "1.32.0"
1004 "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac")))
1009 (inherit (package-source base-rust))
1010 (snippet '(begin (delete-file-recursively "src/llvm")
1011 (delete-file-recursively "src/llvm-emscripten")
1012 (delete-file-recursively "src/tools/clang")
1013 (delete-file-recursively "src/tools/lldb")
1014 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1016 (patches (search-patches "rust-reproducible-builds.patch"))
1017 ;; the vendor directory has moved to the root of
1018 ;; the tarball, so we have to strip an extra prefix
1019 (patch-flags '("-p2"))))
1021 ;; Downgrade to LLVM 6, all LTO tests appear to fail with LLVM 7.0.1
1022 (alist-replace "llvm" (list llvm-6)
1023 (package-inputs base-rust)))
1025 (substitute-keyword-arguments (package-arguments base-rust)
1027 `(modify-phases ,phases
1028 ;; Cargo.lock and the vendor/ directory have been moved to the
1029 ;; root of the rust tarball
1030 (replace 'patch-cargo-checksums
1032 (use-modules (guix build cargo-utils))
1033 (substitute* "Cargo.lock"
1034 (("(\"checksum .* = )\".*\"" all name)
1035 (string-append name "\"" ,%cargo-reference-hash "\"")))
1036 (generate-all-checksums "vendor")
1038 (add-after 'enable-codegen-tests 'override-jemalloc
1039 (lambda* (#:key inputs #:allow-other-keys)
1040 ;; The compiler is no longer directly built against jemalloc,
1041 ;; but rather via the jemalloc-sys crate (which vendors the
1042 ;; jemalloc source). To use jemalloc we must enable linking to
1043 ;; it (otherwise it would use the system allocator), and set
1044 ;; an environment variable pointing to the compiled jemalloc.
1045 (substitute* "config.toml"
1046 (("^jemalloc =.*$") "")
1047 (("[[]rust[]]") "\n[rust]\njemalloc=true\n"))
1048 (setenv "JEMALLOC_OVERRIDE" (string-append (assoc-ref inputs "jemalloc")
1049 "/lib/libjemalloc_pic.a"))
1051 ;; Remove no longer relevant steps
1052 (delete 'remove-flaky-test)
1053 (delete 'patch-aarch64-test))))))))
1055 (define-public rust-1.33
1057 (rust-bootstrapped-package rust-1.32 "1.33.0"
1058 "152x91mg7bz4ygligwjb05fgm1blwy2i70s2j03zc9jiwvbsh0as")))
1063 (inherit (package-source base-rust))
1065 (patch-flags '("-p1"))))
1067 ;; Upgrade to jemalloc@5.1.0
1068 (alist-replace "jemalloc" (list jemalloc)
1069 (package-inputs base-rust)))
1071 (substitute-keyword-arguments (package-arguments base-rust)
1073 `(modify-phases ,phases
1074 (delete 'ignore-cargo-package-tests)
1075 (add-after 'configure 'configure-test-threads
1076 ;; Several rustc and cargo tests will fail if run on one core
1077 ;; https://github.com/rust-lang/rust/issues/59122
1078 ;; https://github.com/rust-lang/cargo/issues/6746
1079 ;; https://github.com/rust-lang/rust/issues/58907
1080 (lambda* (#:key inputs #:allow-other-keys)
1081 (setenv "RUST_TEST_THREADS" "2")
1084 (define-public rust-1.34
1086 (rust-bootstrapped-package rust-1.33 "1.34.1"
1087 "19s09k7y5j6g3y4d2rk6kg9pvq6ml94c49w6b72dmq8p9lk8bixh")))
1092 (inherit (package-source base-rust))
1094 (delete-file-recursively "src/llvm-emscripten")
1095 (delete-file-recursively "src/llvm-project")
1096 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1099 (define-public rust-1.35
1101 (rust-bootstrapped-package rust-1.34 "1.35.0"
1102 "0bbizy6b7002v1rdhrxrf5gijclbyizdhkglhp81ib3bf5x66kas")))
1106 (alist-replace "llvm" (list llvm-8)
1107 (package-inputs base-rust)))
1109 (substitute-keyword-arguments (package-arguments base-rust)
1111 `(modify-phases ,phases
1112 ;; The tidy test includes a pass which ensures large binaries
1113 ;; don't accidentally get checked into the rust git repo.
1114 ;; Unfortunately the test assumes that git is always available,
1115 ;; so we'll comment out the invocation of this pass.
1116 (add-after 'configure 'disable-tidy-bins-check
1118 (substitute* "src/tools/tidy/src/main.rs"
1119 (("bins::check") "//bins::check"))
1122 (define-public rust-1.36
1124 (rust-bootstrapped-package rust-1.35 "1.36.0"
1125 "06xv2p6zq03lidr0yaf029ii8wnjjqa894nkmrm6s0rx47by9i04")))
1129 (substitute-keyword-arguments (package-arguments base-rust)
1131 `(modify-phases ,phases
1132 (delete 'patch-process-docs-rev-cmd))))))))
1134 (define-public rust-1.37
1136 (rust-bootstrapped-package rust-1.36 "1.37.0"
1137 "1hrqprybhkhs6d9b5pjskfnc5z9v2l2gync7nb39qjb5s0h703hj")))
1141 (substitute-keyword-arguments (package-arguments base-rust)
1143 `(modify-phases ,phases
1144 (add-before 'configure 'configure-cargo-home
1146 (let ((cargo-home (string-append (getcwd) "/.cargo")))
1147 (mkdir-p cargo-home)
1148 (setenv "CARGO_HOME" cargo-home)
1151 (define-public rust-1.38
1153 (rust-bootstrapped-package rust-1.37 "1.38.0"
1154 "101dlpsfkq67p0hbwx4acqq6n90dj4bbprndizpgh1kigk566hk4")))
1158 (alist-replace "llvm" (list llvm-9)
1159 (package-inputs base-rust)))
1161 (substitute-keyword-arguments (package-arguments base-rust)
1163 `(modify-phases ,phases
1164 (replace 'patch-command-exec-tests
1165 ,(patch-command-exec-tests-phase
1166 "src/test/ui/command-exec.rs"))
1167 (add-after 'patch-tests 'patch-command-uid-gid-test
1169 (substitute* "src/test/ui/command-uid-gid.rs"
1170 (("/bin/sh") (which "sh"))
1171 (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
1174 (define-public rust-1.39
1176 (rust-bootstrapped-package rust-1.38 "1.39.0"
1177 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
1181 (substitute-keyword-arguments (package-arguments base-rust)
1183 `(modify-phases ,phases
1184 (replace 'patch-cargo-checksums
1185 ;; The Cargo.lock format changed.
1187 (use-modules (guix build cargo-utils))
1188 (substitute* "Cargo.lock"
1189 (("(checksum = )\".*\"" all name)
1190 (string-append name "\"" ,%cargo-reference-hash "\"")))
1191 (generate-all-checksums "vendor")
1194 (define-public rust-1.40
1196 (rust-bootstrapped-package rust-1.39 "1.40.0"
1197 "1ba9llwhqm49w7sz3z0gqscj039m53ky9wxzhaj11z6yg1ah15yx")))
1202 (inherit (package-source base-rust))
1203 ;; llvm-emscripten is no longer bundled, as that codegen backend
1206 (delete-file-recursively "src/llvm-project")
1207 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1210 ;; Rust 1.40 does not ship rustc-internal libraries by default
1211 ;; (see rustc-dev-split). This means that librustc_driver.so is no
1212 ;; longer available in lib/rustlib/$target/lib, which is the directory
1213 ;; included in the runpath of librustc_codegen_llvm-llvm.so.
1214 ;; This is detected by our validate-runpath phase as an error, but it
1215 ;; is harmless as the codegen backend is loaded by librustc_driver.so
1216 ;; itself, which must at that point have been already loaded.
1217 ;; As such, we skip validating the runpath for Rust 1.40.
1218 ;; Rust 1.41 stopped putting the codegen backend in a separate library,
1219 ;; which makes this workaround only necessary for this release.
1220 (cons* #:validate-runpath? #f
1221 (substitute-keyword-arguments (package-arguments base-rust)
1223 `(modify-phases ,phases
1224 ;; We often need to patch tests with various Guix-specific paths.
1225 ;; This often increases the line length and makes tidy, rustc's
1226 ;; style checker, complain. We could insert additional newlines
1227 ;; or add an "// ignore-tidy-linelength" comment, but as an
1228 ;; ignore comment must be used, both approaches are fragile due
1229 ;; to upstream formatting changes. As such, disable running the
1230 ;; linter during tests, since it's intended for rustc developers
1233 ;; TODO(rebuild-rust): This phase could be added earlier to
1234 ;; simplify a significant amount of code, but it would require
1235 ;; rebuilding the entire rusty universe.
1236 (add-after 'patch-tests 'neuter-tidy
1238 (substitute* "src/bootstrap/builder.rs"
1239 (("^.*::Tidy,") ""))
1241 ;; TODO(rebuild-rust): Adapt the find-files approach for
1242 ;; earlier testsuite patches.
1243 (replace 'patch-command-uid-gid-test
1245 (match (find-files "src/test" "command-uid-gid\\.rs")
1248 (("/bin/sh") (which "sh")))))
1250 (replace 'patch-command-exec-tests
1251 ,(patch-command-exec-tests-phase
1252 '(match (find-files "src/test" "command-exec\\.rs")
1254 ;; The test got removed in commit 000fe63b6fc57b09828930cacbab20c2ee6e6d15
1255 ;; "Remove painful test that is not pulling its weight"
1256 (delete 'remove-unsupported-tests)))))))))
1258 (define-public rust-1.41
1260 (rust-bootstrapped-package rust-1.40 "1.41.1"
1261 "0ws5x0fxv57fyllsa6025h3q6j9v3m8nb3syl4x0hgkddq0kvj9q")))
1265 (substitute-keyword-arguments (package-arguments base-rust)
1266 ((#:validate-runpath? _) #t))))))
1268 (define-public rust-1.42
1269 (rust-bootstrapped-package rust-1.41 "1.42.0"
1270 "0x9lxs82may6c0iln0b908cxyn1cv7h03n5cmbx3j1bas4qzks6j"))
1272 (define-public rust-1.43
1273 (rust-bootstrapped-package rust-1.42 "1.43.0"
1274 "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
1276 (define-public rust-1.44
1277 (rust-bootstrapped-package rust-1.43 "1.44.1"
1278 "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
1280 (define-public rust-1.45
1282 (rust-bootstrapped-package rust-1.44 "1.45.2"
1283 "0273a1g3f59plyi1n0azf21qjzwml1yqdnj5z472crz37qggr8xp")))
1288 (inherit (package-source base-rust))
1289 (patches (search-patches "rust-1.45-linker-locale.patch"))))
1291 (alist-replace "llvm" (list llvm-10)
1292 (package-inputs base-rust)))
1294 (substitute-keyword-arguments (package-arguments base-rust)
1296 `(modify-phases ,phases
1297 ;; These tests make sure that the parser behaves properly when
1298 ;; a source file starts with a shebang. Unfortunately,
1299 ;; the patch-shebangs phase changes the meaning of these edge-cases.
1300 ;; We skip the test since it's drastically unlikely Guix's packaging
1301 ;; will introduce a bug here.
1302 (add-after 'patch-tests 'skip-shebang-tests
1304 (with-directory-excursion "src/test/ui/parser/shebang"
1305 (delete-file "shebang-doc-comment.rs")
1306 (delete-file "sneaky-attrib.rs")
1308 ;; This test case synchronizes itself by starting a localhost TCP
1309 ;; server. This doesn't work as networking is not available.
1310 (add-after 'patch-tests 'skip-networking-test
1312 (substitute* "src/tools/cargo/tests/testsuite/freshness.rs"
1313 (("fn linking_interrupted" all)
1314 (string-append "#[ignore] " all)))
1317 (define-public rust-1.46
1318 (rust-bootstrapped-package rust-1.45 "1.46.0"
1319 "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))
1321 ;; TODO(staging): Bump this variable to the latest packaged rust.
1322 (define-public rust rust-1.45)