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>
13 ;;; This file is part of GNU Guix.
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
28 (define-module (gnu packages rust)
29 #:use-module (gnu packages base)
30 #:use-module (gnu packages bison)
31 #:use-module (gnu packages bootstrap)
32 #:use-module (gnu packages cmake)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages curl)
35 #:use-module (gnu packages elf)
36 #:use-module (gnu packages flex)
37 #:use-module (gnu packages gcc)
38 #:use-module (gnu packages gdb)
39 #:use-module (gnu packages jemalloc)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages llvm)
42 #:use-module (gnu packages pkg-config)
43 #:use-module (gnu packages python)
44 #:use-module (gnu packages ssh)
45 #:use-module (gnu packages tls)
46 #:use-module (gnu packages)
47 #:use-module (guix build-system cargo)
48 #:use-module (guix build-system gnu)
49 #:use-module (guix build-system trivial)
50 #:use-module (guix download)
51 #:use-module (guix git-download)
52 #:use-module ((guix licenses) #:prefix license:)
53 #:use-module (guix packages)
54 #:use-module ((guix build utils) #:select (alist-replace))
55 #:use-module (guix utils)
56 #:use-module (ice-9 match)
57 #:use-module (srfi srfi-26))
59 ;; This is the hash for the empty file, and the reason it's relevant is not
62 ;; The root of the problem is that Cargo keeps track of a file called
63 ;; Cargo.lock, that contains the hash of the tarball source of each dependency.
65 ;; However, tarball sources aren't handled well by Guix because of the need to
66 ;; patch shebangs in any helper scripts. This is why we use Cargo's vendoring
67 ;; capabilities, where instead of the tarball, a directory is provided in its
68 ;; place. (In the case of rustc, the source code already ships with vendored
69 ;; dependencies, but crates built with cargo-build-system undergo vendoring
72 ;; To preserve the advantages of checksumming, vendored dependencies contain
73 ;; a file called .cargo-checksum.json, which contains the hash of the tarball,
74 ;; as well as the list of files in it, with the hash of each file.
76 ;; The patch-cargo-checksums phase of cargo-build-system runs after
77 ;; any Guix-specific patches to the vendored dependencies and regenerates the
78 ;; .cargo-checksum.json files, but it's hard to know the tarball checksum that
79 ;; should be written to the file - and taking care of any unhandled edge case
80 ;; would require rebuilding everything that depends on rust. This is why we lie,
81 ;; and say that the tarball has the hash of an empty file. It's not a problem
82 ;; because cargo-build-system removes the Cargo.lock file. We can't do that
83 ;; for rustc because of a quirk of its build system, so we modify the lock file
84 ;; to substitute the hash.
85 (define %cargo-reference-hash
86 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
88 (define* (nix-system->gnu-triplet-for-rust
89 #:optional (system (%current-system)))
91 ("x86_64-linux" "x86_64-unknown-linux-gnu")
92 ("i686-linux" "i686-unknown-linux-gnu")
93 ("armhf-linux" "armv7-unknown-linux-gnueabihf")
94 ("aarch64-linux" "aarch64-unknown-linux-gnu")
95 ("mips64el-linux" "mips64el-unknown-linux-gnuabi64")
96 (_ (nix-system->gnu-triplet system))))
98 (define* (rust-uri version #:key (dist "static"))
99 (string-append "https://" dist ".rust-lang.org/dist/"
100 "rustc-" version "-src.tar.gz"))
102 (define* (rust-bootstrapped-package base-rust version checksum)
103 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
109 (inherit (package-source base-rust))
110 (uri (rust-uri version))
111 (sha256 (base32 checksum))))
113 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
114 (alist-replace "rustc-bootstrap" (list base-rust)
115 (package-native-inputs base-rust))))))
117 (define-public mrustc
118 (let ((rustc-version "1.19.0"))
125 (url "https://github.com/thepowersgang/mrustc")
126 (commit (string-append "v" version))))
127 (file-name (git-file-name name version))
130 "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2"))))
131 (outputs '("out" "cargo"))
132 (build-system gnu-build-system)
138 ;; Required for the libstd sources.
139 ("rustc" ,(package-source rust-1.19))))
141 `(#:test-target "test"
143 (list ,(string-append "RUSTC_TARGET="
144 (or (%current-target-system)
145 (nix-system->gnu-triplet-for-rust))))
147 (modify-phases %standard-phases
148 (add-after 'unpack 'patch-date
150 (substitute* "Makefile"
151 (("shell date") "shell date -d @1"))
152 (substitute* "run_rustc/Makefile"
153 (("[$]Vtime ") "$V "))
155 (add-after 'patch-date 'unpack-target-compiler
156 (lambda* (#:key inputs outputs #:allow-other-keys)
157 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
158 (chdir ,(string-append "rustc-" rustc-version "-src"))
159 (invoke "patch" "-p0" ,(string-append "../rustc-" rustc-version
162 (setenv "RUSTC_VERSION" ,rustc-version)
163 (setenv "MRUSTC_TARGET_VER"
164 ,(version-major+minor rustc-version))
165 (setenv "OUTDIR_SUF" "")
168 (lambda* (#:key inputs #:allow-other-keys)
169 (setenv "CC" (string-append (assoc-ref inputs "gcc")
171 (setenv "CXX" (string-append (assoc-ref inputs "gcc")
174 (add-after 'build 'build-minicargo
175 (lambda* (#:key make-flags #:allow-other-keys)
176 ;; TODO: minicargo.mk: RUSTC_VERSION=$(RUSTC_VERSION) RUSTC_CHANNEL=$(RUSTC_SRC_TY) OUTDIR_SUF=$(OUTDIR_SUF)
177 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags)
178 (apply invoke "make" "-C" "tools/minicargo" make-flags)))
179 ;(add-after 'check 'check-locally
180 ; (lambda* (#:key make-flags #:allow-other-keys)
181 ; ;; The enum test wouldn't work otherwise.
182 ; ;; See <https://github.com/thepowersgang/mrustc/issues/137>.
183 ; (setenv "MRUSTC_TARGET_VER" ,(version-major+minor rustc-version))
184 ; (apply invoke "make" "local_tests" make-flags)))
186 (lambda* (#:key inputs outputs #:allow-other-keys)
187 (let* ((out (assoc-ref outputs "out"))
188 (bin (string-append out "/bin"))
189 (tools-bin (string-append out "/tools/bin"))
190 (cargo-out (assoc-ref outputs "cargo"))
191 (cargo-bin (string-append cargo-out "/bin"))
192 (lib (string-append out "/lib"))
193 (lib/rust (string-append lib "/mrust"))
194 (gcc (assoc-ref inputs "gcc"))
195 (run_rustc (string-append out
196 "/share/mrustc/run_rustc")))
197 ;; These files are not reproducible.
198 (for-each delete-file (find-files "output" "\\.txt$"))
199 ;(delete-file-recursively "output/local_tests")
200 (mkdir-p (dirname lib/rust))
201 (copy-recursively "output" lib/rust)
204 (install-file "bin/mrustc" bin)
205 ;; minicargo uses relative paths to resolve mrustc.
206 (install-file "tools/bin/minicargo" tools-bin)
207 (install-file "tools/bin/minicargo" cargo-bin)
209 (copy-file "run_rustc/Makefile"
210 (string-append run_rustc "/Makefile"))
212 (synopsis "Compiler for the Rust programming language")
213 (description "Rust is a systems programming language that provides memory
214 safety and thread safety guarantees.")
215 (home-page "https://github.com/thepowersgang/mrustc")
217 (license (list license:asl2.0 license:expat)))))
226 (uri (rust-uri "1.19.0"))
227 (sha256 (base32 "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))
228 (modules '((guix build utils)))
229 (snippet '(begin (delete-file-recursively "src/llvm") #t))
230 (patches (search-patches "rust-1.19-mrustc.patch"))))
231 (outputs '("out" "cargo"))
232 (properties '((timeout . 72000) ;20 hours
233 (max-silent-time . 18000))) ;5 hours (for armel)
235 `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
236 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
238 (modify-phases %standard-phases
239 (add-after 'unpack 'set-env
240 (lambda* (#:key inputs #:allow-other-keys)
241 ;; Disable test for cross compilation support.
242 (setenv "CFG_DISABLE_CROSS_TESTS" "1")
243 (setenv "SHELL" (which "sh"))
244 (setenv "CONFIG_SHELL" (which "sh"))
245 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
246 ;; guix llvm-3.9.1 package installs only shared libraries
247 (setenv "LLVM_LINK_SHARED" "1")
249 (add-after 'unpack 'patch-cargo-tomls
250 (lambda* (#:key inputs outputs #:allow-other-keys)
251 (substitute* "src/librustc_errors/Cargo.toml"
252 (("[[]dependencies[]]") "
256 (substitute* "src/librustc/Cargo.toml"
257 (("[[]dependencies[]]") "
259 getopts = { path = \"../libgetopts\" }
261 (substitute* "src/librustdoc/Cargo.toml"
262 (("[[]dependencies[]]") "
264 test = { path = \"../libtest\" }
267 (add-after 'unpack 'patch-tests
268 (lambda* (#:key inputs #:allow-other-keys)
269 (let ((bash (assoc-ref inputs "bash")))
270 (substitute* "src/libstd/process.rs"
271 ;; The newline is intentional.
272 ;; There's a line length "tidy" check in Rust which would
274 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
275 (substitute* "src/libstd/net/tcp.rs"
276 ;; There is no network in build environment
277 (("fn connect_timeout_unroutable")
278 "#[ignore]\nfn connect_timeout_unroutable"))
279 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
280 (substitute* "src/libstd/sys/unix/process/process_common.rs"
281 (("fn test_process_mask") "#[allow(unused_attributes)]
283 fn test_process_mask"))
285 (add-after 'patch-tests 'patch-aarch64-test
287 (substitute* "src/librustc_back/dynamic_lib.rs"
288 ;; This test is known to fail on aarch64 and powerpc64le:
289 ;; https://github.com/rust-lang/rust/issues/45410
290 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
292 (add-after 'patch-tests 'use-readelf-for-tests
294 ;; nm doesn't recognize the file format because of the
295 ;; nonstandard sections used by the Rust compiler, but readelf
297 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
301 (add-after 'patch-tests 'remove-unsupported-tests
303 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
304 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
305 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
307 (add-after 'patch-source-shebangs 'patch-cargo-checksums
309 (use-modules (guix build cargo-utils))
310 (substitute* "src/Cargo.lock"
311 (("(\"checksum .* = )\".*\"" all name)
312 (string-append name "\"" ,%cargo-reference-hash "\"")))
313 (generate-all-checksums "src/vendor")
315 ;; This phase is overridden by newer versions.
318 ;; This phase is overridden by newer versions.
320 (lambda* (#:key inputs outputs #:allow-other-keys)
321 (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap")))
322 (setenv "CFG_COMPILER_HOST_TRIPLE"
323 ,(nix-system->gnu-triplet (%current-system)))
324 (setenv "CFG_RELEASE" "")
325 (setenv "CFG_RELEASE_CHANNEL" "stable")
326 (setenv "CFG_LIBDIR_RELATIVE" "lib")
327 (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
328 (setenv "MRUSTC_TARGET_VER" ,(version-major+minor version))
329 ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path.
331 ;; mrustc 0.9 doesn't check the search paths for crates anymore.
332 (copy-recursively (string-append rustc-bootstrap "/lib/mrust")
334 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
335 "src/rustc" "--vendor-dir" "src/vendor"
336 "--output-dir" "output/rustc-build"
337 "-L" (string-append rustc-bootstrap "/lib/mrust")
339 (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
340 (setenv "CFG_RELEASE" #f)
341 (setenv "CFG_RELEASE_CHANNEL" #f)
342 (setenv "CFG_VERSION" #f)
343 (setenv "CFG_PREFIX" #f)
344 (setenv "CFG_LIBDIR_RELATIVE" #f)
345 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
346 "src/tools/cargo" "--vendor-dir" "src/vendor"
347 "--output-dir" "output/cargo-build"
349 "-L" (string-append rustc-bootstrap "/lib/mrust")
351 ;; Now use the newly-built rustc to build the libraries.
352 ;; One day that could be replaced by:
353 ;; (invoke "output/cargo-build/cargo" "build"
354 ;; "--manifest-path" "src/bootstrap/Cargo.toml"
355 ;; "--verbose") ; "--locked" "--frozen"
356 ;; but right now, Cargo has problems with libstd's circular
358 (mkdir-p "output/target-libs")
359 (for-each (match-lambda
364 "output/rustc-build/rustc"
365 "-C" (string-append "linker="
367 ;; Required for libterm.
368 "-Z" "force-unstable-if-unmarked"
369 "-L" "output/target-libs"
370 (string-append "src/" name "/lib.rs")
372 (string-append "output/target-libs/"
373 (car (string-split name #\/))
381 ("liblibc/src" "--cfg" "stdbuild")
382 ("libunwind" "-l" "gcc_s")
383 ("libcompiler_builtins")
386 ;; Uses "cc" to link.
387 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
390 ;; Test dependencies:
396 ;; This phase is overridden by newer versions.
399 ;; This phase is overridden by newer versions.
401 (lambda* (#:key inputs outputs #:allow-other-keys)
402 (let* ((out (assoc-ref outputs "out"))
403 (target-system ,(or (%current-target-system)
404 (nix-system->gnu-triplet
406 (out-libs (string-append out "/lib/rustlib/"
407 target-system "/lib")))
408 ;(setenv "CFG_PREFIX" out)
410 (copy-recursively "output/target-libs" out-libs)
411 (install-file "output/rustc-build/rustc"
412 (string-append out "/bin"))
413 (install-file "output/rustc-build/rustdoc"
414 (string-append out "/bin"))
415 (install-file "output/cargo-build/cargo"
416 (string-append (assoc-ref outputs "cargo")
419 (build-system gnu-build-system)
421 `(("bison" ,bison) ; For the tests
422 ("cmake" ,cmake-minimal)
423 ("flex" ,flex) ; For the tests
424 ;; FIXME: Rust 1.27 and some later versions require GDB 8.2 specifically.
425 ;; See <https://bugs.gnu.org/37810>. Use it on all Rusts for simplicity.
426 ("gdb" ,gdb-8.2) ; For the tests
427 ("procps" ,procps) ; For the tests
428 ("python-2" ,python-2)
429 ("rustc-bootstrap" ,mrustc)
430 ("cargo-bootstrap" ,mrustc "cargo")
431 ("pkg-config" ,pkg-config) ; For "cargo"
434 `(("jemalloc" ,jemalloc-4.5.0)
436 ("openssl" ,openssl-1.0)
437 ("libssh2" ,libssh2) ; For "cargo"
438 ("libcurl" ,curl))) ; For "cargo"
440 ;; rustc invokes gcc, so we need to set its search paths accordingly.
441 ;; Note: duplicate its value here to cope with circular dependencies among
442 ;; modules (see <https://bugs.gnu.org/31392>).
444 (list (search-path-specification
445 (variable "C_INCLUDE_PATH")
446 (files '("include")))
447 (search-path-specification
448 (variable "CPLUS_INCLUDE_PATH")
449 (files '("include/c++" "include")))
450 (search-path-specification
451 (variable "LIBRARY_PATH")
452 (files '("lib" "lib64")))))
454 (synopsis "Compiler for the Rust progamming language")
455 (description "Rust is a systems programming language that provides memory
456 safety and thread safety guarantees.")
457 (home-page "https://www.rust-lang.org")
459 (license (list license:asl2.0 license:expat))))
461 (define-public rust-1.20
463 (rust-bootstrapped-package rust-1.19 "1.20.0"
464 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
469 (inherit (package-source base-rust))
471 (delete-file-recursively "src/jemalloc")
472 (delete-file-recursively "src/llvm")
476 `(;; The tests fail with newer versions of GNU Make.
477 ("make" ,gnu-make-4.2)
478 ,@(package-native-inputs base-rust)))
479 (outputs '("out" "doc" "cargo"))
480 ;; Since rust-1.19 is local, it's quite probable that Hydra
481 ;; will build rust-1.19 only as a dependency of rust-1.20.
482 ;; But then Hydra will use the wrong properties, the ones here,
483 ;; for rust-1.19. Therefore, we copied the properties of
485 (properties '((timeout . 72000) ;20 hours
486 (max-silent-time . 18000))) ;5 hours (for armel)
488 (substitute-keyword-arguments (package-arguments rust-1.19)
490 `(modify-phases ,phases
491 (add-after 'patch-tests 'patch-cargo-tests
493 (substitute* "src/tools/cargo/tests/build.rs"
494 (("/usr/bin/env") (which "env"))
495 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
496 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
497 (substitute* "src/tools/cargo/tests/death.rs"
498 ;; This is stuck when built in container.
499 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
500 ;; Prints test output in the wrong order when built on
502 (substitute* "src/tools/cargo/tests/test.rs"
503 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
505 ;; These tests pull in a dependency on "git", which changes
506 ;; too frequently take part in the Rust toolchain.
507 (substitute* "src/tools/cargo/tests/new.rs"
508 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
509 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
510 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
512 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
513 ;; https://github.com/rust-lang/rust/issues/47863
515 (substitute* "src/test/run-pass/out-of-stack.rs"
516 (("// ignore-android") "// ignore-test\n// ignore-android"))
519 (lambda* (#:key inputs outputs #:allow-other-keys)
520 (let* ((out (assoc-ref outputs "out"))
521 (doc (assoc-ref outputs "doc"))
522 (gcc (assoc-ref inputs "gcc"))
523 (gdb (assoc-ref inputs "gdb"))
524 (binutils (assoc-ref inputs "binutils"))
525 (python (assoc-ref inputs "python-2"))
526 (rustc (assoc-ref inputs "rustc-bootstrap"))
527 (cargo (assoc-ref inputs "cargo-bootstrap"))
528 (llvm (assoc-ref inputs "llvm"))
529 (jemalloc (assoc-ref inputs "jemalloc")))
530 (call-with-output-file "config.toml"
532 (display (string-append "
535 cargo = \"" cargo "/bin/cargo" "\"
536 rustc = \"" rustc "/bin/rustc" "\"
538 python = \"" python "/bin/python2" "\"
539 gdb = \"" gdb "/bin/gdb" "\"
544 docdir = \"" doc "/share/doc/rust" "\"
547 default-linker = \"" gcc "/bin/gcc" "\"
550 " ;; There are 2 failed codegen tests:
551 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
552 ;; These tests require a patched LLVM
553 "codegen-tests = false
554 [target." ,(nix-system->gnu-triplet-for-rust) "]
555 llvm-config = \"" llvm "/bin/llvm-config" "\"
556 cc = \"" gcc "/bin/gcc" "\"
557 cxx = \"" gcc "/bin/g++" "\"
558 ar = \"" binutils "/bin/ar" "\"
559 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
563 (add-after 'configure 'provide-cc
564 (lambda* (#:key inputs #:allow-other-keys)
565 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
567 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
569 (add-after 'provide-cc 'configure-archiver
570 (lambda* (#:key inputs #:allow-other-keys)
571 (substitute* "src/build_helper/lib.rs"
572 ;; Make sure "ar" is always used as the archiver.
573 (("\"musl\"") "\"\"")
574 ;; Then substitute "ar" by our name.
575 (("\"ar\"") (string-append "\""
576 (assoc-ref inputs "binutils")
579 (delete 'patch-cargo-tomls)
580 (add-before 'build 'reset-timestamps-after-changes
584 ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist".
585 ;; Therefore, use timestamp 1.
586 (utime filename 1 1 1 1))
587 (find-files "." #:directories? #t))
591 (invoke "./x.py" "build")
592 (invoke "./x.py" "build" "src/tools/cargo")))
595 ;; Disable parallel execution to prevent EAGAIN errors when
597 (invoke "./x.py" "-j1" "test" "-vv")
598 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
601 (lambda* (#:key outputs #:allow-other-keys)
602 (invoke "./x.py" "install")
603 (substitute* "config.toml"
604 ;; replace prefix to specific output
605 (("prefix = \"[^\"]*\"")
606 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
607 (invoke "./x.py" "install" "cargo")))
608 (add-after 'install 'delete-install-logs
609 (lambda* (#:key outputs #:allow-other-keys)
610 (define (delete-manifest-file out-path file)
611 (delete-file (string-append out-path "/lib/rustlib/" file)))
613 (let ((out (assoc-ref outputs "out"))
614 (cargo-out (assoc-ref outputs "cargo")))
616 (lambda (file) (delete-manifest-file out file))
619 "manifest-rust-std-x86_64-unknown-linux-gnu"
622 (lambda (file) (delete-manifest-file cargo-out file))
626 (add-after 'install 'wrap-rustc
627 (lambda* (#:key inputs outputs #:allow-other-keys)
628 (let ((out (assoc-ref outputs "out"))
629 (libc (assoc-ref inputs "libc"))
630 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
631 ;; Let gcc find ld and libc startup files.
632 (wrap-program (string-append out "/bin/rustc")
633 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
634 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
637 (define-public rust-1.21
638 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
639 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
643 (substitute-keyword-arguments (package-arguments base-rust)
645 `(modify-phases ,phases
646 (add-after 'configure 'remove-ar
647 (lambda* (#:key inputs #:allow-other-keys)
648 ;; Remove because toml complains about "unknown field".
649 (substitute* "config.toml"
653 (define-public rust-1.22
654 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
655 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
659 (substitute-keyword-arguments (package-arguments base-rust)
661 `(modify-phases ,phases
662 (add-after 'unpack 'remove-flaky-test
664 ;; See <https://github.com/rust-lang/rust/issues/43402>.
665 (when (file-exists? "src/test/run-make/issue-26092")
666 (delete-file-recursively "src/test/run-make/issue-26092"))
669 (define-public rust-1.23
670 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
671 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
675 (substitute-keyword-arguments (package-arguments base-rust)
677 `(modify-phases ,phases
678 (delete 'configure-archiver)
680 (add-after 'unpack 'dont-build-native
682 ;; XXX: Revisit this when we use gcc 6.
683 (substitute* "src/binaryen/CMakeLists.txt"
684 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
687 (define-public rust-1.24
689 (rust-bootstrapped-package rust-1.23 "1.24.1"
690 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
694 (substitute-keyword-arguments (package-arguments base-rust)
696 `(modify-phases ,phases
697 (delete 'use-readelf-for-tests)
698 (replace 'patch-aarch64-test
700 (substitute* "src/librustc_metadata/dynamic_lib.rs"
701 ;; This test is known to fail on aarch64 and powerpc64le:
702 ;; https://github.com/rust-lang/rust/issues/45410
703 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
706 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
707 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
708 ;;; Keep using llvm 3.9.1 until builds become determenistic
709 (define-public rust-1.25
711 (rust-bootstrapped-package rust-1.24 "1.25.0"
712 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")))
717 (inherit (package-source base-rust))
719 (delete-file-recursively "src/jemalloc")
720 (delete-file-recursively "src/llvm")
721 (delete-file-recursively "src/llvm-emscripten")
723 (patches (search-patches
724 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
726 (substitute-keyword-arguments (package-arguments base-rust)
728 `(modify-phases ,phases
729 (add-after 'patch-cargo-tests 'patch-cargo-index-update
731 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
732 ;; This test wants to update the crate index.
733 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
735 (replace 'patch-aarch64-test
737 (substitute* "src/librustc_metadata/dynamic_lib.rs"
738 ;; This test is known to fail on aarch64 and powerpc64le:
739 ;; https://github.com/rust-lang/rust/issues/45410
740 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
741 ;; This test fails on aarch64 with llvm@6.0:
742 ;; https://github.com/rust-lang/rust/issues/49807
743 ;; other possible solution:
744 ;; https://github.com/rust-lang/rust/pull/47688
745 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
747 (delete 'ignore-glibc-2.27-incompatible-test))))))))
749 (define-public rust-1.26
751 (rust-bootstrapped-package rust-1.25 "1.26.2"
752 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv")))
757 (inherit (package-source base-rust))
758 (patches (search-patches
759 "rust-coresimd-doctest.patch"
760 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
762 (substitute-keyword-arguments (package-arguments base-rust)
764 `(modify-phases ,phases
765 ;; binaryen was replaced with LLD project from LLVM
766 (delete 'dont-build-native)
769 ;; Enable parallel execution.
770 (let ((parallel-job-spec
771 (string-append "-j" (number->string
773 (parallel-job-count))))))
774 (invoke "./x.py" parallel-job-spec "test" "-vv")
775 (invoke "./x.py" parallel-job-spec "test"
776 "src/tools/cargo"))))
777 (replace 'remove-unsupported-tests
779 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
780 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
781 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
783 (replace 'patch-cargo-tests
785 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
786 (("/usr/bin/env") (which "env"))
787 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
788 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
789 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
790 ;; This is stuck when built in container.
791 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
792 ;; Prints test output in the wrong order when built on
794 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
795 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
797 ;; Avoid dependency on "git".
798 (substitute* "src/tools/cargo/tests/testsuite/new.rs"
799 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
800 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
801 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
803 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
805 ;; This test failed to work on "nightly" channel builds
806 ;; https://github.com/rust-lang/cargo/issues/5648
807 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
808 (("fn test_resolving_minimum_version_with_transitive_deps")
809 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
811 (replace 'patch-cargo-index-update
813 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
814 ;; This test wants to update the crate index.
815 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
818 (define-public rust-1.27
820 (rust-bootstrapped-package rust-1.26 "1.27.2"
821 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs")))
826 (inherit (package-source base-rust))
827 (patches (search-patches "rust-coresimd-doctest.patch"
828 "rust-bootstrap-stage0-test.patch"
829 "rust-1.25-accept-more-detailed-gdb-lines.patch"
830 "rust-reproducible-builds.patch"))))
832 (substitute-keyword-arguments (package-arguments base-rust)
834 `(modify-phases ,phases
835 (add-before 'install 'mkdir-prefix-paths
836 (lambda* (#:key outputs #:allow-other-keys)
837 ;; As result of https://github.com/rust-lang/rust/issues/36989
838 ;; `prefix' directory should exist before `install' call
839 (mkdir-p (assoc-ref outputs "out"))
840 (mkdir-p (assoc-ref outputs "cargo"))
842 (add-after 'patch-cargo-tests 'disable-thinlto-test
844 ;; thinlto required llvm 6.0 for work
845 (substitute* "src/tools/cargo/tests/testsuite/path.rs"
846 (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works"))
849 (define-public rust-1.28
851 (rust-bootstrapped-package rust-1.27 "1.28.0"
852 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx")))
857 (inherit (package-source base-rust))
858 (patches (search-patches "rust-coresimd-doctest.patch"
859 "rust-bootstrap-stage0-test.patch"
860 "rust-1.25-accept-more-detailed-gdb-lines.patch"
861 "rust-reproducible-builds.patch"))))
864 (alist-replace "llvm" (list llvm-6)
865 (package-inputs base-rust)))
867 (substitute-keyword-arguments (package-arguments base-rust)
869 `(modify-phases ,phases
870 (add-after 'configure 'enable-codegen-tests
871 ;; Codegen tests should pass with llvm 6, so enable them.
873 (substitute* "config.toml"
874 (("codegen-tests = false") ""))
876 (add-after 'patch-tests 'disable-amd64-avx-test
877 ;; That test would fail on x86_64 machines without avx.
879 (substitute* "src/test/run-pass/issue-44056.rs"
880 (("only-x86_64") "ignore-test"))
882 ;; This is no longer needed as of 1.28
883 (delete 'disable-cargo-test-for-nightly-channel)
884 ;; The thinlto test should pass with llvm 6.
885 (delete 'disable-thinlto-test))))))))
887 (define-public rust-1.29
889 (rust-bootstrapped-package rust-1.28 "1.29.2"
890 "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h")))
895 (inherit (package-source base-rust))
896 (patches (search-patches "rust-1.25-accept-more-detailed-gdb-lines.patch"
897 "rust-reproducible-builds.patch")))))))
899 (define-public rust-1.30
901 (rust-bootstrapped-package rust-1.29 "1.30.1"
902 "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn")))
907 (inherit (package-source base-rust))
909 (delete-file-recursively "src/jemalloc")
910 (delete-file-recursively "src/llvm")
911 (delete-file-recursively "src/llvm-emscripten")
912 (delete-file-recursively "src/tools/clang")
913 (delete-file-recursively "src/tools/lldb")
916 (substitute-keyword-arguments (package-arguments base-rust)
918 `(modify-phases ,phases
919 (add-after 'patch-cargo-tests 'patch-cargo-env-shebang
920 (lambda* (#:key inputs #:allow-other-keys)
921 (let ((coreutils (assoc-ref inputs "coreutils")))
922 (substitute* "src/tools/cargo/tests/testsuite/fix.rs"
923 ;; Cargo has a test which explicitly sets a
924 ;; RUSTC_WRAPPER environment variable which points
925 ;; to /usr/bin/env. Since it's not a shebang, it
926 ;; needs to be manually patched
927 (("\"/usr/bin/env\"")
928 (string-append "\"" coreutils "/bin/env\"")))
930 (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
932 (substitute* "src/tools/cargo/tests/testsuite/package.rs"
933 ;; These tests largely check that cargo outputs warning/error
934 ;; messages as expected. It seems that cargo outputs an
935 ;; absolute path to something in the store instead of the
936 ;; expected relative path (e.g. `[..]`) so we'll ignore
938 (("fn include") "#[ignore]\nfn include")
939 (("fn exclude") "#[ignore]\nfn exclude"))
941 ;; The test has been moved elsewhere.
942 (replace 'disable-amd64-avx-test
944 (substitute* "src/test/ui/run-pass/issues/issue-44056.rs"
945 (("only-x86_64") "ignore-test"))
948 (define (patch-command-exec-tests-phase test-path)
949 "The command-exec.rs test moves around between releases. We need to apply
950 a Guix-specific patch to it for each release. This function generates the phase
951 that applies said patch, parametrized by the test-path. This is done this way
952 because the phase is more complex than the equivalents for other tests that
954 `(lambda* (#:key inputs #:allow-other-keys)
955 (let ((coreutils (assoc-ref inputs "coreutils")))
956 (substitute* ,test-path
957 ;; This test suite includes some tests that the stdlib's
958 ;; `Command` execution properly handles situations where
959 ;; the environment or PATH variable are empty, but this
960 ;; fails since we don't have `echo` available in the usual
961 ;; Linux directories.
962 ;; NB: the leading space is so we don't fail a tidy check
963 ;; for trailing whitespace, and the newlines are to ensure
964 ;; we don't exceed the 100 chars tidy check as well
965 ((" Command::new\\(\"echo\"\\)")
966 (string-append "\nCommand::new(\"" coreutils "/bin/echo\")\n")))
969 (define-public rust-1.31
971 (rust-bootstrapped-package rust-1.30 "1.31.1"
972 "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli")))
976 (substitute-keyword-arguments (package-arguments base-rust)
978 `(modify-phases ,phases
979 (add-after 'patch-tests 'patch-command-exec-tests
980 ,(patch-command-exec-tests-phase
981 "src/test/run-pass/command-exec.rs"))
982 ;; The test has been moved elsewhere.
983 (replace 'disable-amd64-avx-test
985 (substitute* "src/test/ui/issues/issue-44056.rs"
986 (("only-x86_64") "ignore-test"))
988 (add-after 'patch-tests 'patch-process-docs-rev-cmd
990 ;; Disable some doc tests which depend on the "rev" command
991 ;; https://github.com/rust-lang/rust/pull/58746
992 (substitute* "src/libstd/process.rs"
993 (("```rust") "```rust,no_run"))
996 (define-public rust-1.32
998 (rust-bootstrapped-package rust-1.31 "1.32.0"
999 "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac")))
1004 (inherit (package-source base-rust))
1005 (snippet '(begin (delete-file-recursively "src/llvm")
1006 (delete-file-recursively "src/llvm-emscripten")
1007 (delete-file-recursively "src/tools/clang")
1008 (delete-file-recursively "src/tools/lldb")
1009 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1011 (patches (search-patches "rust-reproducible-builds.patch"))
1012 ;; the vendor directory has moved to the root of
1013 ;; the tarball, so we have to strip an extra prefix
1014 (patch-flags '("-p2"))))
1016 ;; Downgrade to LLVM 6, all LTO tests appear to fail with LLVM 7.0.1
1017 (alist-replace "llvm" (list llvm-6)
1018 (package-inputs base-rust)))
1020 (substitute-keyword-arguments (package-arguments base-rust)
1022 `(modify-phases ,phases
1023 ;; Cargo.lock and the vendor/ directory have been moved to the
1024 ;; root of the rust tarball
1025 (replace 'patch-cargo-checksums
1027 (use-modules (guix build cargo-utils))
1028 (substitute* "Cargo.lock"
1029 (("(\"checksum .* = )\".*\"" all name)
1030 (string-append name "\"" ,%cargo-reference-hash "\"")))
1031 (generate-all-checksums "vendor")
1033 (add-after 'enable-codegen-tests 'override-jemalloc
1034 (lambda* (#:key inputs #:allow-other-keys)
1035 ;; The compiler is no longer directly built against jemalloc,
1036 ;; but rather via the jemalloc-sys crate (which vendors the
1037 ;; jemalloc source). To use jemalloc we must enable linking to
1038 ;; it (otherwise it would use the system allocator), and set
1039 ;; an environment variable pointing to the compiled jemalloc.
1040 (substitute* "config.toml"
1041 (("^jemalloc =.*$") "")
1042 (("[[]rust[]]") "\n[rust]\njemalloc=true\n"))
1043 (setenv "JEMALLOC_OVERRIDE" (string-append (assoc-ref inputs "jemalloc")
1044 "/lib/libjemalloc_pic.a"))
1046 ;; Remove no longer relevant steps
1047 (delete 'remove-flaky-test)
1048 (delete 'patch-aarch64-test))))))))
1050 (define-public rust-1.33
1052 (rust-bootstrapped-package rust-1.32 "1.33.0"
1053 "152x91mg7bz4ygligwjb05fgm1blwy2i70s2j03zc9jiwvbsh0as")))
1058 (inherit (package-source base-rust))
1060 (patch-flags '("-p1"))))
1062 ;; Upgrade to jemalloc@5.1.0
1063 (alist-replace "jemalloc" (list jemalloc)
1064 (package-inputs base-rust)))
1066 (substitute-keyword-arguments (package-arguments base-rust)
1068 `(modify-phases ,phases
1069 (delete 'ignore-cargo-package-tests)
1070 (add-after 'configure 'configure-test-threads
1071 ;; Several rustc and cargo tests will fail if run on one core
1072 ;; https://github.com/rust-lang/rust/issues/59122
1073 ;; https://github.com/rust-lang/cargo/issues/6746
1074 ;; https://github.com/rust-lang/rust/issues/58907
1075 (lambda* (#:key inputs #:allow-other-keys)
1076 (setenv "RUST_TEST_THREADS" "2")
1079 (define-public rust-1.34
1081 (rust-bootstrapped-package rust-1.33 "1.34.1"
1082 "19s09k7y5j6g3y4d2rk6kg9pvq6ml94c49w6b72dmq8p9lk8bixh")))
1087 (inherit (package-source base-rust))
1089 (delete-file-recursively "src/llvm-emscripten")
1090 (delete-file-recursively "src/llvm-project")
1091 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1094 (define-public rust-1.35
1096 (rust-bootstrapped-package rust-1.34 "1.35.0"
1097 "0bbizy6b7002v1rdhrxrf5gijclbyizdhkglhp81ib3bf5x66kas")))
1101 (alist-replace "llvm" (list llvm-8)
1102 (package-inputs base-rust)))
1104 (substitute-keyword-arguments (package-arguments base-rust)
1106 `(modify-phases ,phases
1107 ;; The tidy test includes a pass which ensures large binaries
1108 ;; don't accidentally get checked into the rust git repo.
1109 ;; Unfortunately the test assumes that git is always available,
1110 ;; so we'll comment out the invocation of this pass.
1111 (add-after 'configure 'disable-tidy-bins-check
1113 (substitute* "src/tools/tidy/src/main.rs"
1114 (("bins::check") "//bins::check"))
1117 (define-public rust-1.36
1119 (rust-bootstrapped-package rust-1.35 "1.36.0"
1120 "06xv2p6zq03lidr0yaf029ii8wnjjqa894nkmrm6s0rx47by9i04")))
1124 (substitute-keyword-arguments (package-arguments base-rust)
1126 `(modify-phases ,phases
1127 (delete 'patch-process-docs-rev-cmd))))))))
1129 (define-public rust-1.37
1131 (rust-bootstrapped-package rust-1.36 "1.37.0"
1132 "1hrqprybhkhs6d9b5pjskfnc5z9v2l2gync7nb39qjb5s0h703hj")))
1136 (substitute-keyword-arguments (package-arguments base-rust)
1138 `(modify-phases ,phases
1139 (add-before 'configure 'configure-cargo-home
1141 (let ((cargo-home (string-append (getcwd) "/.cargo")))
1142 (mkdir-p cargo-home)
1143 (setenv "CARGO_HOME" cargo-home)
1146 (define-public rust-1.38
1148 (rust-bootstrapped-package rust-1.37 "1.38.0"
1149 "101dlpsfkq67p0hbwx4acqq6n90dj4bbprndizpgh1kigk566hk4")))
1153 (alist-replace "llvm" (list llvm-9)
1154 (package-inputs base-rust)))
1156 (substitute-keyword-arguments (package-arguments base-rust)
1158 `(modify-phases ,phases
1159 (replace 'patch-command-exec-tests
1160 ,(patch-command-exec-tests-phase
1161 "src/test/ui/command-exec.rs"))
1162 (add-after 'patch-tests 'patch-command-uid-gid-test
1164 (substitute* "src/test/ui/command-uid-gid.rs"
1165 (("/bin/sh") (which "sh"))
1166 (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
1169 (define-public rust-1.39
1171 (rust-bootstrapped-package rust-1.38 "1.39.0"
1172 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
1176 (substitute-keyword-arguments (package-arguments base-rust)
1178 `(modify-phases ,phases
1179 (replace 'patch-cargo-checksums
1180 ;; The Cargo.lock format changed.
1182 (use-modules (guix build cargo-utils))
1183 (substitute* "Cargo.lock"
1184 (("(checksum = )\".*\"" all name)
1185 (string-append name "\"" ,%cargo-reference-hash "\"")))
1186 (generate-all-checksums "vendor")
1189 (define-public rust-1.40
1191 (rust-bootstrapped-package rust-1.39 "1.40.0"
1192 "1ba9llwhqm49w7sz3z0gqscj039m53ky9wxzhaj11z6yg1ah15yx")))
1197 (inherit (package-source base-rust))
1198 ;; llvm-emscripten is no longer bundled, as that codegen backend
1201 (delete-file-recursively "src/llvm-project")
1202 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1205 ;; Rust 1.40 does not ship rustc-internal libraries by default
1206 ;; (see rustc-dev-split). This means that librustc_driver.so is no
1207 ;; longer available in lib/rustlib/$target/lib, which is the directory
1208 ;; included in the runpath of librustc_codegen_llvm-llvm.so.
1209 ;; This is detected by our validate-runpath phase as an error, but it
1210 ;; is harmless as the codegen backend is loaded by librustc_driver.so
1211 ;; itself, which must at that point have been already loaded.
1212 ;; As such, we skip validating the runpath for Rust 1.40.
1213 ;; Rust 1.41 stopped putting the codegen backend in a separate library,
1214 ;; which makes this workaround only necessary for this release.
1215 (cons* #:validate-runpath? #f
1216 (substitute-keyword-arguments (package-arguments base-rust)
1218 `(modify-phases ,phases
1219 ;; We often need to patch tests with various Guix-specific paths.
1220 ;; This often increases the line length and makes tidy, rustc's
1221 ;; style checker, complain. We could insert additional newlines
1222 ;; or add an "// ignore-tidy-linelength" comment, but as an
1223 ;; ignore comment must be used, both approaches are fragile due
1224 ;; to upstream formatting changes. As such, disable running the
1225 ;; linter during tests, since it's intended for rustc developers
1228 ;; TODO(rebuild-rust): This phase could be added earlier to
1229 ;; simplify a significant amount of code, but it would require
1230 ;; rebuilding the entire rusty universe.
1231 (add-after 'patch-tests 'neuter-tidy
1233 (substitute* "src/bootstrap/builder.rs"
1234 (("^.*::Tidy,") ""))
1236 ;; TODO(rebuild-rust): Adapt the find-files approach for
1237 ;; earlier testsuite patches.
1238 (replace 'patch-command-uid-gid-test
1240 (match (find-files "src/test" "command-uid-gid\\.rs")
1243 (("/bin/sh") (which "sh")))))
1245 (replace 'patch-command-exec-tests
1246 ,(patch-command-exec-tests-phase
1247 '(match (find-files "src/test" "command-exec\\.rs")
1249 ;; The test got removed in commit 000fe63b6fc57b09828930cacbab20c2ee6e6d15
1250 ;; "Remove painful test that is not pulling its weight"
1251 (delete 'remove-unsupported-tests)))))))))
1253 (define-public rust-1.41
1255 (rust-bootstrapped-package rust-1.40 "1.41.1"
1256 "0ws5x0fxv57fyllsa6025h3q6j9v3m8nb3syl4x0hgkddq0kvj9q")))
1260 (substitute-keyword-arguments (package-arguments base-rust)
1261 ((#:validate-runpath? _) #t))))))
1263 (define-public rust-1.42
1264 (rust-bootstrapped-package rust-1.41 "1.42.0"
1265 "0x9lxs82may6c0iln0b908cxyn1cv7h03n5cmbx3j1bas4qzks6j"))
1267 (define-public rust-1.43
1268 (rust-bootstrapped-package rust-1.42 "1.43.0"
1269 "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
1271 (define-public rust-1.44
1272 (rust-bootstrapped-package rust-1.43 "1.44.1"
1273 "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
1275 (define-public rust-1.45
1277 (rust-bootstrapped-package rust-1.44 "1.45.0"
1278 "0z6dh0yd3fcm3qh960wi4s6fa6pxz9mh77psycsqfkkx5kqra15s")))
1283 (inherit (package-source base-rust))
1284 (patches (search-patches "rust-1.45-linker-locale.patch"))))
1286 (alist-replace "llvm" (list llvm-10)
1287 (package-inputs base-rust)))
1289 (substitute-keyword-arguments (package-arguments base-rust)
1291 `(modify-phases ,phases
1292 ;; These tests make sure that the parser behaves properly when
1293 ;; a source file starts with a shebang. Unfortunately,
1294 ;; the patch-shebangs phase changes the meaning of these edge-cases.
1295 ;; We skip the test since it's drastically unlikely Guix's packaging
1296 ;; will introduce a bug here.
1297 (add-after 'patch-tests 'skip-shebang-tests
1299 (with-directory-excursion "src/test/ui/parser/shebang"
1300 (delete-file "shebang-doc-comment.rs")
1301 (delete-file "sneaky-attrib.rs")
1303 ;; This test case synchronizes itself by starting a localhost TCP
1304 ;; server. This doesn't work as networking is not available.
1305 (add-after 'patch-tests 'skip-networking-test
1307 (substitute* "src/tools/cargo/tests/testsuite/freshness.rs"
1308 (("fn linking_interrupted" all)
1309 (string-append "#[ignore] " all)))
1312 ;; TODO(staging): Bump this variable to the latest packaged rust.
1313 (define-public rust rust-1.45)