gnu: rust-1.38: Build with llvm-9.
[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 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
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.
19 ;;;
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.
24 ;;;
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/>.
27
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))
58
59 ;; This is the hash for the empty file, and the reason it's relevant is not
60 ;; the most obvious.
61 ;;
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.
64 ;;
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
70 ;; during the build.)
71 ;;
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.
75 ;;
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")
87
88 (define* (nix-system->gnu-triplet-for-rust
89 #:optional (system (%current-system)))
90 (match 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))))
97
98 (define* (rust-uri version #:key (dist "static"))
99 (string-append "https://" dist ".rust-lang.org/dist/"
100 "rustc-" version "-src.tar.gz"))
101
102 (define* (rust-bootstrapped-package base-rust version checksum)
103 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
104 (package
105 (inherit base-rust)
106 (version version)
107 (source
108 (origin
109 (inherit (package-source base-rust))
110 (uri (rust-uri version))
111 (sha256 (base32 checksum))))
112 (native-inputs
113 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
114 (alist-replace "rustc-bootstrap" (list base-rust)
115 (package-native-inputs base-rust))))))
116
117 (define-public mrustc
118 (let ((rustc-version "1.19.0"))
119 (package
120 (name "mrustc")
121 (version "0.9")
122 (source (origin
123 (method git-fetch)
124 (uri (git-reference
125 (url "https://github.com/thepowersgang/mrustc")
126 (commit (string-append "v" version))))
127 (file-name (git-file-name name version))
128 (sha256
129 (base32
130 "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2"))))
131 (outputs '("out" "cargo"))
132 (build-system gnu-build-system)
133 (inputs
134 `(("zlib" ,zlib)))
135 (native-inputs
136 `(("bison" ,bison)
137 ("flex" ,flex)
138 ;; Required for the libstd sources.
139 ("rustc" ,(package-source rust-1.19))))
140 (arguments
141 `(#:test-target "test"
142 #:make-flags
143 (list ,(string-append "RUSTC_TARGET="
144 (or (%current-target-system)
145 (nix-system->gnu-triplet-for-rust))))
146 #:phases
147 (modify-phases %standard-phases
148 (add-after 'unpack 'patch-date
149 (lambda _
150 (substitute* "Makefile"
151 (("shell date") "shell date -d @1"))
152 (substitute* "run_rustc/Makefile"
153 (("[$]Vtime ") "$V "))
154 #t))
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
160 "-src.patch"))
161 (chdir "..")
162 (setenv "RUSTC_VERSION" ,rustc-version)
163 (setenv "MRUSTC_TARGET_VER"
164 ,(version-major+minor rustc-version))
165 (setenv "OUTDIR_SUF" "")
166 #t))
167 (replace 'configure
168 (lambda* (#:key inputs #:allow-other-keys)
169 (setenv "CC" (string-append (assoc-ref inputs "gcc")
170 "/bin/gcc"))
171 (setenv "CXX" (string-append (assoc-ref inputs "gcc")
172 "/bin/g++"))
173 #t))
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)))
185 (replace 'install
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)
202 (mkdir-p bin)
203 (mkdir-p tools-bin)
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)
208 (mkdir-p run_rustc)
209 (copy-file "run_rustc/Makefile"
210 (string-append run_rustc "/Makefile"))
211 #t))))))
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")
216 ;; Dual licensed.
217 (license (list license:asl2.0 license:expat)))))
218
219 (define rust-1.19
220 (package
221 (name "rust")
222 (version "1.19.0")
223 (source
224 (origin
225 (method url-fetch)
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)
234 (arguments
235 `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
236 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
237 #:phases
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")
248 #t))
249 (add-after 'unpack 'patch-cargo-tomls
250 (lambda* (#:key inputs outputs #:allow-other-keys)
251 (substitute* "src/librustc_errors/Cargo.toml"
252 (("[[]dependencies[]]") "
253 [dependencies]
254 term = \"0.4.4\"
255 "))
256 (substitute* "src/librustc/Cargo.toml"
257 (("[[]dependencies[]]") "
258 [dependencies]
259 getopts = { path = \"../libgetopts\" }
260 "))
261 (substitute* "src/librustdoc/Cargo.toml"
262 (("[[]dependencies[]]") "
263 [dependencies]
264 test = { path = \"../libtest\" }
265 "))
266 #t))
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
273 ;; fail otherwise.
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)]
282 #[ignore]
283 fn test_process_mask"))
284 #t)))
285 (add-after 'patch-tests 'patch-aarch64-test
286 (lambda* _
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"))
291 #t))
292 (add-after 'patch-tests 'use-readelf-for-tests
293 (lambda* _
294 ;; nm doesn't recognize the file format because of the
295 ;; nonstandard sections used by the Rust compiler, but readelf
296 ;; ignores them.
297 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
298 (("\tnm ")
299 "\treadelf -c "))
300 #t))
301 (add-after 'patch-tests 'remove-unsupported-tests
302 (lambda* _
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")
306 #t))
307 (add-after 'patch-source-shebangs 'patch-cargo-checksums
308 (lambda* _
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")
314 #t))
315 ;; This phase is overridden by newer versions.
316 (replace 'configure
317 (const #t))
318 ;; This phase is overridden by newer versions.
319 (replace 'build
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.
330 (mkdir-p "output")
331 ;; mrustc 0.9 doesn't check the search paths for crates anymore.
332 (copy-recursively (string-append rustc-bootstrap "/lib/mrust")
333 "output")
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")
338 "-j" "1")
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"
348 "-L" "output/"
349 "-L" (string-append rustc-bootstrap "/lib/mrust")
350 "-j" "1")
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
357 ;; dependencies.
358 (mkdir-p "output/target-libs")
359 (for-each (match-lambda
360 ((name . flags)
361 (write name)
362 (newline)
363 (apply invoke
364 "output/rustc-build/rustc"
365 "-C" (string-append "linker="
366 (getenv "CC"))
367 ;; Required for libterm.
368 "-Z" "force-unstable-if-unmarked"
369 "-L" "output/target-libs"
370 (string-append "src/" name "/lib.rs")
371 "-o"
372 (string-append "output/target-libs/"
373 (car (string-split name #\/))
374 ".rlib")
375 flags)))
376 '(("libcore")
377 ("libstd_unicode")
378 ("liballoc")
379 ("libcollections")
380 ("librand")
381 ("liblibc/src" "--cfg" "stdbuild")
382 ("libunwind" "-l" "gcc_s")
383 ("libcompiler_builtins")
384 ("liballoc_system")
385 ("libpanic_unwind")
386 ;; Uses "cc" to link.
387 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
388 ("libarena")
389
390 ;; Test dependencies:
391
392 ("libgetopts")
393 ("libterm")
394 ("libtest")))
395 #t)))
396 ;; This phase is overridden by newer versions.
397 (replace 'check
398 (const #t))
399 ;; This phase is overridden by newer versions.
400 (replace 'install
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
405 (%current-system))))
406 (out-libs (string-append out "/lib/rustlib/"
407 target-system "/lib")))
408 ;(setenv "CFG_PREFIX" out)
409 (mkdir-p out-libs)
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")
417 "/bin")))
418 #t)))))
419 (build-system gnu-build-system)
420 (native-inputs
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"
432 ("which" ,which)))
433 (inputs
434 `(("jemalloc" ,jemalloc-4.5.0)
435 ("llvm" ,llvm-3.9.1)
436 ("openssl" ,openssl-1.0)
437 ("libssh2" ,libssh2) ; For "cargo"
438 ("libcurl" ,curl))) ; For "cargo"
439
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>).
443 (native-search-paths
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")))))
453
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")
458 ;; Dual licensed.
459 (license (list license:asl2.0 license:expat))))
460
461 (define-public rust-1.20
462 (let ((base-rust
463 (rust-bootstrapped-package rust-1.19 "1.20.0"
464 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
465 (package
466 (inherit base-rust)
467 (source
468 (origin
469 (inherit (package-source base-rust))
470 (snippet '(begin
471 (delete-file-recursively "src/jemalloc")
472 (delete-file-recursively "src/llvm")
473 #t))
474 (patches '())))
475 (native-inputs
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
484 ;; rust-1.19 here.
485 (properties '((timeout . 72000) ;20 hours
486 (max-silent-time . 18000))) ;5 hours (for armel)
487 (arguments
488 (substitute-keyword-arguments (package-arguments rust-1.19)
489 ((#:phases phases)
490 `(modify-phases ,phases
491 (add-after 'patch-tests 'patch-cargo-tests
492 (lambda _
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
501 ;; i686-linux.
502 (substitute* "src/tools/cargo/tests/test.rs"
503 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
504
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"))
511 #t))
512 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
513 ;; https://github.com/rust-lang/rust/issues/47863
514 (lambda _
515 (substitute* "src/test/run-pass/out-of-stack.rs"
516 (("// ignore-android") "// ignore-test\n// ignore-android"))
517 #t))
518 (replace 'configure
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"
531 (lambda (port)
532 (display (string-append "
533 [llvm]
534 [build]
535 cargo = \"" cargo "/bin/cargo" "\"
536 rustc = \"" rustc "/bin/rustc" "\"
537 docs = true
538 python = \"" python "/bin/python2" "\"
539 gdb = \"" gdb "/bin/gdb" "\"
540 vendor = true
541 submodules = false
542 [install]
543 prefix = \"" out "\"
544 docdir = \"" doc "/share/doc/rust" "\"
545 sysconfdir = \"etc\"
546 [rust]
547 default-linker = \"" gcc "/bin/gcc" "\"
548 channel = \"stable\"
549 rpath = true
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" "\"
560 [dist]
561 ") port)))
562 #t)))
563 (add-after 'configure 'provide-cc
564 (lambda* (#:key inputs #:allow-other-keys)
565 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
566 "/tmp/cc")
567 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
568 #t))
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")
577 "/bin/ar\"")))
578 #t))
579 (delete 'patch-cargo-tomls)
580 (add-before 'build 'reset-timestamps-after-changes
581 (lambda* _
582 (for-each
583 (lambda (filename)
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))
588 #t))
589 (replace 'build
590 (lambda* _
591 (invoke "./x.py" "build")
592 (invoke "./x.py" "build" "src/tools/cargo")))
593 (replace 'check
594 (lambda* _
595 ;; Disable parallel execution to prevent EAGAIN errors when
596 ;; running tests.
597 (invoke "./x.py" "-j1" "test" "-vv")
598 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
599 #t))
600 (replace 'install
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)))
612
613 (let ((out (assoc-ref outputs "out"))
614 (cargo-out (assoc-ref outputs "cargo")))
615 (for-each
616 (lambda (file) (delete-manifest-file out file))
617 '("install.log"
618 "manifest-rust-docs"
619 "manifest-rust-std-x86_64-unknown-linux-gnu"
620 "manifest-rustc"))
621 (for-each
622 (lambda (file) (delete-manifest-file cargo-out file))
623 '("install.log"
624 "manifest-cargo"))
625 #t)))
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"))))
635 #t))))))))))
636
637 (define-public rust-1.21
638 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
639 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
640 (package
641 (inherit base-rust)
642 (arguments
643 (substitute-keyword-arguments (package-arguments base-rust)
644 ((#:phases phases)
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"
650 (("^ar =.*") "\n"))
651 #t)))))))))
652
653 (define-public rust-1.22
654 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
655 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
656 (package
657 (inherit base-rust)
658 (arguments
659 (substitute-keyword-arguments (package-arguments base-rust)
660 ((#:phases phases)
661 `(modify-phases ,phases
662 (add-after 'unpack 'remove-flaky-test
663 (lambda _
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"))
667 #t)))))))))
668
669 (define-public rust-1.23
670 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
671 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
672 (package
673 (inherit base-rust)
674 (arguments
675 (substitute-keyword-arguments (package-arguments base-rust)
676 ((#:phases phases)
677 `(modify-phases ,phases
678 (delete 'configure-archiver)
679 (delete 'remove-ar)
680 (add-after 'unpack 'dont-build-native
681 (lambda _
682 ;; XXX: Revisit this when we use gcc 6.
683 (substitute* "src/binaryen/CMakeLists.txt"
684 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
685 #t)))))))))
686
687 (define-public rust-1.24
688 (let ((base-rust
689 (rust-bootstrapped-package rust-1.23 "1.24.1"
690 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
691 (package
692 (inherit base-rust)
693 (arguments
694 (substitute-keyword-arguments (package-arguments base-rust)
695 ((#:phases phases)
696 `(modify-phases ,phases
697 (delete 'use-readelf-for-tests)
698 (replace 'patch-aarch64-test
699 (lambda* _
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"))
704 #t)))))))))
705
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
710 (let ((base-rust
711 (rust-bootstrapped-package rust-1.24 "1.25.0"
712 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")))
713 (package
714 (inherit base-rust)
715 (source
716 (origin
717 (inherit (package-source base-rust))
718 (snippet '(begin
719 (delete-file-recursively "src/jemalloc")
720 (delete-file-recursively "src/llvm")
721 (delete-file-recursively "src/llvm-emscripten")
722 #t))
723 (patches (search-patches
724 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
725 (arguments
726 (substitute-keyword-arguments (package-arguments base-rust)
727 ((#:phases phases)
728 `(modify-phases ,phases
729 (add-after 'patch-cargo-tests 'patch-cargo-index-update
730 (lambda _
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"))
734 #t))
735 (replace 'patch-aarch64-test
736 (lambda _
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")
746 #t))
747 (delete 'ignore-glibc-2.27-incompatible-test))))))))
748
749 (define-public rust-1.26
750 (let ((base-rust
751 (rust-bootstrapped-package rust-1.25 "1.26.2"
752 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv")))
753 (package
754 (inherit base-rust)
755 (source
756 (origin
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"))))
761 (arguments
762 (substitute-keyword-arguments (package-arguments base-rust)
763 ((#:phases phases)
764 `(modify-phases ,phases
765 ;; binaryen was replaced with LLD project from LLVM
766 (delete 'dont-build-native)
767 (replace 'check
768 (lambda* _
769 ;; Enable parallel execution.
770 (let ((parallel-job-spec
771 (string-append "-j" (number->string
772 (min 4
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
778 (lambda* _
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")
782 #t))
783 (replace 'patch-cargo-tests
784 (lambda* _
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
793 ;; i686-linux.
794 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
795 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
796
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"))
802 #t))
803 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
804 (lambda* _
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"))
810 #t))
811 (replace 'patch-cargo-index-update
812 (lambda* _
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"))
816 #t)))))))))
817
818 (define-public rust-1.27
819 (let ((base-rust
820 (rust-bootstrapped-package rust-1.26 "1.27.2"
821 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs")))
822 (package
823 (inherit base-rust)
824 (source
825 (origin
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"))))
831 (arguments
832 (substitute-keyword-arguments (package-arguments base-rust)
833 ((#:phases phases)
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"))
841 #t))
842 (add-after 'patch-cargo-tests 'disable-thinlto-test
843 (lambda* _
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"))
847 #t)))))))))
848
849 (define-public rust-1.28
850 (let ((base-rust
851 (rust-bootstrapped-package rust-1.27 "1.28.0"
852 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx")))
853 (package
854 (inherit base-rust)
855 (source
856 (origin
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"))))
862 (inputs
863 ;; Use LLVM 6.0
864 (alist-replace "llvm" (list llvm-6)
865 (package-inputs base-rust)))
866 (arguments
867 (substitute-keyword-arguments (package-arguments base-rust)
868 ((#:phases phases)
869 `(modify-phases ,phases
870 (add-after 'configure 'enable-codegen-tests
871 ;; Codegen tests should pass with llvm 6, so enable them.
872 (lambda* _
873 (substitute* "config.toml"
874 (("codegen-tests = false") ""))
875 #t))
876 (add-after 'patch-tests 'disable-amd64-avx-test
877 ;; That test would fail on x86_64 machines without avx.
878 (lambda* _
879 (substitute* "src/test/run-pass/issue-44056.rs"
880 (("only-x86_64") "ignore-test"))
881 #t))
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))))))))
886
887 (define-public rust-1.29
888 (let ((base-rust
889 (rust-bootstrapped-package rust-1.28 "1.29.2"
890 "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h")))
891 (package
892 (inherit base-rust)
893 (source
894 (origin
895 (inherit (package-source base-rust))
896 (patches (search-patches "rust-1.25-accept-more-detailed-gdb-lines.patch"
897 "rust-reproducible-builds.patch")))))))
898
899 (define-public rust-1.30
900 (let ((base-rust
901 (rust-bootstrapped-package rust-1.29 "1.30.1"
902 "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn")))
903 (package
904 (inherit base-rust)
905 (source
906 (origin
907 (inherit (package-source base-rust))
908 (snippet '(begin
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")
914 #t))))
915 (arguments
916 (substitute-keyword-arguments (package-arguments base-rust)
917 ((#:phases phases)
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\"")))
929 #t)))
930 (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
931 (lambda* _
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
937 ;; these for now
938 (("fn include") "#[ignore]\nfn include")
939 (("fn exclude") "#[ignore]\nfn exclude"))
940 #t))
941 ;; The test has been moved elsewhere.
942 (replace 'disable-amd64-avx-test
943 (lambda _
944 (substitute* "src/test/ui/run-pass/issues/issue-44056.rs"
945 (("only-x86_64") "ignore-test"))
946 #t)))))))))
947
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
953 move around."
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")))
967 #t)))
968
969 (define-public rust-1.31
970 (let ((base-rust
971 (rust-bootstrapped-package rust-1.30 "1.31.1"
972 "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli")))
973 (package
974 (inherit base-rust)
975 (arguments
976 (substitute-keyword-arguments (package-arguments base-rust)
977 ((#:phases phases)
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
984 (lambda _
985 (substitute* "src/test/ui/issues/issue-44056.rs"
986 (("only-x86_64") "ignore-test"))
987 #t))
988 (add-after 'patch-tests 'patch-process-docs-rev-cmd
989 (lambda* _
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"))
994 #t)))))))))
995
996 (define-public rust-1.32
997 (let ((base-rust
998 (rust-bootstrapped-package rust-1.31 "1.32.0"
999 "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac")))
1000 (package
1001 (inherit base-rust)
1002 (source
1003 (origin
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")
1010 #t))
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"))))
1015 (inputs
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)))
1019 (arguments
1020 (substitute-keyword-arguments (package-arguments base-rust)
1021 ((#:phases phases)
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
1026 (lambda* _
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")
1032 #t))
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"))
1045 #t))
1046 ;; Remove no longer relevant steps
1047 (delete 'remove-flaky-test)
1048 (delete 'patch-aarch64-test))))))))
1049
1050 (define-public rust-1.33
1051 (let ((base-rust
1052 (rust-bootstrapped-package rust-1.32 "1.33.0"
1053 "152x91mg7bz4ygligwjb05fgm1blwy2i70s2j03zc9jiwvbsh0as")))
1054 (package
1055 (inherit base-rust)
1056 (source
1057 (origin
1058 (inherit (package-source base-rust))
1059 (patches '())
1060 (patch-flags '("-p1"))))
1061 (inputs
1062 ;; Upgrade to jemalloc@5.1.0
1063 (alist-replace "jemalloc" (list jemalloc)
1064 (package-inputs base-rust)))
1065 (arguments
1066 (substitute-keyword-arguments (package-arguments base-rust)
1067 ((#:phases phases)
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")
1077 #t)))))))))
1078
1079 (define-public rust-1.34
1080 (let ((base-rust
1081 (rust-bootstrapped-package rust-1.33 "1.34.1"
1082 "19s09k7y5j6g3y4d2rk6kg9pvq6ml94c49w6b72dmq8p9lk8bixh")))
1083 (package
1084 (inherit base-rust)
1085 (source
1086 (origin
1087 (inherit (package-source base-rust))
1088 (snippet '(begin
1089 (delete-file-recursively "src/llvm-emscripten")
1090 (delete-file-recursively "src/llvm-project")
1091 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1092 #t)))))))
1093
1094 (define-public rust-1.35
1095 (let ((base-rust
1096 (rust-bootstrapped-package rust-1.34 "1.35.0"
1097 "0bbizy6b7002v1rdhrxrf5gijclbyizdhkglhp81ib3bf5x66kas")))
1098 (package
1099 (inherit base-rust)
1100 (inputs
1101 (alist-replace "llvm" (list llvm-8)
1102 (package-inputs base-rust)))
1103 (arguments
1104 (substitute-keyword-arguments (package-arguments base-rust)
1105 ((#:phases phases)
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
1112 (lambda* _
1113 (substitute* "src/tools/tidy/src/main.rs"
1114 (("bins::check") "//bins::check"))
1115 #t)))))))))
1116
1117 (define-public rust-1.36
1118 (let ((base-rust
1119 (rust-bootstrapped-package rust-1.35 "1.36.0"
1120 "06xv2p6zq03lidr0yaf029ii8wnjjqa894nkmrm6s0rx47by9i04")))
1121 (package
1122 (inherit base-rust)
1123 (arguments
1124 (substitute-keyword-arguments (package-arguments base-rust)
1125 ((#:phases phases)
1126 `(modify-phases ,phases
1127 (delete 'patch-process-docs-rev-cmd))))))))
1128
1129 (define-public rust-1.37
1130 (let ((base-rust
1131 (rust-bootstrapped-package rust-1.36 "1.37.0"
1132 "1hrqprybhkhs6d9b5pjskfnc5z9v2l2gync7nb39qjb5s0h703hj")))
1133 (package
1134 (inherit base-rust)
1135 (arguments
1136 (substitute-keyword-arguments (package-arguments base-rust)
1137 ((#:phases phases)
1138 `(modify-phases ,phases
1139 (add-before 'configure 'configure-cargo-home
1140 (lambda _
1141 (let ((cargo-home (string-append (getcwd) "/.cargo")))
1142 (mkdir-p cargo-home)
1143 (setenv "CARGO_HOME" cargo-home)
1144 #t))))))))))
1145
1146 (define-public rust-1.38
1147 (let ((base-rust
1148 (rust-bootstrapped-package rust-1.37 "1.38.0"
1149 "101dlpsfkq67p0hbwx4acqq6n90dj4bbprndizpgh1kigk566hk4")))
1150 (package
1151 (inherit base-rust)
1152 (inputs
1153 (alist-replace "llvm" (list llvm-9)
1154 (package-inputs base-rust)))
1155 (arguments
1156 (substitute-keyword-arguments (package-arguments base-rust)
1157 ((#:phases phases)
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
1163 (lambda _
1164 (substitute* "src/test/ui/command-uid-gid.rs"
1165 (("/bin/sh") (which "sh"))
1166 (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
1167 #t)))))))))
1168
1169 (define-public rust-1.39
1170 (let ((base-rust
1171 (rust-bootstrapped-package rust-1.38 "1.39.0"
1172 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
1173 (package
1174 (inherit base-rust)
1175 (arguments
1176 (substitute-keyword-arguments (package-arguments base-rust)
1177 ((#:phases phases)
1178 `(modify-phases ,phases
1179 (replace 'patch-cargo-checksums
1180 ;; The Cargo.lock format changed.
1181 (lambda* _
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")
1187 #t)))))))))
1188
1189 (define-public rust-1.40
1190 (let ((base-rust
1191 (rust-bootstrapped-package rust-1.39 "1.40.0"
1192 "1ba9llwhqm49w7sz3z0gqscj039m53ky9wxzhaj11z6yg1ah15yx")))
1193 (package
1194 (inherit base-rust)
1195 (source
1196 (origin
1197 (inherit (package-source base-rust))
1198 ;; llvm-emscripten is no longer bundled, as that codegen backend
1199 ;; got removed.
1200 (snippet '(begin
1201 (delete-file-recursively "src/llvm-project")
1202 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1203 #t))))
1204 (arguments
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)
1217 ((#:phases phases)
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
1226 ;; anyway.
1227 ;;
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
1232 (lambda _
1233 (substitute* "src/bootstrap/builder.rs"
1234 (("^.*::Tidy,") ""))
1235 #t))
1236 ;; TODO(rebuild-rust): Adapt the find-files approach for
1237 ;; earlier testsuite patches.
1238 (replace 'patch-command-uid-gid-test
1239 (lambda _
1240 (match (find-files "src/test" "command-uid-gid\\.rs")
1241 ((file)
1242 (substitute* file
1243 (("/bin/sh") (which "sh")))))
1244 #t))
1245 (replace 'patch-command-exec-tests
1246 ,(patch-command-exec-tests-phase
1247 '(match (find-files "src/test" "command-exec\\.rs")
1248 ((file) file))))
1249 ;; The test got removed in commit 000fe63b6fc57b09828930cacbab20c2ee6e6d15
1250 ;; "Remove painful test that is not pulling its weight"
1251 (delete 'remove-unsupported-tests)))))))))
1252
1253 (define-public rust-1.41
1254 (let ((base-rust
1255 (rust-bootstrapped-package rust-1.40 "1.41.1"
1256 "0ws5x0fxv57fyllsa6025h3q6j9v3m8nb3syl4x0hgkddq0kvj9q")))
1257 (package
1258 (inherit base-rust)
1259 (arguments
1260 (substitute-keyword-arguments (package-arguments base-rust)
1261 ((#:validate-runpath? _) #t))))))
1262
1263 (define-public rust-1.42
1264 (rust-bootstrapped-package rust-1.41 "1.42.0"
1265 "0x9lxs82may6c0iln0b908cxyn1cv7h03n5cmbx3j1bas4qzks6j"))
1266
1267 (define-public rust-1.43
1268 (rust-bootstrapped-package rust-1.42 "1.43.0"
1269 "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
1270
1271 (define-public rust-1.44
1272 (rust-bootstrapped-package rust-1.43 "1.44.1"
1273 "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
1274
1275 (define-public rust-1.45
1276 (let ((base-rust
1277 (rust-bootstrapped-package rust-1.44 "1.45.0"
1278 "0z6dh0yd3fcm3qh960wi4s6fa6pxz9mh77psycsqfkkx5kqra15s")))
1279 (package
1280 (inherit base-rust)
1281 (source
1282 (origin
1283 (inherit (package-source base-rust))
1284 (patches (search-patches "rust-1.45-linker-locale.patch"))))
1285 (inputs
1286 (alist-replace "llvm" (list llvm-10)
1287 (package-inputs base-rust)))
1288 (arguments
1289 (substitute-keyword-arguments (package-arguments base-rust)
1290 ((#:phases phases)
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
1298 (lambda _
1299 (with-directory-excursion "src/test/ui/parser/shebang"
1300 (delete-file "shebang-doc-comment.rs")
1301 (delete-file "sneaky-attrib.rs")
1302 #t)))
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
1306 (lambda _
1307 (substitute* "src/tools/cargo/tests/testsuite/freshness.rs"
1308 (("fn linking_interrupted" all)
1309 (string-append "#[ignore] " all)))
1310 #t)))))))))
1311
1312 ;; TODO(staging): Bump this variable to the latest packaged rust.
1313 (define-public rust rust-1.45)