installer: Open manual in the selected language on tty2.
[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 ng0 <ng0@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 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 ;;;
12 ;;; This file is part of GNU Guix.
13 ;;;
14 ;;; GNU Guix is free software; you can redistribute it and/or modify it
15 ;;; under the terms of the GNU General Public License as published by
16 ;;; the Free Software Foundation; either version 3 of the License, or (at
17 ;;; your option) any later version.
18 ;;;
19 ;;; GNU Guix is distributed in the hope that it will be useful, but
20 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;;; GNU General Public License for more details.
23 ;;;
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26
27 (define-module (gnu packages rust)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages bison)
30 #:use-module (gnu packages bootstrap)
31 #:use-module (gnu packages cmake)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages curl)
34 #:use-module (gnu packages elf)
35 #:use-module (gnu packages flex)
36 #:use-module (gnu packages gcc)
37 #:use-module (gnu packages gdb)
38 #:use-module (gnu packages jemalloc)
39 #:use-module (gnu packages linux)
40 #:use-module (gnu packages llvm)
41 #:use-module (gnu packages pkg-config)
42 #:use-module (gnu packages python)
43 #:use-module (gnu packages ssh)
44 #:use-module (gnu packages tls)
45 #:use-module (gnu packages)
46 #:use-module (guix build-system cargo)
47 #:use-module (guix build-system gnu)
48 #:use-module (guix build-system trivial)
49 #:use-module (guix download)
50 #:use-module (guix git-download)
51 #:use-module ((guix licenses) #:prefix license:)
52 #:use-module (guix packages)
53 #:use-module ((guix build utils) #:select (alist-replace))
54 #:use-module (guix utils)
55 #:use-module (ice-9 match)
56 #:use-module (srfi srfi-26))
57
58 ;; This is the hash for the empty file, and the reason it's relevant is not
59 ;; the most obvious.
60 ;;
61 ;; The root of the problem is that Cargo keeps track of a file called
62 ;; Cargo.lock, that contains the hash of the tarball source of each dependency.
63 ;;
64 ;; However, tarball sources aren't handled well by Guix because of the need to
65 ;; patch shebangs in any helper scripts. This is why we use Cargo's vendoring
66 ;; capabilities, where instead of the tarball, a directory is provided in its
67 ;; place. (In the case of rustc, the source code already ships with vendored
68 ;; dependencies, but crates built with cargo-build-system undergo vendoring
69 ;; during the build.)
70 ;;
71 ;; To preserve the advantages of checksumming, vendored dependencies contain
72 ;; a file called .cargo-checksum.json, which contains the hash of the tarball,
73 ;; as well as the list of files in it, with the hash of each file.
74 ;;
75 ;; The patch-cargo-checksums phase of cargo-build-system runs after
76 ;; any Guix-specific patches to the vendored dependencies and regenerates the
77 ;; .cargo-checksum.json files, but it's hard to know the tarball checksum that
78 ;; should be written to the file - and taking care of any unhandled edge case
79 ;; would require rebuilding everything that depends on rust. This is why we lie,
80 ;; and say that the tarball has the hash of an empty file. It's not a problem
81 ;; because cargo-build-system removes the Cargo.lock file. We can't do that
82 ;; for rustc because of a quirk of its build system, so we modify the lock file
83 ;; to substitute the hash.
84 (define %cargo-reference-hash
85 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
86
87 (define* (nix-system->gnu-triplet-for-rust
88 #:optional (system (%current-system)))
89 (match system
90 ("x86_64-linux" "x86_64-unknown-linux-gnu")
91 ("i686-linux" "i686-unknown-linux-gnu")
92 ("armhf-linux" "armv7-unknown-linux-gnueabihf")
93 ("aarch64-linux" "aarch64-unknown-linux-gnu")
94 ("mips64el-linux" "mips64el-unknown-linux-gnuabi64")
95 (_ (nix-system->gnu-triplet system))))
96
97 (define* (rust-uri version #:key (dist "static"))
98 (string-append "https://" dist ".rust-lang.org/dist/"
99 "rustc-" version "-src.tar.gz"))
100
101 (define* (rust-bootstrapped-package base-rust version checksum)
102 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
103 (package
104 (inherit base-rust)
105 (version version)
106 (source
107 (origin
108 (inherit (package-source base-rust))
109 (uri (rust-uri version))
110 (sha256 (base32 checksum))))
111 (native-inputs
112 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
113 (alist-replace "rustc-bootstrap" (list base-rust)
114 (package-native-inputs base-rust))))))
115
116 (define-public mrustc
117 (let ((rustc-version "1.19.0"))
118 (package
119 (name "mrustc")
120 (version "0.9")
121 (source (origin
122 (method git-fetch)
123 (uri (git-reference
124 (url "https://github.com/thepowersgang/mrustc.git")
125 (commit (string-append "v" version))))
126 (file-name (git-file-name name version))
127 (sha256
128 (base32
129 "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2"))))
130 (outputs '("out" "cargo"))
131 (build-system gnu-build-system)
132 (inputs
133 `(("zlib" ,zlib)))
134 (native-inputs
135 `(("bison" ,bison)
136 ("flex" ,flex)
137 ;; Required for the libstd sources.
138 ("rustc" ,(package-source rust-1.19))))
139 (arguments
140 `(#:test-target "test"
141 #:make-flags
142 (list ,(string-append "RUSTC_TARGET="
143 (or (%current-target-system)
144 (nix-system->gnu-triplet-for-rust))))
145 #:phases
146 (modify-phases %standard-phases
147 (add-after 'unpack 'patch-date
148 (lambda _
149 (substitute* "Makefile"
150 (("shell date") "shell date -d @1"))
151 (substitute* "run_rustc/Makefile"
152 (("[$]Vtime ") "$V "))
153 #t))
154 (add-after 'patch-date 'unpack-target-compiler
155 (lambda* (#:key inputs outputs #:allow-other-keys)
156 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
157 (chdir ,(string-append "rustc-" rustc-version "-src"))
158 (invoke "patch" "-p0" ,(string-append "../rustc-" rustc-version
159 "-src.patch"))
160 (chdir "..")
161 (setenv "RUSTC_VERSION" ,rustc-version)
162 (setenv "MRUSTC_TARGET_VER"
163 ,(version-major+minor rustc-version))
164 (setenv "OUTDIR_SUF" "")
165 #t))
166 (replace 'configure
167 (lambda* (#:key inputs #:allow-other-keys)
168 (setenv "CC" (string-append (assoc-ref inputs "gcc")
169 "/bin/gcc"))
170 (setenv "CXX" (string-append (assoc-ref inputs "gcc")
171 "/bin/g++"))
172 #t))
173 (add-after 'build 'build-minicargo
174 (lambda* (#:key make-flags #:allow-other-keys)
175 ;; TODO: minicargo.mk: RUSTC_VERSION=$(RUSTC_VERSION) RUSTC_CHANNEL=$(RUSTC_SRC_TY) OUTDIR_SUF=$(OUTDIR_SUF)
176 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags)
177 (apply invoke "make" "-C" "tools/minicargo" make-flags)))
178 ;(add-after 'check 'check-locally
179 ; (lambda* (#:key make-flags #:allow-other-keys)
180 ; ;; The enum test wouldn't work otherwise.
181 ; ;; See <https://github.com/thepowersgang/mrustc/issues/137>.
182 ; (setenv "MRUSTC_TARGET_VER" ,(version-major+minor rustc-version))
183 ; (apply invoke "make" "local_tests" make-flags)))
184 (replace 'install
185 (lambda* (#:key inputs outputs #:allow-other-keys)
186 (let* ((out (assoc-ref outputs "out"))
187 (bin (string-append out "/bin"))
188 (tools-bin (string-append out "/tools/bin"))
189 (cargo-out (assoc-ref outputs "cargo"))
190 (cargo-bin (string-append cargo-out "/bin"))
191 (lib (string-append out "/lib"))
192 (lib/rust (string-append lib "/mrust"))
193 (gcc (assoc-ref inputs "gcc"))
194 (run_rustc (string-append out
195 "/share/mrustc/run_rustc")))
196 ;; These files are not reproducible.
197 (for-each delete-file (find-files "output" "\\.txt$"))
198 ;(delete-file-recursively "output/local_tests")
199 (mkdir-p (dirname lib/rust))
200 (copy-recursively "output" lib/rust)
201 (mkdir-p bin)
202 (mkdir-p tools-bin)
203 (install-file "bin/mrustc" bin)
204 ;; minicargo uses relative paths to resolve mrustc.
205 (install-file "tools/bin/minicargo" tools-bin)
206 (install-file "tools/bin/minicargo" cargo-bin)
207 (mkdir-p run_rustc)
208 (copy-file "run_rustc/Makefile"
209 (string-append run_rustc "/Makefile"))
210 #t))))))
211 (synopsis "Compiler for the Rust programming language")
212 (description "Rust is a systems programming language that provides memory
213 safety and thread safety guarantees.")
214 (home-page "https://github.com/thepowersgang/mrustc")
215 ;; Dual licensed.
216 (license (list license:asl2.0 license:expat)))))
217
218 (define rust-1.19
219 (package
220 (name "rust")
221 (version "1.19.0")
222 (source
223 (origin
224 (method url-fetch)
225 (uri (rust-uri "1.19.0"))
226 (sha256 (base32 "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))
227 (modules '((guix build utils)))
228 (snippet '(begin (delete-file-recursively "src/llvm") #t))
229 (patches (map search-patch '("rust-1.19-mrustc.patch")))))
230 (outputs '("out" "cargo"))
231 (properties '((timeout . 72000) ;20 hours
232 (max-silent-time . 18000))) ;5 hours (for armel)
233 (arguments
234 `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
235 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
236 #:phases
237 (modify-phases %standard-phases
238 (add-after 'unpack 'set-env
239 (lambda* (#:key inputs #:allow-other-keys)
240 ;; Disable test for cross compilation support.
241 (setenv "CFG_DISABLE_CROSS_TESTS" "1")
242 (setenv "SHELL" (which "sh"))
243 (setenv "CONFIG_SHELL" (which "sh"))
244 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
245 ;; guix llvm-3.9.1 package installs only shared libraries
246 (setenv "LLVM_LINK_SHARED" "1")
247 #t))
248 (add-after 'unpack 'patch-cargo-tomls
249 (lambda* (#:key inputs outputs #:allow-other-keys)
250 (substitute* "src/librustc_errors/Cargo.toml"
251 (("[[]dependencies[]]") "
252 [dependencies]
253 term = \"0.4.4\"
254 "))
255 (substitute* "src/librustc/Cargo.toml"
256 (("[[]dependencies[]]") "
257 [dependencies]
258 getopts = { path = \"../libgetopts\" }
259 "))
260 (substitute* "src/librustdoc/Cargo.toml"
261 (("[[]dependencies[]]") "
262 [dependencies]
263 test = { path = \"../libtest\" }
264 "))
265 #t))
266 (add-after 'unpack 'patch-tests
267 (lambda* (#:key inputs #:allow-other-keys)
268 (let ((bash (assoc-ref inputs "bash")))
269 (substitute* "src/libstd/process.rs"
270 ;; The newline is intentional.
271 ;; There's a line length "tidy" check in Rust which would
272 ;; fail otherwise.
273 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
274 (substitute* "src/libstd/net/tcp.rs"
275 ;; There is no network in build environment
276 (("fn connect_timeout_unroutable")
277 "#[ignore]\nfn connect_timeout_unroutable"))
278 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
279 (substitute* "src/libstd/sys/unix/process/process_common.rs"
280 (("fn test_process_mask") "#[allow(unused_attributes)]
281 #[ignore]
282 fn test_process_mask"))
283 #t)))
284 (add-after 'patch-tests 'patch-aarch64-test
285 (lambda* _
286 (substitute* "src/librustc_back/dynamic_lib.rs"
287 ;; This test is known to fail on aarch64 and powerpc64le:
288 ;; https://github.com/rust-lang/rust/issues/45410
289 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
290 #t))
291 (add-after 'patch-tests 'use-readelf-for-tests
292 (lambda* _
293 ;; nm doesn't recognize the file format because of the
294 ;; nonstandard sections used by the Rust compiler, but readelf
295 ;; ignores them.
296 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
297 (("\tnm ")
298 "\treadelf -c "))
299 #t))
300 (add-after 'patch-tests 'remove-unsupported-tests
301 (lambda* _
302 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
303 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
304 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
305 #t))
306 (add-after 'patch-source-shebangs 'patch-cargo-checksums
307 (lambda* _
308 (use-modules (guix build cargo-utils))
309 (substitute* "src/Cargo.lock"
310 (("(\"checksum .* = )\".*\"" all name)
311 (string-append name "\"" ,%cargo-reference-hash "\"")))
312 (generate-all-checksums "src/vendor")
313 #t))
314 ;; This phase is overridden by newer versions.
315 (replace 'configure
316 (const #t))
317 ;; This phase is overridden by newer versions.
318 (replace 'build
319 (lambda* (#:key inputs outputs #:allow-other-keys)
320 (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap")))
321 (setenv "CFG_COMPILER_HOST_TRIPLE"
322 ,(nix-system->gnu-triplet (%current-system)))
323 (setenv "CFG_RELEASE" "")
324 (setenv "CFG_RELEASE_CHANNEL" "stable")
325 (setenv "CFG_LIBDIR_RELATIVE" "lib")
326 (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
327 (setenv "MRUSTC_TARGET_VER" ,(version-major+minor version))
328 ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path.
329 (mkdir-p "output")
330 ;; mrustc 0.9 doesn't check the search paths for crates anymore.
331 (copy-recursively (string-append rustc-bootstrap "/lib/mrust")
332 "output")
333 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
334 "src/rustc" "--vendor-dir" "src/vendor"
335 "--output-dir" "output/rustc-build"
336 "-L" (string-append rustc-bootstrap "/lib/mrust")
337 "-j" "1")
338 (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
339 (setenv "CFG_RELEASE" #f)
340 (setenv "CFG_RELEASE_CHANNEL" #f)
341 (setenv "CFG_VERSION" #f)
342 (setenv "CFG_PREFIX" #f)
343 (setenv "CFG_LIBDIR_RELATIVE" #f)
344 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
345 "src/tools/cargo" "--vendor-dir" "src/vendor"
346 "--output-dir" "output/cargo-build"
347 "-L" "output/"
348 "-L" (string-append rustc-bootstrap "/lib/mrust")
349 "-j" "1")
350 ;; Now use the newly-built rustc to build the libraries.
351 ;; One day that could be replaced by:
352 ;; (invoke "output/cargo-build/cargo" "build"
353 ;; "--manifest-path" "src/bootstrap/Cargo.toml"
354 ;; "--verbose") ; "--locked" "--frozen"
355 ;; but right now, Cargo has problems with libstd's circular
356 ;; dependencies.
357 (mkdir-p "output/target-libs")
358 (for-each (match-lambda
359 ((name . flags)
360 (write name)
361 (newline)
362 (apply invoke
363 "output/rustc-build/rustc"
364 "-C" (string-append "linker="
365 (getenv "CC"))
366 ;; Required for libterm.
367 "-Z" "force-unstable-if-unmarked"
368 "-L" "output/target-libs"
369 (string-append "src/" name "/lib.rs")
370 "-o"
371 (string-append "output/target-libs/"
372 (car (string-split name #\/))
373 ".rlib")
374 flags)))
375 '(("libcore")
376 ("libstd_unicode")
377 ("liballoc")
378 ("libcollections")
379 ("librand")
380 ("liblibc/src" "--cfg" "stdbuild")
381 ("libunwind" "-l" "gcc_s")
382 ("libcompiler_builtins")
383 ("liballoc_system")
384 ("libpanic_unwind")
385 ;; Uses "cc" to link.
386 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
387 ("libarena")
388
389 ;; Test dependencies:
390
391 ("libgetopts")
392 ("libterm")
393 ("libtest")))
394 #t)))
395 ;; This phase is overridden by newer versions.
396 (replace 'check
397 (const #t))
398 ;; This phase is overridden by newer versions.
399 (replace 'install
400 (lambda* (#:key inputs outputs #:allow-other-keys)
401 (let* ((out (assoc-ref outputs "out"))
402 (target-system ,(or (%current-target-system)
403 (nix-system->gnu-triplet
404 (%current-system))))
405 (out-libs (string-append out "/lib/rustlib/"
406 target-system "/lib")))
407 ;(setenv "CFG_PREFIX" out)
408 (mkdir-p out-libs)
409 (copy-recursively "output/target-libs" out-libs)
410 (install-file "output/rustc-build/rustc"
411 (string-append out "/bin"))
412 (install-file "output/rustc-build/rustdoc"
413 (string-append out "/bin"))
414 (install-file "output/cargo-build/cargo"
415 (string-append (assoc-ref outputs "cargo")
416 "/bin")))
417 #t)))))
418 (build-system gnu-build-system)
419 (native-inputs
420 `(("bison" ,bison) ; For the tests
421 ("cmake" ,cmake-minimal)
422 ("flex" ,flex) ; For the tests
423 ("gdb" ,gdb) ; For the tests
424 ("procps" ,procps) ; For the tests
425 ("python-2" ,python-2)
426 ("rustc-bootstrap" ,mrustc)
427 ("cargo-bootstrap" ,mrustc "cargo")
428 ("pkg-config" ,pkg-config) ; For "cargo"
429 ("which" ,which)))
430 (inputs
431 `(("jemalloc" ,jemalloc-4.5.0)
432 ("llvm" ,llvm-3.9.1)
433 ("openssl" ,openssl-1.0)
434 ("libssh2" ,libssh2) ; For "cargo"
435 ("libcurl" ,curl))) ; For "cargo"
436
437 ;; rustc invokes gcc, so we need to set its search paths accordingly.
438 ;; Note: duplicate its value here to cope with circular dependencies among
439 ;; modules (see <https://bugs.gnu.org/31392>).
440 (native-search-paths
441 (list (search-path-specification
442 (variable "CPATH")
443 (files '("include")))
444 (search-path-specification
445 (variable "LIBRARY_PATH")
446 (files '("lib" "lib64")))))
447
448 (synopsis "Compiler for the Rust progamming language")
449 (description "Rust is a systems programming language that provides memory
450 safety and thread safety guarantees.")
451 (home-page "https://www.rust-lang.org")
452 ;; Dual licensed.
453 (license (list license:asl2.0 license:expat))))
454
455 (define-public rust-1.20
456 (let ((base-rust
457 (rust-bootstrapped-package rust-1.19 "1.20.0"
458 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
459 (package
460 (inherit base-rust)
461 (source
462 (origin
463 (inherit (package-source base-rust))
464 (snippet '(begin
465 (delete-file-recursively "src/jemalloc")
466 (delete-file-recursively "src/llvm")
467 #t))
468 (patches '())))
469 (outputs '("out" "doc" "cargo"))
470 ;; Since rust-1.19 is local, it's quite probable that Hydra
471 ;; will build rust-1.19 only as a dependency of rust-1.20.
472 ;; But then Hydra will use the wrong properties, the ones here,
473 ;; for rust-1.19. Therefore, we copied the properties of
474 ;; rust-1.19 here.
475 (properties '((timeout . 72000) ;20 hours
476 (max-silent-time . 18000))) ;5 hours (for armel)
477 (arguments
478 (substitute-keyword-arguments (package-arguments rust-1.19)
479 ((#:phases phases)
480 `(modify-phases ,phases
481 (add-after 'patch-tests 'patch-cargo-tests
482 (lambda _
483 (substitute* "src/tools/cargo/tests/build.rs"
484 (("/usr/bin/env") (which "env"))
485 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
486 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
487 (substitute* "src/tools/cargo/tests/death.rs"
488 ;; This is stuck when built in container.
489 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
490 ;; Prints test output in the wrong order when built on
491 ;; i686-linux.
492 (substitute* "src/tools/cargo/tests/test.rs"
493 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
494
495 ;; These tests pull in a dependency on "git", which changes
496 ;; too frequently take part in the Rust toolchain.
497 (substitute* "src/tools/cargo/tests/new.rs"
498 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
499 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
500 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
501 #t))
502 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
503 ;; https://github.com/rust-lang/rust/issues/47863
504 (lambda _
505 (substitute* "src/test/run-pass/out-of-stack.rs"
506 (("// ignore-android") "// ignore-test\n// ignore-android"))
507 #t))
508 (replace 'configure
509 (lambda* (#:key inputs outputs #:allow-other-keys)
510 (let* ((out (assoc-ref outputs "out"))
511 (doc (assoc-ref outputs "doc"))
512 (gcc (assoc-ref inputs "gcc"))
513 (gdb (assoc-ref inputs "gdb"))
514 (binutils (assoc-ref inputs "binutils"))
515 (python (assoc-ref inputs "python-2"))
516 (rustc (assoc-ref inputs "rustc-bootstrap"))
517 (cargo (assoc-ref inputs "cargo-bootstrap"))
518 (llvm (assoc-ref inputs "llvm"))
519 (jemalloc (assoc-ref inputs "jemalloc")))
520 (call-with-output-file "config.toml"
521 (lambda (port)
522 (display (string-append "
523 [llvm]
524 [build]
525 cargo = \"" cargo "/bin/cargo" "\"
526 rustc = \"" rustc "/bin/rustc" "\"
527 docs = true
528 python = \"" python "/bin/python2" "\"
529 gdb = \"" gdb "/bin/gdb" "\"
530 vendor = true
531 submodules = false
532 [install]
533 prefix = \"" out "\"
534 docdir = \"" doc "/share/doc/rust" "\"
535 sysconfdir = \"etc\"
536 [rust]
537 default-linker = \"" gcc "/bin/gcc" "\"
538 channel = \"stable\"
539 rpath = true
540 " ;; There are 2 failed codegen tests:
541 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
542 ;; These tests require a patched LLVM
543 "codegen-tests = false
544 [target." ,(nix-system->gnu-triplet-for-rust) "]
545 llvm-config = \"" llvm "/bin/llvm-config" "\"
546 cc = \"" gcc "/bin/gcc" "\"
547 cxx = \"" gcc "/bin/g++" "\"
548 ar = \"" binutils "/bin/ar" "\"
549 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
550 [dist]
551 ") port)))
552 #t)))
553 (add-after 'configure 'provide-cc
554 (lambda* (#:key inputs #:allow-other-keys)
555 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
556 "/tmp/cc")
557 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
558 #t))
559 (add-after 'provide-cc 'configure-archiver
560 (lambda* (#:key inputs #:allow-other-keys)
561 (substitute* "src/build_helper/lib.rs"
562 ;; Make sure "ar" is always used as the archiver.
563 (("\"musl\"") "\"\"")
564 ;; Then substitute "ar" by our name.
565 (("\"ar\"") (string-append "\""
566 (assoc-ref inputs "binutils")
567 "/bin/ar\"")))
568 #t))
569 (delete 'patch-cargo-tomls)
570 (add-before 'build 'reset-timestamps-after-changes
571 (lambda* _
572 (for-each
573 (lambda (filename)
574 ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist".
575 ;; Therefore, use timestamp 1.
576 (utime filename 1 1 1 1))
577 (find-files "." #:directories? #t))
578 #t))
579 (replace 'build
580 (lambda* _
581 (invoke "./x.py" "build")
582 (invoke "./x.py" "build" "src/tools/cargo")))
583 (replace 'check
584 (lambda* _
585 ;; Disable parallel execution to prevent EAGAIN errors when
586 ;; running tests.
587 (invoke "./x.py" "-j1" "test" "-vv")
588 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
589 #t))
590 (replace 'install
591 (lambda* (#:key outputs #:allow-other-keys)
592 (invoke "./x.py" "install")
593 (substitute* "config.toml"
594 ;; replace prefix to specific output
595 (("prefix = \"[^\"]*\"")
596 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
597 (invoke "./x.py" "install" "cargo")))
598 (add-after 'install 'delete-install-logs
599 (lambda* (#:key outputs #:allow-other-keys)
600 (define (delete-manifest-file out-path file)
601 (delete-file (string-append out-path "/lib/rustlib/" file)))
602
603 (let ((out (assoc-ref outputs "out"))
604 (cargo-out (assoc-ref outputs "cargo")))
605 (for-each
606 (lambda (file) (delete-manifest-file out file))
607 '("install.log"
608 "manifest-rust-docs"
609 "manifest-rust-std-x86_64-unknown-linux-gnu"
610 "manifest-rustc"))
611 (for-each
612 (lambda (file) (delete-manifest-file cargo-out file))
613 '("install.log"
614 "manifest-cargo"))
615 #t)))
616 (add-after 'install 'wrap-rustc
617 (lambda* (#:key inputs outputs #:allow-other-keys)
618 (let ((out (assoc-ref outputs "out"))
619 (libc (assoc-ref inputs "libc"))
620 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
621 ;; Let gcc find ld and libc startup files.
622 (wrap-program (string-append out "/bin/rustc")
623 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
624 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
625 #t))))))))))
626
627 (define-public rust-1.21
628 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
629 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
630 (package
631 (inherit base-rust)
632 (arguments
633 (substitute-keyword-arguments (package-arguments base-rust)
634 ((#:phases phases)
635 `(modify-phases ,phases
636 (add-after 'configure 'remove-ar
637 (lambda* (#:key inputs #:allow-other-keys)
638 ;; Remove because toml complains about "unknown field".
639 (substitute* "config.toml"
640 (("^ar =.*") "\n"))
641 #t)))))))))
642
643 (define-public rust-1.22
644 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
645 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
646 (package
647 (inherit base-rust)
648 (arguments
649 (substitute-keyword-arguments (package-arguments base-rust)
650 ((#:phases phases)
651 `(modify-phases ,phases
652 (add-after 'unpack 'remove-flaky-test
653 (lambda _
654 ;; See <https://github.com/rust-lang/rust/issues/43402>.
655 (when (file-exists? "src/test/run-make/issue-26092")
656 (delete-file-recursively "src/test/run-make/issue-26092"))
657 #t)))))))))
658
659 (define-public rust-1.23
660 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
661 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
662 (package
663 (inherit base-rust)
664 (arguments
665 (substitute-keyword-arguments (package-arguments base-rust)
666 ((#:phases phases)
667 `(modify-phases ,phases
668 (delete 'configure-archiver)
669 (delete 'remove-ar)
670 (add-after 'unpack 'dont-build-native
671 (lambda _
672 ;; XXX: Revisit this when we use gcc 6.
673 (substitute* "src/binaryen/CMakeLists.txt"
674 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
675 #t)))))))))
676
677 (define-public rust-1.24
678 (let ((base-rust
679 (rust-bootstrapped-package rust-1.23 "1.24.1"
680 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
681 (package
682 (inherit base-rust)
683 (arguments
684 (substitute-keyword-arguments (package-arguments base-rust)
685 ((#:phases phases)
686 `(modify-phases ,phases
687 (delete 'use-readelf-for-tests)
688 (replace 'patch-aarch64-test
689 (lambda* _
690 (substitute* "src/librustc_metadata/dynamic_lib.rs"
691 ;; This test is known to fail on aarch64 and powerpc64le:
692 ;; https://github.com/rust-lang/rust/issues/45410
693 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
694 #t)))))))))
695
696 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
697 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
698 ;;; Keep using llvm 3.9.1 until builds become determenistic
699 (define-public rust-1.25
700 (let ((base-rust
701 (rust-bootstrapped-package rust-1.24 "1.25.0"
702 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")))
703 (package
704 (inherit base-rust)
705 (source
706 (origin
707 (inherit (package-source base-rust))
708 (snippet '(begin
709 (delete-file-recursively "src/jemalloc")
710 (delete-file-recursively "src/llvm")
711 (delete-file-recursively "src/llvm-emscripten")
712 #t))
713 (patches (map search-patch
714 '("rust-1.25-accept-more-detailed-gdb-lines.patch")))))
715 (arguments
716 (substitute-keyword-arguments (package-arguments base-rust)
717 ((#:phases phases)
718 `(modify-phases ,phases
719 (add-after 'patch-cargo-tests 'patch-cargo-index-update
720 (lambda _
721 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
722 ;; This test wants to update the crate index.
723 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
724 #t))
725 (replace 'patch-aarch64-test
726 (lambda _
727 (substitute* "src/librustc_metadata/dynamic_lib.rs"
728 ;; This test is known to fail on aarch64 and powerpc64le:
729 ;; https://github.com/rust-lang/rust/issues/45410
730 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
731 ;; This test fails on aarch64 with llvm@6.0:
732 ;; https://github.com/rust-lang/rust/issues/49807
733 ;; other possible solution:
734 ;; https://github.com/rust-lang/rust/pull/47688
735 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
736 #t))
737 (delete 'ignore-glibc-2.27-incompatible-test))))))))
738
739 (define-public rust-1.26
740 (let ((base-rust
741 (rust-bootstrapped-package rust-1.25 "1.26.2"
742 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv")))
743 (package
744 (inherit base-rust)
745 (source
746 (origin
747 (inherit (package-source base-rust))
748 (patches (map search-patch
749 '("rust-coresimd-doctest.patch"
750 "rust-1.25-accept-more-detailed-gdb-lines.patch")))))
751 (arguments
752 (substitute-keyword-arguments (package-arguments base-rust)
753 ((#:phases phases)
754 `(modify-phases ,phases
755 ;; binaryen was replaced with LLD project from LLVM
756 (delete 'dont-build-native)
757 (replace 'check
758 (lambda* _
759 ;; Enable parallel execution.
760 (let ((parallel-job-spec
761 (string-append "-j" (number->string
762 (min 4
763 (parallel-job-count))))))
764 (invoke "./x.py" parallel-job-spec "test" "-vv")
765 (invoke "./x.py" parallel-job-spec "test"
766 "src/tools/cargo"))))
767 (replace 'remove-unsupported-tests
768 (lambda* _
769 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
770 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
771 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
772 #t))
773 (replace 'patch-cargo-tests
774 (lambda* _
775 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
776 (("/usr/bin/env") (which "env"))
777 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
778 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
779 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
780 ;; This is stuck when built in container.
781 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
782 ;; Prints test output in the wrong order when built on
783 ;; i686-linux.
784 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
785 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
786
787 ;; Avoid dependency on "git".
788 (substitute* "src/tools/cargo/tests/testsuite/new.rs"
789 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
790 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
791 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
792 #t))
793 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
794 (lambda* _
795 ;; This test failed to work on "nightly" channel builds
796 ;; https://github.com/rust-lang/cargo/issues/5648
797 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
798 (("fn test_resolving_minimum_version_with_transitive_deps")
799 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
800 #t))
801 (replace 'patch-cargo-index-update
802 (lambda* _
803 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
804 ;; This test wants to update the crate index.
805 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
806 #t)))))))))
807
808 (define-public rust-1.27
809 (let ((base-rust
810 (rust-bootstrapped-package rust-1.26 "1.27.2"
811 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs")))
812 (package
813 (inherit base-rust)
814 (source
815 (origin
816 (inherit (package-source base-rust))
817 (patches (map search-patch '("rust-coresimd-doctest.patch"
818 "rust-bootstrap-stage0-test.patch"
819 "rust-1.25-accept-more-detailed-gdb-lines.patch"
820 "rust-reproducible-builds.patch")))))
821 (native-inputs
822 ;; FIXME: Rust 1.27 and some later versions require GDB 8.2 specifically.
823 ;; See <https://bugs.gnu.org/37810>.
824 (alist-replace "gdb" (list gdb-8.2)
825 (package-native-inputs base-rust)))
826 (arguments
827 (substitute-keyword-arguments (package-arguments base-rust)
828 ((#:phases phases)
829 `(modify-phases ,phases
830 (add-before 'install 'mkdir-prefix-paths
831 (lambda* (#:key outputs #:allow-other-keys)
832 ;; As result of https://github.com/rust-lang/rust/issues/36989
833 ;; `prefix' directory should exist before `install' call
834 (mkdir-p (assoc-ref outputs "out"))
835 (mkdir-p (assoc-ref outputs "cargo"))
836 #t))
837 (add-after 'patch-cargo-tests 'disable-thinlto-test
838 (lambda* _
839 ;; thinlto required llvm 6.0 for work
840 (substitute* "src/tools/cargo/tests/testsuite/path.rs"
841 (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works"))
842 #t)))))))))
843
844 (define-public rust-1.28
845 (let ((base-rust
846 (rust-bootstrapped-package rust-1.27 "1.28.0"
847 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx")))
848 (package
849 (inherit base-rust)
850 (source
851 (origin
852 (inherit (package-source base-rust))
853 (patches (map search-patch '("rust-coresimd-doctest.patch"
854 "rust-bootstrap-stage0-test.patch"
855 "rust-1.25-accept-more-detailed-gdb-lines.patch"
856 "rust-reproducible-builds.patch")))))
857 (inputs
858 ;; Use LLVM 6.0
859 (alist-replace "llvm" (list llvm-6)
860 (package-inputs base-rust)))
861 (arguments
862 (substitute-keyword-arguments (package-arguments base-rust)
863 ((#:phases phases)
864 `(modify-phases ,phases
865 (add-after 'configure 'enable-codegen-tests
866 ;; Codegen tests should pass with llvm 6, so enable them.
867 (lambda* _
868 (substitute* "config.toml"
869 (("codegen-tests = false") ""))
870 #t))
871 (add-after 'patch-tests 'disable-amd64-avx-test
872 ;; That test would fail on x86_64 machines without avx.
873 (lambda* _
874 (substitute* "src/test/run-pass/issue-44056.rs"
875 (("only-x86_64") "ignore-test"))
876 #t))
877 ;; The thinlto test should pass with llvm 6.
878 (delete 'disable-thinlto-test))))))))
879
880 (define-public rust-1.29
881 (let ((base-rust
882 (rust-bootstrapped-package rust-1.28 "1.29.2"
883 "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h")))
884 (package
885 (inherit base-rust)
886 (source
887 (origin
888 (inherit (package-source base-rust))
889 (patches (map search-patch '("rust-1.25-accept-more-detailed-gdb-lines.patch"
890 "rust-reproducible-builds.patch"))))))))
891
892 (define-public rust-1.30
893 (let ((base-rust
894 (rust-bootstrapped-package rust-1.29 "1.30.1"
895 "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn")))
896 (package
897 (inherit base-rust)
898 (source
899 (origin
900 (inherit (package-source base-rust))
901 (snippet '(begin
902 (delete-file-recursively "src/jemalloc")
903 (delete-file-recursively "src/llvm")
904 (delete-file-recursively "src/llvm-emscripten")
905 (delete-file-recursively "src/tools/clang")
906 (delete-file-recursively "src/tools/lldb")
907 #t))))
908 (arguments
909 (substitute-keyword-arguments (package-arguments base-rust)
910 ((#:phases phases)
911 `(modify-phases ,phases
912 (add-after 'patch-cargo-tests 'patch-cargo-env-shebang
913 (lambda* (#:key inputs #:allow-other-keys)
914 (let ((coreutils (assoc-ref inputs "coreutils")))
915 (substitute* "src/tools/cargo/tests/testsuite/fix.rs"
916 ;; Cargo has a test which explicitly sets a
917 ;; RUSTC_WRAPPER environment variable which points
918 ;; to /usr/bin/env. Since it's not a shebang, it
919 ;; needs to be manually patched
920 (("\"/usr/bin/env\"")
921 (string-append "\"" coreutils "/bin/env\"")))
922 #t)))
923 (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
924 (lambda* _
925 (substitute* "src/tools/cargo/tests/testsuite/package.rs"
926 ;; These tests largely check that cargo outputs warning/error
927 ;; messages as expected. It seems that cargo outputs an
928 ;; absolute path to something in the store instead of the
929 ;; expected relative path (e.g. `[..]`) so we'll ignore
930 ;; these for now
931 (("fn include") "#[ignore]\nfn include")
932 (("fn exclude") "#[ignore]\nfn exclude"))
933 #t))
934 ;; The test has been moved elsewhere.
935 (replace 'disable-amd64-avx-test
936 (lambda _
937 (substitute* "src/test/ui/run-pass/issues/issue-44056.rs"
938 (("only-x86_64") "ignore-test"))
939 #t)))))))))
940
941 (define (patch-command-exec-tests-phase test-path)
942 "The command-exec.rs test moves around between releases. We need to apply
943 a Guix-specific patch to it for each release. This function generates the phase
944 that applies said patch, parametrized by the test-path. This is done this way
945 because the phase is more complex than the equivalents for other tests that
946 move around."
947 `(lambda* (#:key inputs #:allow-other-keys)
948 (let ((coreutils (assoc-ref inputs "coreutils")))
949 (substitute* ,test-path
950 ;; This test suite includes some tests that the stdlib's
951 ;; `Command` execution properly handles situations where
952 ;; the environment or PATH variable are empty, but this
953 ;; fails since we don't have `echo` available in the usual
954 ;; Linux directories.
955 ;; NB: the leading space is so we don't fail a tidy check
956 ;; for trailing whitespace, and the newlines are to ensure
957 ;; we don't exceed the 100 chars tidy check as well
958 ((" Command::new\\(\"echo\"\\)")
959 (string-append "\nCommand::new(\"" coreutils "/bin/echo\")\n")))
960 #t)))
961
962 (define-public rust-1.31
963 (let ((base-rust
964 (rust-bootstrapped-package rust-1.30 "1.31.1"
965 "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli")))
966 (package
967 (inherit base-rust)
968 (arguments
969 (substitute-keyword-arguments (package-arguments base-rust)
970 ((#:phases phases)
971 `(modify-phases ,phases
972 (add-after 'patch-tests 'patch-command-exec-tests
973 ,(patch-command-exec-tests-phase
974 "src/test/run-pass/command-exec.rs"))
975 ;; The test has been moved elsewhere.
976 (replace 'disable-amd64-avx-test
977 (lambda _
978 (substitute* "src/test/ui/issues/issue-44056.rs"
979 (("only-x86_64") "ignore-test"))
980 #t))
981 (add-after 'patch-tests 'patch-process-docs-rev-cmd
982 (lambda* _
983 ;; Disable some doc tests which depend on the "rev" command
984 ;; https://github.com/rust-lang/rust/pull/58746
985 (substitute* "src/libstd/process.rs"
986 (("```rust") "```rust,no_run"))
987 #t)))))))))
988
989 (define-public rust-1.32
990 (let ((base-rust
991 (rust-bootstrapped-package rust-1.31 "1.32.0"
992 "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac")))
993 (package
994 (inherit base-rust)
995 (source
996 (origin
997 (inherit (package-source base-rust))
998 (snippet '(begin (delete-file-recursively "src/llvm")
999 (delete-file-recursively "src/llvm-emscripten")
1000 (delete-file-recursively "src/tools/clang")
1001 (delete-file-recursively "src/tools/lldb")
1002 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1003 #t))
1004 (patches (map search-patch '("rust-reproducible-builds.patch")))
1005 ;; the vendor directory has moved to the root of
1006 ;; the tarball, so we have to strip an extra prefix
1007 (patch-flags '("-p2"))))
1008 (inputs
1009 ;; Downgrade to LLVM 6, all LTO tests appear to fail with LLVM 7.0.1
1010 (alist-replace "llvm" (list llvm-6)
1011 (package-inputs base-rust)))
1012 (arguments
1013 (substitute-keyword-arguments (package-arguments base-rust)
1014 ((#:phases phases)
1015 `(modify-phases ,phases
1016 ;; Cargo.lock and the vendor/ directory have been moved to the
1017 ;; root of the rust tarball
1018 (replace 'patch-cargo-checksums
1019 (lambda* _
1020 (use-modules (guix build cargo-utils))
1021 (substitute* "Cargo.lock"
1022 (("(\"checksum .* = )\".*\"" all name)
1023 (string-append name "\"" ,%cargo-reference-hash "\"")))
1024 (generate-all-checksums "vendor")
1025 #t))
1026 (add-after 'enable-codegen-tests 'override-jemalloc
1027 (lambda* (#:key inputs #:allow-other-keys)
1028 ;; The compiler is no longer directly built against jemalloc,
1029 ;; but rather via the jemalloc-sys crate (which vendors the
1030 ;; jemalloc source). To use jemalloc we must enable linking to
1031 ;; it (otherwise it would use the system allocator), and set
1032 ;; an environment variable pointing to the compiled jemalloc.
1033 (substitute* "config.toml"
1034 (("^jemalloc =.*$") "")
1035 (("[[]rust[]]") "\n[rust]\njemalloc=true\n"))
1036 (setenv "JEMALLOC_OVERRIDE" (string-append (assoc-ref inputs "jemalloc")
1037 "/lib/libjemalloc_pic.a"))
1038 #t))
1039 ;; Remove no longer relevant steps
1040 (delete 'remove-flaky-test)
1041 (delete 'patch-aarch64-test))))))))
1042
1043 (define-public rust-1.33
1044 (let ((base-rust
1045 (rust-bootstrapped-package rust-1.32 "1.33.0"
1046 "152x91mg7bz4ygligwjb05fgm1blwy2i70s2j03zc9jiwvbsh0as")))
1047 (package
1048 (inherit base-rust)
1049 (source
1050 (origin
1051 (inherit (package-source base-rust))
1052 (patches '())
1053 (patch-flags '("-p1"))))
1054 (inputs
1055 ;; Upgrade to jemalloc@5.1.0
1056 (alist-replace "jemalloc" (list jemalloc)
1057 (package-inputs base-rust)))
1058 (arguments
1059 (substitute-keyword-arguments (package-arguments base-rust)
1060 ((#:phases phases)
1061 `(modify-phases ,phases
1062 (delete 'ignore-cargo-package-tests)
1063 (add-after 'configure 'configure-test-threads
1064 ;; Several rustc and cargo tests will fail if run on one core
1065 ;; https://github.com/rust-lang/rust/issues/59122
1066 ;; https://github.com/rust-lang/cargo/issues/6746
1067 ;; https://github.com/rust-lang/rust/issues/58907
1068 (lambda* (#:key inputs #:allow-other-keys)
1069 (setenv "RUST_TEST_THREADS" "2")
1070 #t)))))))))
1071
1072 (define-public rust-1.34
1073 (let ((base-rust
1074 (rust-bootstrapped-package rust-1.33 "1.34.1"
1075 "19s09k7y5j6g3y4d2rk6kg9pvq6ml94c49w6b72dmq8p9lk8bixh")))
1076 (package
1077 (inherit base-rust)
1078 (source
1079 (origin
1080 (inherit (package-source base-rust))
1081 (snippet '(begin
1082 (delete-file-recursively "src/llvm-emscripten")
1083 (delete-file-recursively "src/llvm-project")
1084 (delete-file-recursively "vendor/jemalloc-sys/jemalloc")
1085 #t)))))))
1086
1087 (define-public rust-1.35
1088 (let ((base-rust
1089 (rust-bootstrapped-package rust-1.34 "1.35.0"
1090 "0bbizy6b7002v1rdhrxrf5gijclbyizdhkglhp81ib3bf5x66kas")))
1091 (package
1092 (inherit base-rust)
1093 (inputs
1094 (alist-replace "llvm" (list llvm-8)
1095 (package-inputs base-rust)))
1096 (arguments
1097 (substitute-keyword-arguments (package-arguments base-rust)
1098 ((#:phases phases)
1099 `(modify-phases ,phases
1100 ;; The tidy test includes a pass which ensures large binaries
1101 ;; don't accidentally get checked into the rust git repo.
1102 ;; Unfortunately the test assumes that git is always available,
1103 ;; so we'll comment out the invocation of this pass.
1104 (add-after 'configure 'disable-tidy-bins-check
1105 (lambda* _
1106 (substitute* "src/tools/tidy/src/main.rs"
1107 (("bins::check") "//bins::check"))
1108 #t)))))))))
1109
1110 (define-public rust-1.36
1111 (let ((base-rust
1112 (rust-bootstrapped-package rust-1.35 "1.36.0"
1113 "06xv2p6zq03lidr0yaf029ii8wnjjqa894nkmrm6s0rx47by9i04")))
1114 (package
1115 (inherit base-rust)
1116 (arguments
1117 (substitute-keyword-arguments (package-arguments base-rust)
1118 ((#:phases phases)
1119 `(modify-phases ,phases
1120 (delete 'patch-process-docs-rev-cmd))))))))
1121
1122 (define-public rust-1.37
1123 (let ((base-rust
1124 (rust-bootstrapped-package rust-1.36 "1.37.0"
1125 "1hrqprybhkhs6d9b5pjskfnc5z9v2l2gync7nb39qjb5s0h703hj")))
1126 (package
1127 (inherit base-rust)
1128 (arguments
1129 (substitute-keyword-arguments (package-arguments base-rust)
1130 ((#:phases phases)
1131 `(modify-phases ,phases
1132 (add-before 'configure 'configure-cargo-home
1133 (lambda _
1134 (let ((cargo-home (string-append (getcwd) "/.cargo")))
1135 (mkdir-p cargo-home)
1136 (setenv "CARGO_HOME" cargo-home)
1137 #t))))))))))
1138
1139 (define-public rust-1.38
1140 (let ((base-rust
1141 (rust-bootstrapped-package rust-1.37 "1.38.0"
1142 "101dlpsfkq67p0hbwx4acqq6n90dj4bbprndizpgh1kigk566hk4")))
1143 (package
1144 (inherit base-rust)
1145 (arguments
1146 (substitute-keyword-arguments (package-arguments base-rust)
1147 ((#:phases phases)
1148 `(modify-phases ,phases
1149 (replace 'patch-command-exec-tests
1150 ,(patch-command-exec-tests-phase
1151 "src/test/ui/command-exec.rs"))
1152 (add-after 'patch-tests 'patch-command-uid-gid-test
1153 (lambda _
1154 (substitute* "src/test/ui/command-uid-gid.rs"
1155 (("/bin/sh") (which "sh"))
1156 (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
1157 #t)))))))))
1158
1159 (define-public rust-1.39
1160 (let ((base-rust
1161 (rust-bootstrapped-package rust-1.38 "1.39.0"
1162 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
1163 (package
1164 (inherit base-rust)
1165 (arguments
1166 (substitute-keyword-arguments (package-arguments base-rust)
1167 ((#:phases phases)
1168 `(modify-phases ,phases
1169 (replace 'patch-cargo-checksums
1170 ;; The Cargo.lock format changed.
1171 (lambda* _
1172 (use-modules (guix build cargo-utils))
1173 (substitute* "Cargo.lock"
1174 (("(checksum = )\".*\"" all name)
1175 (string-append name "\"" ,%cargo-reference-hash "\"")))
1176 (generate-all-checksums "vendor")
1177 #t)))))))))
1178
1179 (define-public rust rust-1.37)