Merge branch 'master' into staging
[jackhill/guix/guix.git] / gnu / packages / rust.scm
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>
13 ;;;
14 ;;; This file is part of GNU Guix.
15 ;;;
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.
20 ;;;
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.
25 ;;;
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/>.
28
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))
59
60 ;; This is the hash for the empty file, and the reason it's relevant is not
61 ;; the most obvious.
62 ;;
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.
65 ;;
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
71 ;; during the build.)
72 ;;
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.
76 ;;
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")
88
89 (define* (nix-system->gnu-triplet-for-rust
90 #:optional (system (%current-system)))
91 (match 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))))
98
99 (define* (rust-uri version #:key (dist "static"))
100 (string-append "https://" dist ".rust-lang.org/dist/"
101 "rustc-" version "-src.tar.gz"))
102
103 (define* (rust-bootstrapped-package base-rust version checksum)
104 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
105 (package
106 (inherit base-rust)
107 (version version)
108 (source
109 (origin
110 (inherit (package-source base-rust))
111 (uri (rust-uri version))
112 (sha256 (base32 checksum))))
113 (native-inputs
114 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
115 (alist-replace "rustc-bootstrap" (list base-rust)
116 (package-native-inputs base-rust))))))
117
118 (define-public mrustc
119 (let ((rustc-version "1.19.0"))
120 (package
121 (name "mrustc")
122 (version "0.9")
123 (source (origin
124 (method git-fetch)
125 (uri (git-reference
126 (url "https://github.com/thepowersgang/mrustc")
127 (commit (string-append "v" version))))
128 (file-name (git-file-name name version))
129 (sha256
130 (base32
131 "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2"))))
132 (outputs '("out" "cargo"))
133 (build-system gnu-build-system)
134 (inputs
135 `(("zlib" ,zlib)))
136 (native-inputs
137 `(("bison" ,bison)
138 ("flex" ,flex)
139 ;; Required for the libstd sources.
140 ("rustc" ,(package-source rust-1.19))))
141 (arguments
142 `(#:test-target "test"
143 #:make-flags
144 (list ,(string-append "RUSTC_TARGET="
145 (or (%current-target-system)
146 (nix-system->gnu-triplet-for-rust))))
147 #:phases
148 (modify-phases %standard-phases
149 (add-after 'unpack 'patch-date
150 (lambda _
151 (substitute* "Makefile"
152 (("shell date") "shell date -d @1"))
153 (substitute* "run_rustc/Makefile"
154 (("[$]Vtime ") "$V "))
155 #t))
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
161 "-src.patch"))
162 (chdir "..")
163 (setenv "RUSTC_VERSION" ,rustc-version)
164 (setenv "MRUSTC_TARGET_VER"
165 ,(version-major+minor rustc-version))
166 (setenv "OUTDIR_SUF" "")
167 #t))
168 (replace 'configure
169 (lambda* (#:key inputs #:allow-other-keys)
170 (setenv "CC" (string-append (assoc-ref inputs "gcc")
171 "/bin/gcc"))
172 (setenv "CXX" (string-append (assoc-ref inputs "gcc")
173 "/bin/g++"))
174 #t))
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)))
186 (replace 'install
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)
203 (mkdir-p bin)
204 (mkdir-p tools-bin)
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)
209 (mkdir-p run_rustc)
210 (copy-file "run_rustc/Makefile"
211 (string-append run_rustc "/Makefile"))
212 #t))))))
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")
217 ;; Dual licensed.
218 (license (list license:asl2.0 license:expat)))))
219
220 (define rust-1.19
221 (package
222 (name "rust")
223 (version "1.19.0")
224 (source
225 (origin
226 (method url-fetch)
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)
235 (arguments
236 `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
237 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
238 #:phases
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")
249 #t))
250 (add-after 'unpack 'patch-cargo-tomls
251 (lambda* (#:key inputs outputs #:allow-other-keys)
252 (substitute* "src/librustc_errors/Cargo.toml"
253 (("[[]dependencies[]]") "
254 [dependencies]
255 term = \"0.4.4\"
256 "))
257 (substitute* "src/librustc/Cargo.toml"
258 (("[[]dependencies[]]") "
259 [dependencies]
260 getopts = { path = \"../libgetopts\" }
261 "))
262 (substitute* "src/librustdoc/Cargo.toml"
263 (("[[]dependencies[]]") "
264 [dependencies]
265 test = { path = \"../libtest\" }
266 "))
267 #t))
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
274 ;; fail otherwise.
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)]
283 #[ignore]
284 fn test_process_mask"))
285 #t)))
286 (add-after 'patch-tests 'patch-aarch64-test
287 (lambda* _
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"))
292 #t))
293 (add-after 'patch-tests 'use-readelf-for-tests
294 (lambda* _
295 ;; nm doesn't recognize the file format because of the
296 ;; nonstandard sections used by the Rust compiler, but readelf
297 ;; ignores them.
298 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
299 (("\tnm ")
300 "\treadelf -c "))
301 #t))
302 (add-after 'patch-tests 'remove-unsupported-tests
303 (lambda* _
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")
307 #t))
308 (add-after 'patch-source-shebangs 'patch-cargo-checksums
309 (lambda* _
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")
315 #t))
316 ;; This phase is overridden by newer versions.
317 (replace 'configure
318 (const #t))
319 ;; This phase is overridden by newer versions.
320 (replace 'build
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.
331 (mkdir-p "output")
332 ;; mrustc 0.9 doesn't check the search paths for crates anymore.
333 (copy-recursively (string-append rustc-bootstrap "/lib/mrust")
334 "output")
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")
339 "-j" "1")
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"
349 "-L" "output/"
350 "-L" (string-append rustc-bootstrap "/lib/mrust")
351 "-j" "1")
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
358 ;; dependencies.
359 (mkdir-p "output/target-libs")
360 (for-each (match-lambda
361 ((name . flags)
362 (write name)
363 (newline)
364 (apply invoke
365 "output/rustc-build/rustc"
366 "-C" (string-append "linker="
367 (getenv "CC"))
368 ;; Required for libterm.
369 "-Z" "force-unstable-if-unmarked"
370 "-L" "output/target-libs"
371 (string-append "src/" name "/lib.rs")
372 "-o"
373 (string-append "output/target-libs/"
374 (car (string-split name #\/))
375 ".rlib")
376 flags)))
377 '(("libcore")
378 ("libstd_unicode")
379 ("liballoc")
380 ("libcollections")
381 ("librand")
382 ("liblibc/src" "--cfg" "stdbuild")
383 ("libunwind" "-l" "gcc_s")
384 ("libcompiler_builtins")
385 ("liballoc_system")
386 ("libpanic_unwind")
387 ;; Uses "cc" to link.
388 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
389 ("libarena")
390
391 ;; Test dependencies:
392
393 ("libgetopts")
394 ("libterm")
395 ("libtest")))
396 #t)))
397 ;; This phase is overridden by newer versions.
398 (replace 'check
399 (const #t))
400 ;; This phase is overridden by newer versions.
401 (replace 'install
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
406 (%current-system))))
407 (out-libs (string-append out "/lib/rustlib/"
408 target-system "/lib")))
409 ;(setenv "CFG_PREFIX" out)
410 (mkdir-p out-libs)
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")
418 "/bin")))
419 #t)))))
420 (build-system gnu-build-system)
421 (native-inputs
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"
433 ("which" ,which)))
434 (inputs
435 `(("jemalloc" ,jemalloc-4.5.0)
436 ("llvm" ,llvm-3.9.1)
437 ("openssl" ,openssl-1.0)
438 ("libssh2" ,libssh2) ; For "cargo"
439 ("libcurl" ,curl))) ; For "cargo"
440
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>).
444 (native-search-paths
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")))))
454
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")
459 ;; Dual licensed.
460 (license (list license:asl2.0 license:expat))))
461
462 (define-public rust-1.20
463 (let ((base-rust
464 (rust-bootstrapped-package rust-1.19 "1.20.0"
465 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
466 (package
467 (inherit base-rust)
468 (source
469 (origin
470 (inherit (package-source base-rust))
471 (snippet '(begin
472 (delete-file-recursively "src/jemalloc")
473 (delete-file-recursively "src/llvm")
474 #t))
475 (patches '())))
476 (native-inputs
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
485 ;; rust-1.19 here.
486 (properties '((timeout . 72000) ;20 hours
487 (max-silent-time . 18000))) ;5 hours (for armel)
488 (arguments
489 (substitute-keyword-arguments (package-arguments rust-1.19)
490 ((#:phases phases)
491 `(modify-phases ,phases
492 (add-after 'patch-tests 'patch-cargo-tests
493 (lambda _
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
502 ;; i686-linux.
503 (substitute* "src/tools/cargo/tests/test.rs"
504 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
505
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"))
512 #t))
513 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
514 ;; https://github.com/rust-lang/rust/issues/47863
515 (lambda _
516 (substitute* "src/test/run-pass/out-of-stack.rs"
517 (("// ignore-android") "// ignore-test\n// ignore-android"))
518 #t))
519 (replace 'configure
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"
532 (lambda (port)
533 (display (string-append "
534 [llvm]
535 [build]
536 cargo = \"" cargo "/bin/cargo" "\"
537 rustc = \"" rustc "/bin/rustc" "\"
538 docs = true
539 python = \"" python "/bin/python2" "\"
540 gdb = \"" gdb "/bin/gdb" "\"
541 vendor = true
542 submodules = false
543 [install]
544 prefix = \"" out "\"
545 docdir = \"" doc "/share/doc/rust" "\"
546 sysconfdir = \"etc\"
547 [rust]
548 default-linker = \"" gcc "/bin/gcc" "\"
549 channel = \"stable\"
550 rpath = true
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" "\"
561 [dist]
562 ") port)))
563 #t)))
564 (add-after 'configure 'provide-cc
565 (lambda* (#:key inputs #:allow-other-keys)
566 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
567 "/tmp/cc")
568 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
569 #t))
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")
578 "/bin/ar\"")))
579 #t))
580 (delete 'patch-cargo-tomls)
581 (add-before 'build 'reset-timestamps-after-changes
582 (lambda* _
583 (for-each
584 (lambda (filename)
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))
589 #t))
590 (replace 'build
591 (lambda* _
592 (invoke "./x.py" "build")
593 (invoke "./x.py" "build" "src/tools/cargo")))
594 (replace 'check
595 (lambda* _
596 ;; Disable parallel execution to prevent EAGAIN errors when
597 ;; running tests.
598 (invoke "./x.py" "-j1" "test" "-vv")
599 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
600 #t))
601 (replace 'install
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)))
613
614 (let ((out (assoc-ref outputs "out"))
615 (cargo-out (assoc-ref outputs "cargo")))
616 (for-each
617 (lambda (file) (delete-manifest-file out file))
618 '("install.log"
619 "manifest-rust-docs"
620 ,(string-append "manifest-rust-std-"
621 (nix-system->gnu-triplet-for-rust))
622 "manifest-rustc"))
623 (for-each
624 (lambda (file) (delete-manifest-file cargo-out file))
625 '("install.log"
626 "manifest-cargo"))
627 #t)))
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"))))
637 #t))))))))))
638
639 (define-public rust-1.21
640 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
641 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
642 (package
643 (inherit base-rust)
644 (arguments
645 (substitute-keyword-arguments (package-arguments base-rust)
646 ((#:phases phases)
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"
652 (("^ar =.*") "\n"))
653 #t)))))))))
654
655 (define-public rust-1.22
656 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
657 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
658 (package
659 (inherit base-rust)
660 (arguments
661 (substitute-keyword-arguments (package-arguments base-rust)
662 ((#:phases phases)
663 `(modify-phases ,phases
664 (add-after 'unpack 'remove-flaky-test
665 (lambda _
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"))
669 #t)))))))))
670
671 (define-public rust-1.23
672 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
673 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
674 (package
675 (inherit base-rust)
676 (arguments
677 (substitute-keyword-arguments (package-arguments base-rust)
678 ((#:phases phases)
679 `(modify-phases ,phases
680 (delete 'configure-archiver)
681 (delete 'remove-ar)
682 (add-after 'unpack 'dont-build-native
683 (lambda _
684 ;; XXX: Revisit this when we use gcc 6.
685 (substitute* "src/binaryen/CMakeLists.txt"
686 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
687 #t)))))))))
688
689 (define-public rust-1.24
690 (let ((base-rust
691 (rust-bootstrapped-package rust-1.23 "1.24.1"
692 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
693 (package
694 (inherit base-rust)
695 (arguments
696 (substitute-keyword-arguments (package-arguments base-rust)
697 ((#:phases phases)
698 `(modify-phases ,phases
699 (delete 'use-readelf-for-tests)
700 (replace 'patch-aarch64-test
701 (lambda* _
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"))
706 #t)))))))))
707
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
712 (let ((base-rust
713 (rust-bootstrapped-package rust-1.24 "1.25.0"
714 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")))
715 (package
716 (inherit base-rust)
717 (source
718 (origin
719 (inherit (package-source base-rust))
720 (snippet '(begin
721 (delete-file-recursively "src/jemalloc")
722 (delete-file-recursively "src/llvm")
723 (delete-file-recursively "src/llvm-emscripten")
724 #t))
725 (patches (search-patches
726 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
727 (arguments
728 (substitute-keyword-arguments (package-arguments base-rust)
729 ((#:phases phases)
730 `(modify-phases ,phases
731 (add-after 'patch-cargo-tests 'patch-cargo-index-update
732 (lambda _
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"))
736 #t))
737 (replace 'patch-aarch64-test
738 (lambda _
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")
748 #t))
749 (delete 'ignore-glibc-2.27-incompatible-test))))))))
750
751 (define-public rust-1.26
752 (let ((base-rust
753 (rust-bootstrapped-package rust-1.25 "1.26.2"
754 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv")))
755 (package
756 (inherit base-rust)
757 (source
758 (origin
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"))))
763 (inputs
764 (alist-replace "openssl" (list openssl)
765 (package-inputs base-rust)))
766 (arguments
767 (substitute-keyword-arguments (package-arguments base-rust)
768 ((#:phases phases)
769 `(modify-phases ,phases
770 ;; binaryen was replaced with LLD project from LLVM
771 (delete 'dont-build-native)
772 (replace 'check
773 (lambda* _
774 ;; Enable parallel execution.
775 (let ((parallel-job-spec
776 (string-append "-j" (number->string
777 (min 4
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
783 (lambda* _
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")
787 #t))
788 (replace 'patch-cargo-tests
789 (lambda* _
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
798 ;; i686-linux.
799 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
800 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
801
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"))
807 #t))
808 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
809 (lambda* _
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"))
815 #t))
816 (replace 'patch-cargo-index-update
817 (lambda* _
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"))
821 #t)))))))))
822
823 (define-public rust-1.27
824 (let ((base-rust
825 (rust-bootstrapped-package rust-1.26 "1.27.2"
826 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs")))
827 (package
828 (inherit base-rust)
829 (source
830 (origin
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"))))
836 (arguments
837 (substitute-keyword-arguments (package-arguments base-rust)
838 ((#:phases phases)
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"))
846 #t))
847 (add-after 'patch-cargo-tests 'disable-thinlto-test
848 (lambda* _
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"))
852 #t)))))))))
853
854 (define-public rust-1.28
855 (let ((base-rust
856 (rust-bootstrapped-package rust-1.27 "1.28.0"
857 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx")))
858 (package
859 (inherit base-rust)
860 (source
861 (origin
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"))))
867 (inputs
868 ;; Use LLVM 6.0
869 (alist-replace "llvm" (list llvm-6)
870 (package-inputs base-rust)))
871 (arguments
872 (substitute-keyword-arguments (package-arguments base-rust)
873 ((#:phases phases)
874 `(modify-phases ,phases
875 (add-after 'configure 'enable-codegen-tests
876 ;; Codegen tests should pass with llvm 6, so enable them.
877 (lambda* _
878 (substitute* "config.toml"
879 (("codegen-tests = false") ""))
880 #t))
881 (add-after 'patch-tests 'disable-amd64-avx-test
882 ;; That test would fail on x86_64 machines without avx.
883 (lambda* _
884 (substitute* "src/test/run-pass/issue-44056.rs"
885 (("only-x86_64") "ignore-test"))
886 #t))
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))))))))
891
892 (define-public rust-1.29
893 (let ((base-rust
894 (rust-bootstrapped-package rust-1.28 "1.29.2"
895 "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h")))
896 (package
897 (inherit base-rust)
898 (source
899 (origin
900 (inherit (package-source base-rust))
901 (patches (search-patches "rust-1.25-accept-more-detailed-gdb-lines.patch"
902 "rust-reproducible-builds.patch")))))))
903
904 (define-public rust-1.30
905 (let ((base-rust
906 (rust-bootstrapped-package rust-1.29 "1.30.1"
907 "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn")))
908 (package
909 (inherit base-rust)
910 (source
911 (origin
912 (inherit (package-source base-rust))
913 (snippet '(begin
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")
919 #t))))
920 (arguments
921 (substitute-keyword-arguments (package-arguments base-rust)
922 ((#:phases phases)
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\"")))
934 #t)))
935 (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
936 (lambda* _
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
942 ;; these for now
943 (("fn include") "#[ignore]\nfn include")
944 (("fn exclude") "#[ignore]\nfn exclude"))
945 #t))
946 ;; The test has been moved elsewhere.
947 (replace 'disable-amd64-avx-test
948 (lambda _
949 (substitute* "src/test/ui/run-pass/issues/issue-44056.rs"
950 (("only-x86_64") "ignore-test"))
951 #t)))))))))
952
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
958 move around."
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")))
972 #t)))
973
974 (define-public rust-1.31
975 (let ((base-rust
976 (rust-bootstrapped-package rust-1.30 "1.31.1"
977 "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli")))
978 (package
979 (inherit base-rust)
980 (arguments
981 (substitute-keyword-arguments (package-arguments base-rust)
982 ((#:phases phases)
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
989 (lambda _
990 (substitute* "src/test/ui/issues/issue-44056.rs"
991 (("only-x86_64") "ignore-test"))
992 #t))
993 (add-after 'patch-tests 'patch-process-docs-rev-cmd
994 (lambda* _
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"))
999 #t)))))))))
1000
1001 (define-public rust-1.32
1002 (let ((base-rust
1003 (rust-bootstrapped-package rust-1.31 "1.32.0"
1004 "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac")))
1005 (package
1006 (inherit base-rust)
1007 (source
1008 (origin
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")
1015 #t))
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"))))
1020 (inputs
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)))
1024 (arguments
1025 (substitute-keyword-arguments (package-arguments base-rust)
1026 ((#:phases phases)
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
1031 (lambda* _
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")
1037 #t))
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"))
1050 #t))
1051 ;; Remove no longer relevant steps
1052 (delete 'remove-flaky-test)
1053 (delete 'patch-aarch64-test))))))))
1054
1055 (define-public rust-1.33
1056 (let ((base-rust
1057 (rust-bootstrapped-package rust-1.32 "1.33.0"
1058 "152x91mg7bz4ygligwjb05fgm1blwy2i70s2j03zc9jiwvbsh0as")))
1059 (package
1060 (inherit base-rust)
1061 (source
1062 (origin
1063 (inherit (package-source base-rust))
1064 (patches '())
1065 (patch-flags '("-p1"))))
1066 (inputs
1067 ;; Upgrade to jemalloc@5.1.0
1068 (alist-replace "jemalloc" (list jemalloc)
1069 (package-inputs base-rust)))
1070 (arguments
1071 (substitute-keyword-arguments (package-arguments base-rust)
1072 ((#:phases phases)
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")
1082 #t)))))))))
1083
1084 (define-public rust-1.34
1085 (let ((base-rust
1086 (rust-bootstrapped-package rust-1.33 "1.34.1"
1087 "19s09k7y5j6g3y4d2rk6kg9pvq6ml94c49w6b72dmq8p9lk8bixh")))
1088 (package
1089 (inherit base-rust)
1090 (source
1091 (origin
1092 (inherit (package-source base-rust))
1093 (snippet '(begin
1094 (delete-file-recursively "src/llvm-emscripten")
1095 (delete-file-recursively "src/llvm-project")
1096 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1097 #t)))))))
1098
1099 (define-public rust-1.35
1100 (let ((base-rust
1101 (rust-bootstrapped-package rust-1.34 "1.35.0"
1102 "0bbizy6b7002v1rdhrxrf5gijclbyizdhkglhp81ib3bf5x66kas")))
1103 (package
1104 (inherit base-rust)
1105 (inputs
1106 (alist-replace "llvm" (list llvm-8)
1107 (package-inputs base-rust)))
1108 (arguments
1109 (substitute-keyword-arguments (package-arguments base-rust)
1110 ((#:phases phases)
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
1117 (lambda* _
1118 (substitute* "src/tools/tidy/src/main.rs"
1119 (("bins::check") "//bins::check"))
1120 #t)))))))))
1121
1122 (define-public rust-1.36
1123 (let ((base-rust
1124 (rust-bootstrapped-package rust-1.35 "1.36.0"
1125 "06xv2p6zq03lidr0yaf029ii8wnjjqa894nkmrm6s0rx47by9i04")))
1126 (package
1127 (inherit base-rust)
1128 (arguments
1129 (substitute-keyword-arguments (package-arguments base-rust)
1130 ((#:phases phases)
1131 `(modify-phases ,phases
1132 (delete 'patch-process-docs-rev-cmd))))))))
1133
1134 (define-public rust-1.37
1135 (let ((base-rust
1136 (rust-bootstrapped-package rust-1.36 "1.37.0"
1137 "1hrqprybhkhs6d9b5pjskfnc5z9v2l2gync7nb39qjb5s0h703hj")))
1138 (package
1139 (inherit base-rust)
1140 (arguments
1141 (substitute-keyword-arguments (package-arguments base-rust)
1142 ((#:phases phases)
1143 `(modify-phases ,phases
1144 (add-before 'configure 'configure-cargo-home
1145 (lambda _
1146 (let ((cargo-home (string-append (getcwd) "/.cargo")))
1147 (mkdir-p cargo-home)
1148 (setenv "CARGO_HOME" cargo-home)
1149 #t))))))))))
1150
1151 (define-public rust-1.38
1152 (let ((base-rust
1153 (rust-bootstrapped-package rust-1.37 "1.38.0"
1154 "101dlpsfkq67p0hbwx4acqq6n90dj4bbprndizpgh1kigk566hk4")))
1155 (package
1156 (inherit base-rust)
1157 (inputs
1158 (alist-replace "llvm" (list llvm-9)
1159 (package-inputs base-rust)))
1160 (arguments
1161 (substitute-keyword-arguments (package-arguments base-rust)
1162 ((#:phases phases)
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
1168 (lambda _
1169 (substitute* "src/test/ui/command-uid-gid.rs"
1170 (("/bin/sh") (which "sh"))
1171 (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
1172 #t)))))))))
1173
1174 (define-public rust-1.39
1175 (let ((base-rust
1176 (rust-bootstrapped-package rust-1.38 "1.39.0"
1177 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
1178 (package
1179 (inherit base-rust)
1180 (arguments
1181 (substitute-keyword-arguments (package-arguments base-rust)
1182 ((#:phases phases)
1183 `(modify-phases ,phases
1184 (replace 'patch-cargo-checksums
1185 ;; The Cargo.lock format changed.
1186 (lambda* _
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")
1192 #t)))))))))
1193
1194 (define-public rust-1.40
1195 (let ((base-rust
1196 (rust-bootstrapped-package rust-1.39 "1.40.0"
1197 "1ba9llwhqm49w7sz3z0gqscj039m53ky9wxzhaj11z6yg1ah15yx")))
1198 (package
1199 (inherit base-rust)
1200 (source
1201 (origin
1202 (inherit (package-source base-rust))
1203 ;; llvm-emscripten is no longer bundled, as that codegen backend
1204 ;; got removed.
1205 (snippet '(begin
1206 (delete-file-recursively "src/llvm-project")
1207 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1208 #t))))
1209 (arguments
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)
1222 ((#:phases phases)
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
1231 ;; anyway.
1232 ;;
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
1237 (lambda _
1238 (substitute* "src/bootstrap/builder.rs"
1239 (("^.*::Tidy,") ""))
1240 #t))
1241 ;; TODO(rebuild-rust): Adapt the find-files approach for
1242 ;; earlier testsuite patches.
1243 (replace 'patch-command-uid-gid-test
1244 (lambda _
1245 (match (find-files "src/test" "command-uid-gid\\.rs")
1246 ((file)
1247 (substitute* file
1248 (("/bin/sh") (which "sh")))))
1249 #t))
1250 (replace 'patch-command-exec-tests
1251 ,(patch-command-exec-tests-phase
1252 '(match (find-files "src/test" "command-exec\\.rs")
1253 ((file) file))))
1254 ;; The test got removed in commit 000fe63b6fc57b09828930cacbab20c2ee6e6d15
1255 ;; "Remove painful test that is not pulling its weight"
1256 (delete 'remove-unsupported-tests)))))))))
1257
1258 (define-public rust-1.41
1259 (let ((base-rust
1260 (rust-bootstrapped-package rust-1.40 "1.41.1"
1261 "0ws5x0fxv57fyllsa6025h3q6j9v3m8nb3syl4x0hgkddq0kvj9q")))
1262 (package
1263 (inherit base-rust)
1264 (arguments
1265 (substitute-keyword-arguments (package-arguments base-rust)
1266 ((#:validate-runpath? _) #t))))))
1267
1268 (define-public rust-1.42
1269 (rust-bootstrapped-package rust-1.41 "1.42.0"
1270 "0x9lxs82may6c0iln0b908cxyn1cv7h03n5cmbx3j1bas4qzks6j"))
1271
1272 (define-public rust-1.43
1273 (rust-bootstrapped-package rust-1.42 "1.43.0"
1274 "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
1275
1276 (define-public rust-1.44
1277 (rust-bootstrapped-package rust-1.43 "1.44.1"
1278 "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
1279
1280 (define-public rust-1.45
1281 (let ((base-rust
1282 (rust-bootstrapped-package rust-1.44 "1.45.2"
1283 "0273a1g3f59plyi1n0azf21qjzwml1yqdnj5z472crz37qggr8xp")))
1284 (package
1285 (inherit base-rust)
1286 (source
1287 (origin
1288 (inherit (package-source base-rust))
1289 (patches (search-patches "rust-1.45-linker-locale.patch"))))
1290 (inputs
1291 (alist-replace "llvm" (list llvm-10)
1292 (package-inputs base-rust)))
1293 (arguments
1294 (substitute-keyword-arguments (package-arguments base-rust)
1295 ((#:phases phases)
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
1303 (lambda _
1304 (with-directory-excursion "src/test/ui/parser/shebang"
1305 (delete-file "shebang-doc-comment.rs")
1306 (delete-file "sneaky-attrib.rs")
1307 #t)))
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
1311 (lambda _
1312 (substitute* "src/tools/cargo/tests/testsuite/freshness.rs"
1313 (("fn linking_interrupted" all)
1314 (string-append "#[ignore] " all)))
1315 #t)))))))))
1316
1317 (define-public rust-1.46
1318 (rust-bootstrapped-package rust-1.45 "1.46.0"
1319 "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))
1320
1321 ;; TODO(staging): Bump this variable to the latest packaged rust.
1322 (define-public rust rust-1.45)