mailmap: Update entries for Nikita.
[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 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 "C_INCLUDE_PATH")
443 (files '("include")))
444 (search-path-specification
445 (variable "CPLUS_INCLUDE_PATH")
446 (files '("include/c++" "include")))
447 (search-path-specification
448 (variable "LIBRARY_PATH")
449 (files '("lib" "lib64")))))
450
451 (synopsis "Compiler for the Rust progamming language")
452 (description "Rust is a systems programming language that provides memory
453 safety and thread safety guarantees.")
454 (home-page "https://www.rust-lang.org")
455 ;; Dual licensed.
456 (license (list license:asl2.0 license:expat))))
457
458 (define-public rust-1.20
459 (let ((base-rust
460 (rust-bootstrapped-package rust-1.19 "1.20.0"
461 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
462 (package
463 (inherit base-rust)
464 (source
465 (origin
466 (inherit (package-source base-rust))
467 (snippet '(begin
468 (delete-file-recursively "src/jemalloc")
469 (delete-file-recursively "src/llvm")
470 #t))
471 (patches '())))
472 (native-inputs
473 `(;; The tests fail with newer versions of GNU Make.
474 ("make" ,gnu-make-4.2)
475 ,@(package-native-inputs base-rust)))
476 (outputs '("out" "doc" "cargo"))
477 ;; Since rust-1.19 is local, it's quite probable that Hydra
478 ;; will build rust-1.19 only as a dependency of rust-1.20.
479 ;; But then Hydra will use the wrong properties, the ones here,
480 ;; for rust-1.19. Therefore, we copied the properties of
481 ;; rust-1.19 here.
482 (properties '((timeout . 72000) ;20 hours
483 (max-silent-time . 18000))) ;5 hours (for armel)
484 (arguments
485 (substitute-keyword-arguments (package-arguments rust-1.19)
486 ((#:phases phases)
487 `(modify-phases ,phases
488 (add-after 'patch-tests 'patch-cargo-tests
489 (lambda _
490 (substitute* "src/tools/cargo/tests/build.rs"
491 (("/usr/bin/env") (which "env"))
492 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
493 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
494 (substitute* "src/tools/cargo/tests/death.rs"
495 ;; This is stuck when built in container.
496 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
497 ;; Prints test output in the wrong order when built on
498 ;; i686-linux.
499 (substitute* "src/tools/cargo/tests/test.rs"
500 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
501
502 ;; These tests pull in a dependency on "git", which changes
503 ;; too frequently take part in the Rust toolchain.
504 (substitute* "src/tools/cargo/tests/new.rs"
505 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
506 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
507 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
508 #t))
509 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
510 ;; https://github.com/rust-lang/rust/issues/47863
511 (lambda _
512 (substitute* "src/test/run-pass/out-of-stack.rs"
513 (("// ignore-android") "// ignore-test\n// ignore-android"))
514 #t))
515 (replace 'configure
516 (lambda* (#:key inputs outputs #:allow-other-keys)
517 (let* ((out (assoc-ref outputs "out"))
518 (doc (assoc-ref outputs "doc"))
519 (gcc (assoc-ref inputs "gcc"))
520 (gdb (assoc-ref inputs "gdb"))
521 (binutils (assoc-ref inputs "binutils"))
522 (python (assoc-ref inputs "python-2"))
523 (rustc (assoc-ref inputs "rustc-bootstrap"))
524 (cargo (assoc-ref inputs "cargo-bootstrap"))
525 (llvm (assoc-ref inputs "llvm"))
526 (jemalloc (assoc-ref inputs "jemalloc")))
527 (call-with-output-file "config.toml"
528 (lambda (port)
529 (display (string-append "
530 [llvm]
531 [build]
532 cargo = \"" cargo "/bin/cargo" "\"
533 rustc = \"" rustc "/bin/rustc" "\"
534 docs = true
535 python = \"" python "/bin/python2" "\"
536 gdb = \"" gdb "/bin/gdb" "\"
537 vendor = true
538 submodules = false
539 [install]
540 prefix = \"" out "\"
541 docdir = \"" doc "/share/doc/rust" "\"
542 sysconfdir = \"etc\"
543 [rust]
544 default-linker = \"" gcc "/bin/gcc" "\"
545 channel = \"stable\"
546 rpath = true
547 " ;; There are 2 failed codegen tests:
548 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
549 ;; These tests require a patched LLVM
550 "codegen-tests = false
551 [target." ,(nix-system->gnu-triplet-for-rust) "]
552 llvm-config = \"" llvm "/bin/llvm-config" "\"
553 cc = \"" gcc "/bin/gcc" "\"
554 cxx = \"" gcc "/bin/g++" "\"
555 ar = \"" binutils "/bin/ar" "\"
556 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
557 [dist]
558 ") port)))
559 #t)))
560 (add-after 'configure 'provide-cc
561 (lambda* (#:key inputs #:allow-other-keys)
562 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
563 "/tmp/cc")
564 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
565 #t))
566 (add-after 'provide-cc 'configure-archiver
567 (lambda* (#:key inputs #:allow-other-keys)
568 (substitute* "src/build_helper/lib.rs"
569 ;; Make sure "ar" is always used as the archiver.
570 (("\"musl\"") "\"\"")
571 ;; Then substitute "ar" by our name.
572 (("\"ar\"") (string-append "\""
573 (assoc-ref inputs "binutils")
574 "/bin/ar\"")))
575 #t))
576 (delete 'patch-cargo-tomls)
577 (add-before 'build 'reset-timestamps-after-changes
578 (lambda* _
579 (for-each
580 (lambda (filename)
581 ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist".
582 ;; Therefore, use timestamp 1.
583 (utime filename 1 1 1 1))
584 (find-files "." #:directories? #t))
585 #t))
586 (replace 'build
587 (lambda* _
588 (invoke "./x.py" "build")
589 (invoke "./x.py" "build" "src/tools/cargo")))
590 (replace 'check
591 (lambda* _
592 ;; Disable parallel execution to prevent EAGAIN errors when
593 ;; running tests.
594 (invoke "./x.py" "-j1" "test" "-vv")
595 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
596 #t))
597 (replace 'install
598 (lambda* (#:key outputs #:allow-other-keys)
599 (invoke "./x.py" "install")
600 (substitute* "config.toml"
601 ;; replace prefix to specific output
602 (("prefix = \"[^\"]*\"")
603 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
604 (invoke "./x.py" "install" "cargo")))
605 (add-after 'install 'delete-install-logs
606 (lambda* (#:key outputs #:allow-other-keys)
607 (define (delete-manifest-file out-path file)
608 (delete-file (string-append out-path "/lib/rustlib/" file)))
609
610 (let ((out (assoc-ref outputs "out"))
611 (cargo-out (assoc-ref outputs "cargo")))
612 (for-each
613 (lambda (file) (delete-manifest-file out file))
614 '("install.log"
615 "manifest-rust-docs"
616 "manifest-rust-std-x86_64-unknown-linux-gnu"
617 "manifest-rustc"))
618 (for-each
619 (lambda (file) (delete-manifest-file cargo-out file))
620 '("install.log"
621 "manifest-cargo"))
622 #t)))
623 (add-after 'install 'wrap-rustc
624 (lambda* (#:key inputs outputs #:allow-other-keys)
625 (let ((out (assoc-ref outputs "out"))
626 (libc (assoc-ref inputs "libc"))
627 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
628 ;; Let gcc find ld and libc startup files.
629 (wrap-program (string-append out "/bin/rustc")
630 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
631 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
632 #t))))))))))
633
634 (define-public rust-1.21
635 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
636 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
637 (package
638 (inherit base-rust)
639 (arguments
640 (substitute-keyword-arguments (package-arguments base-rust)
641 ((#:phases phases)
642 `(modify-phases ,phases
643 (add-after 'configure 'remove-ar
644 (lambda* (#:key inputs #:allow-other-keys)
645 ;; Remove because toml complains about "unknown field".
646 (substitute* "config.toml"
647 (("^ar =.*") "\n"))
648 #t)))))))))
649
650 (define-public rust-1.22
651 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
652 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
653 (package
654 (inherit base-rust)
655 (arguments
656 (substitute-keyword-arguments (package-arguments base-rust)
657 ((#:phases phases)
658 `(modify-phases ,phases
659 (add-after 'unpack 'remove-flaky-test
660 (lambda _
661 ;; See <https://github.com/rust-lang/rust/issues/43402>.
662 (when (file-exists? "src/test/run-make/issue-26092")
663 (delete-file-recursively "src/test/run-make/issue-26092"))
664 #t)))))))))
665
666 (define-public rust-1.23
667 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
668 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
669 (package
670 (inherit base-rust)
671 (arguments
672 (substitute-keyword-arguments (package-arguments base-rust)
673 ((#:phases phases)
674 `(modify-phases ,phases
675 (delete 'configure-archiver)
676 (delete 'remove-ar)
677 (add-after 'unpack 'dont-build-native
678 (lambda _
679 ;; XXX: Revisit this when we use gcc 6.
680 (substitute* "src/binaryen/CMakeLists.txt"
681 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
682 #t)))))))))
683
684 (define-public rust-1.24
685 (let ((base-rust
686 (rust-bootstrapped-package rust-1.23 "1.24.1"
687 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
688 (package
689 (inherit base-rust)
690 (arguments
691 (substitute-keyword-arguments (package-arguments base-rust)
692 ((#:phases phases)
693 `(modify-phases ,phases
694 (delete 'use-readelf-for-tests)
695 (replace 'patch-aarch64-test
696 (lambda* _
697 (substitute* "src/librustc_metadata/dynamic_lib.rs"
698 ;; This test is known to fail on aarch64 and powerpc64le:
699 ;; https://github.com/rust-lang/rust/issues/45410
700 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
701 #t)))))))))
702
703 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
704 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
705 ;;; Keep using llvm 3.9.1 until builds become determenistic
706 (define-public rust-1.25
707 (let ((base-rust
708 (rust-bootstrapped-package rust-1.24 "1.25.0"
709 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")))
710 (package
711 (inherit base-rust)
712 (source
713 (origin
714 (inherit (package-source base-rust))
715 (snippet '(begin
716 (delete-file-recursively "src/jemalloc")
717 (delete-file-recursively "src/llvm")
718 (delete-file-recursively "src/llvm-emscripten")
719 #t))
720 (patches (map search-patch
721 '("rust-1.25-accept-more-detailed-gdb-lines.patch")))))
722 (arguments
723 (substitute-keyword-arguments (package-arguments base-rust)
724 ((#:phases phases)
725 `(modify-phases ,phases
726 (add-after 'patch-cargo-tests 'patch-cargo-index-update
727 (lambda _
728 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
729 ;; This test wants to update the crate index.
730 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
731 #t))
732 (replace 'patch-aarch64-test
733 (lambda _
734 (substitute* "src/librustc_metadata/dynamic_lib.rs"
735 ;; This test is known to fail on aarch64 and powerpc64le:
736 ;; https://github.com/rust-lang/rust/issues/45410
737 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
738 ;; This test fails on aarch64 with llvm@6.0:
739 ;; https://github.com/rust-lang/rust/issues/49807
740 ;; other possible solution:
741 ;; https://github.com/rust-lang/rust/pull/47688
742 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
743 #t))
744 (delete 'ignore-glibc-2.27-incompatible-test))))))))
745
746 (define-public rust-1.26
747 (let ((base-rust
748 (rust-bootstrapped-package rust-1.25 "1.26.2"
749 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv")))
750 (package
751 (inherit base-rust)
752 (source
753 (origin
754 (inherit (package-source base-rust))
755 (patches (map search-patch
756 '("rust-coresimd-doctest.patch"
757 "rust-1.25-accept-more-detailed-gdb-lines.patch")))))
758 (arguments
759 (substitute-keyword-arguments (package-arguments base-rust)
760 ((#:phases phases)
761 `(modify-phases ,phases
762 ;; binaryen was replaced with LLD project from LLVM
763 (delete 'dont-build-native)
764 (replace 'check
765 (lambda* _
766 ;; Enable parallel execution.
767 (let ((parallel-job-spec
768 (string-append "-j" (number->string
769 (min 4
770 (parallel-job-count))))))
771 (invoke "./x.py" parallel-job-spec "test" "-vv")
772 (invoke "./x.py" parallel-job-spec "test"
773 "src/tools/cargo"))))
774 (replace 'remove-unsupported-tests
775 (lambda* _
776 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
777 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
778 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
779 #t))
780 (replace 'patch-cargo-tests
781 (lambda* _
782 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
783 (("/usr/bin/env") (which "env"))
784 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
785 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
786 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
787 ;; This is stuck when built in container.
788 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
789 ;; Prints test output in the wrong order when built on
790 ;; i686-linux.
791 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
792 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
793
794 ;; Avoid dependency on "git".
795 (substitute* "src/tools/cargo/tests/testsuite/new.rs"
796 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
797 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
798 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
799 #t))
800 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
801 (lambda* _
802 ;; This test failed to work on "nightly" channel builds
803 ;; https://github.com/rust-lang/cargo/issues/5648
804 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
805 (("fn test_resolving_minimum_version_with_transitive_deps")
806 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
807 #t))
808 (replace 'patch-cargo-index-update
809 (lambda* _
810 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
811 ;; This test wants to update the crate index.
812 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
813 #t)))))))))
814
815 (define-public rust-1.27
816 (let ((base-rust
817 (rust-bootstrapped-package rust-1.26 "1.27.2"
818 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs")))
819 (package
820 (inherit base-rust)
821 (source
822 (origin
823 (inherit (package-source base-rust))
824 (patches (map search-patch '("rust-coresimd-doctest.patch"
825 "rust-bootstrap-stage0-test.patch"
826 "rust-1.25-accept-more-detailed-gdb-lines.patch"
827 "rust-reproducible-builds.patch")))))
828 (native-inputs
829 ;; FIXME: Rust 1.27 and some later versions require GDB 8.2 specifically.
830 ;; See <https://bugs.gnu.org/37810>.
831 (alist-replace "gdb" (list gdb-8.2)
832 (package-native-inputs base-rust)))
833 (arguments
834 (substitute-keyword-arguments (package-arguments base-rust)
835 ((#:phases phases)
836 `(modify-phases ,phases
837 (add-before 'install 'mkdir-prefix-paths
838 (lambda* (#:key outputs #:allow-other-keys)
839 ;; As result of https://github.com/rust-lang/rust/issues/36989
840 ;; `prefix' directory should exist before `install' call
841 (mkdir-p (assoc-ref outputs "out"))
842 (mkdir-p (assoc-ref outputs "cargo"))
843 #t))
844 (add-after 'patch-cargo-tests 'disable-thinlto-test
845 (lambda* _
846 ;; thinlto required llvm 6.0 for work
847 (substitute* "src/tools/cargo/tests/testsuite/path.rs"
848 (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works"))
849 #t)))))))))
850
851 (define-public rust-1.28
852 (let ((base-rust
853 (rust-bootstrapped-package rust-1.27 "1.28.0"
854 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx")))
855 (package
856 (inherit base-rust)
857 (source
858 (origin
859 (inherit (package-source base-rust))
860 (patches (map search-patch '("rust-coresimd-doctest.patch"
861 "rust-bootstrap-stage0-test.patch"
862 "rust-1.25-accept-more-detailed-gdb-lines.patch"
863 "rust-reproducible-builds.patch")))))
864 (inputs
865 ;; Use LLVM 6.0
866 (alist-replace "llvm" (list llvm-6)
867 (package-inputs base-rust)))
868 (arguments
869 (substitute-keyword-arguments (package-arguments base-rust)
870 ((#:phases phases)
871 `(modify-phases ,phases
872 (add-after 'configure 'enable-codegen-tests
873 ;; Codegen tests should pass with llvm 6, so enable them.
874 (lambda* _
875 (substitute* "config.toml"
876 (("codegen-tests = false") ""))
877 #t))
878 (add-after 'patch-tests 'disable-amd64-avx-test
879 ;; That test would fail on x86_64 machines without avx.
880 (lambda* _
881 (substitute* "src/test/run-pass/issue-44056.rs"
882 (("only-x86_64") "ignore-test"))
883 #t))
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 (map search-patch '("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 (map search-patch '("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 (arguments
1153 (substitute-keyword-arguments (package-arguments base-rust)
1154 ((#:phases phases)
1155 `(modify-phases ,phases
1156 (replace 'patch-command-exec-tests
1157 ,(patch-command-exec-tests-phase
1158 "src/test/ui/command-exec.rs"))
1159 (add-after 'patch-tests 'patch-command-uid-gid-test
1160 (lambda _
1161 (substitute* "src/test/ui/command-uid-gid.rs"
1162 (("/bin/sh") (which "sh"))
1163 (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength"))
1164 #t)))))))))
1165
1166 (define-public rust-1.39
1167 (let ((base-rust
1168 (rust-bootstrapped-package rust-1.38 "1.39.0"
1169 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl")))
1170 (package
1171 (inherit base-rust)
1172 (arguments
1173 (substitute-keyword-arguments (package-arguments base-rust)
1174 ((#:phases phases)
1175 `(modify-phases ,phases
1176 (replace 'patch-cargo-checksums
1177 ;; The Cargo.lock format changed.
1178 (lambda* _
1179 (use-modules (guix build cargo-utils))
1180 (substitute* "Cargo.lock"
1181 (("(checksum = )\".*\"" all name)
1182 (string-append name "\"" ,%cargo-reference-hash "\"")))
1183 (generate-all-checksums "vendor")
1184 #t)))))))))
1185
1186 (define-public rust rust-1.37)