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 Nils Gillmann <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 Efraim Flashner <efraim@flashner.co.il>
8 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
9 ;;; Copyright © 2018 Danny Milosavljevic <dannym+a@scratchpost.org>
10 ;;; Copyright © 2019 Ivan Petkov <ivanppetkov@gmail.com>
12 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
58 (define %cargo-reference-project-file "/dev/null")
59 (define %cargo-reference-hash
60 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
62 (define* (nix-system->gnu-triplet-for-rust
63 #:optional (system (%current-system)))
65 ("x86_64-linux" "x86_64-unknown-linux-gnu")
66 ("i686-linux" "i686-unknown-linux-gnu")
67 ("armhf-linux" "armv7-unknown-linux-gnueabihf")
68 ("aarch64-linux" "aarch64-unknown-linux-gnu")
69 ("mips64el-linux" "mips64el-unknown-linux-gnuabi64")
70 (_ (nix-system->gnu-triplet system))))
73 (define* (rust-source version hash #:key (patches '()))
76 (uri (string-append "https://static.rust-lang.org/dist/"
77 "rustc-" version "-src.tar.gz"))
78 (sha256 (base32 hash))
79 (modules '((guix build utils)))
80 (snippet '(begin (delete-file-recursively "src/llvm") #t))
81 (patches (map search-patch patches))))
83 (define* (rust-bootstrapped-package base-rust version checksum
85 "Bootstrap rust VERSION with source checksum CHECKSUM patched with PATCHES using BASE-RUST."
90 (rust-source version checksum #:patches patches))
92 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
93 (alist-replace "rustc-bootstrap" (list base-rust)
94 (package-native-inputs base-rust))))))
97 (let ((rustc-version "1.19.0"))
104 (url "https://github.com/thepowersgang/mrustc.git")
105 (commit (string-append "v" version))))
106 (file-name (git-file-name name version))
109 "0a7v8ccyzp1sdkwni8h1698hxpfz2sxhcpx42n6l2pbm0rbjp08i"))))
110 (outputs '("out" "cargo"))
111 (build-system gnu-build-system)
113 `(("llvm" ,llvm-3.9.1)))
117 ;; Required for the libstd sources.
119 ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))))
121 `(#:test-target "local_tests"
122 #:make-flags (list (string-append "LLVM_CONFIG="
123 (assoc-ref %build-inputs "llvm")
126 (modify-phases %standard-phases
127 (add-after 'unpack 'patch-date
129 (substitute* "Makefile"
130 (("shell date") "shell date -d @1"))
132 (add-after 'patch-date 'unpack-target-compiler
133 (lambda* (#:key inputs outputs #:allow-other-keys)
134 (substitute* "minicargo.mk"
135 ;; Don't try to build LLVM.
136 (("^[$][(]LLVM_CONFIG[)]:") "xxx:")
137 ;; Build for the correct target architecture.
138 (("^RUSTC_TARGET := x86_64-unknown-linux-gnu")
139 (string-append "RUSTC_TARGET := "
140 ,(or (%current-target-system)
141 (nix-system->gnu-triplet-for-rust)))))
142 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
143 (chdir "rustc-1.19.0-src")
144 (invoke "patch" "-p0" "../rust_src.patch")
148 (lambda* (#:key inputs #:allow-other-keys)
149 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
151 (add-after 'build 'build-minicargo
153 (for-each (lambda (target)
154 (invoke "make" "-f" "minicargo.mk" target))
155 '("output/libstd.hir" "output/libpanic_unwind.hir"
156 "output/libproc_macro.hir" "output/libtest.hir"))
157 ;; Technically the above already does it - but we want to be clear.
158 (invoke "make" "-C" "tools/minicargo")))
160 (lambda* (#:key inputs outputs #:allow-other-keys)
161 (let* ((out (assoc-ref outputs "out"))
162 (bin (string-append out "/bin"))
163 (tools-bin (string-append out "/tools/bin"))
164 (cargo-out (assoc-ref outputs "cargo"))
165 (cargo-bin (string-append cargo-out "/bin"))
166 (lib (string-append out "/lib"))
167 (lib/rust (string-append lib "/mrust"))
168 (gcc (assoc-ref inputs "gcc")))
169 ;; These files are not reproducible.
170 (for-each delete-file (find-files "output" "\\.txt$"))
171 (delete-file-recursively "output/local_tests")
173 (copy-recursively "output" lib/rust)
176 (install-file "bin/mrustc" bin)
177 ;; minicargo uses relative paths to resolve mrustc.
178 (install-file "tools/bin/minicargo" tools-bin)
179 (install-file "tools/bin/minicargo" cargo-bin)
181 (synopsis "Compiler for the Rust progamming language")
182 (description "Rust is a systems programming language that provides memory
183 safety and thread safety guarantees.")
184 (home-page "https://github.com/thepowersgang/mrustc")
186 (license (list license:asl2.0 license:expat)))))
192 (source (rust-source version "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"
193 #:patches '("rust-1.19-mrustc.patch")))
194 (outputs '("out" "cargo"))
195 (properties '((timeout . 72000) ;20 hours
196 (max-silent-time . 18000))) ;5 hours (for armel)
198 `(#:imported-modules ,%cargo-utils-modules ;for `generate-checksums'
199 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
201 (modify-phases %standard-phases
202 (add-after 'unpack 'set-env
203 (lambda* (#:key inputs #:allow-other-keys)
204 ;; Disable test for cross compilation support.
205 (setenv "CFG_DISABLE_CROSS_TESTS" "1")
206 (setenv "SHELL" (which "sh"))
207 (setenv "CONFIG_SHELL" (which "sh"))
208 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
209 ;; guix llvm-3.9.1 package installs only shared libraries
210 (setenv "LLVM_LINK_SHARED" "1")
212 (add-after 'unpack 'patch-cargo-tomls
213 (lambda* (#:key inputs outputs #:allow-other-keys)
214 (substitute* "src/librustc_errors/Cargo.toml"
215 (("[[]dependencies[]]") "
219 (substitute* "src/librustc/Cargo.toml"
220 (("[[]dependencies[]]") "
222 getopts = { path = \"../libgetopts\" }
224 (substitute* "src/librustdoc/Cargo.toml"
225 (("[[]dependencies[]]") "
227 test = { path = \"../libtest\" }
230 (add-after 'unpack 'patch-tests
231 (lambda* (#:key inputs #:allow-other-keys)
232 (let ((bash (assoc-ref inputs "bash")))
233 (substitute* "src/libstd/process.rs"
234 ;; The newline is intentional.
235 ;; There's a line length "tidy" check in Rust which would
237 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
238 (substitute* "src/libstd/net/tcp.rs"
239 ;; There is no network in build environment
240 (("fn connect_timeout_unroutable")
241 "#[ignore]\nfn connect_timeout_unroutable"))
242 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
243 (substitute* "src/libstd/sys/unix/process/process_common.rs"
244 (("fn test_process_mask") "#[allow(unused_attributes)]
246 fn test_process_mask"))
248 (add-after 'patch-tests 'patch-aarch64-test
250 (substitute* "src/librustc_back/dynamic_lib.rs"
251 ;; This test is known to fail on aarch64 and powerpc64le:
252 ;; https://github.com/rust-lang/rust/issues/45410
253 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
255 (add-after 'patch-tests 'use-readelf-for-tests
257 ;; nm doesn't recognize the file format because of the
258 ;; nonstandard sections used by the Rust compiler, but readelf
260 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
264 (add-after 'patch-tests 'remove-unsupported-tests
266 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
267 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
268 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
270 (add-after 'patch-source-shebangs 'patch-cargo-checksums
272 (substitute* "src/Cargo.lock"
273 (("(\"checksum .* = )\".*\"" all name)
274 (string-append name "\"" ,%cargo-reference-hash "\"")))
277 (use-modules (guix build cargo-utils))
278 (delete-file filename)
279 (let* ((dir (dirname filename)))
280 (display (string-append
281 "patch-cargo-checksums: generate-checksums for "
283 (generate-checksums dir ,%cargo-reference-project-file)))
284 (find-files "src/vendor" ".cargo-checksum.json"))
286 ;; This phase is overridden by newer versions.
289 ;; This phase is overridden by newer versions.
291 (lambda* (#:key inputs outputs #:allow-other-keys)
292 (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap")))
293 (setenv "CFG_COMPILER_HOST_TRIPLE"
294 ,(nix-system->gnu-triplet (%current-system)))
295 (setenv "CFG_RELEASE" "")
296 (setenv "CFG_RELEASE_CHANNEL" "stable")
297 (setenv "CFG_LIBDIR_RELATIVE" "lib")
298 (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
299 ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path.
301 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
302 "src/rustc" "--vendor-dir" "src/vendor"
303 "--output-dir" "output/rustc-build"
304 "-L" (string-append rustc-bootstrap "/lib/mrust")
306 (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
307 (setenv "CFG_RELEASE" #f)
308 (setenv "CFG_RELEASE_CHANNEL" #f)
309 (setenv "CFG_VERSION" #f)
310 (setenv "CFG_PREFIX" #f)
311 (setenv "CFG_LIBDIR_RELATIVE" #f)
312 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
313 "src/tools/cargo" "--vendor-dir" "src/vendor"
314 "--output-dir" "output/cargo-build"
316 "-L" (string-append rustc-bootstrap "/lib/mrust")
318 ;; Now use the newly-built rustc to build the libraries.
319 ;; One day that could be replaced by:
320 ;; (invoke "output/cargo-build/cargo" "build"
321 ;; "--manifest-path" "src/bootstrap/Cargo.toml"
322 ;; "--verbose") ; "--locked" "--frozen"
323 ;; but right now, Cargo has problems with libstd's circular
325 (mkdir-p "output/target-libs")
326 (for-each (match-lambda
331 "output/rustc-build/rustc"
332 "-C" (string-append "linker="
334 ;; Required for libterm.
335 "-Z" "force-unstable-if-unmarked"
336 "-L" "output/target-libs"
337 (string-append "src/" name "/lib.rs")
339 (string-append "output/target-libs/"
340 (car (string-split name #\/))
348 ("liblibc/src" "--cfg" "stdbuild")
349 ("libunwind" "-l" "gcc_s")
350 ("libcompiler_builtins")
353 ;; Uses "cc" to link.
354 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
357 ;; Test dependencies:
363 ;; This phase is overridden by newer versions.
366 ;; This phase is overridden by newer versions.
368 (lambda* (#:key inputs outputs #:allow-other-keys)
369 (let* ((out (assoc-ref outputs "out"))
370 (target-system ,(or (%current-target-system)
371 (nix-system->gnu-triplet
373 (out-libs (string-append out "/lib/rustlib/"
374 target-system "/lib")))
375 ;(setenv "CFG_PREFIX" out)
377 (copy-recursively "output/target-libs" out-libs)
378 (install-file "output/rustc-build/rustc"
379 (string-append out "/bin"))
380 (install-file "output/rustc-build/rustdoc"
381 (string-append out "/bin"))
382 (install-file "output/cargo-build/cargo"
383 (string-append (assoc-ref outputs "cargo")
386 (build-system gnu-build-system)
388 `(("bison" ,bison) ; For the tests
390 ("flex" ,flex) ; For the tests
391 ("gdb" ,gdb) ; For the tests
392 ("procps" ,procps) ; For the tests
393 ("python-2" ,python-2)
394 ("rustc-bootstrap" ,mrustc)
395 ("cargo-bootstrap" ,mrustc "cargo")
396 ("pkg-config" ,pkg-config) ; For "cargo"
399 `(("jemalloc" ,jemalloc-4.5.0)
402 ("libssh2" ,libssh2) ; For "cargo"
403 ("libcurl" ,curl))) ; For "cargo"
405 ;; rustc invokes gcc, so we need to set its search paths accordingly.
406 ;; Note: duplicate its value here to cope with circular dependencies among
407 ;; modules (see <https://bugs.gnu.org/31392>).
409 (list (search-path-specification
410 (variable "C_INCLUDE_PATH")
411 (files '("include")))
412 (search-path-specification
413 (variable "CPLUS_INCLUDE_PATH")
414 (files '("include")))
415 (search-path-specification
416 (variable "LIBRARY_PATH")
417 (files '("lib" "lib64")))))
419 (synopsis "Compiler for the Rust progamming language")
420 (description "Rust is a systems programming language that provides memory
421 safety and thread safety guarantees.")
422 (home-page "https://www.rust-lang.org")
424 (license (list license:asl2.0 license:expat))))
426 (define-public rust-1.20
428 (rust-bootstrapped-package rust-1.19 "1.20.0"
429 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
432 (outputs '("out" "doc" "cargo"))
435 (substitute-keyword-arguments (package-arguments rust-1.19)
437 `(modify-phases ,phases
438 (add-after 'patch-tests 'patch-cargo-tests
440 (substitute* "src/tools/cargo/tests/build.rs"
441 (("/usr/bin/env") (which "env"))
442 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
443 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
444 (substitute* "src/tools/cargo/tests/death.rs"
445 ;; This is stuck when built in container.
446 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
447 ;; Prints test output in the wrong order when built on
449 (substitute* "src/tools/cargo/tests/test.rs"
450 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
452 ;; These tests pull in a dependency on "git", which changes
453 ;; too frequently take part in the Rust toolchain.
454 (substitute* "src/tools/cargo/tests/new.rs"
455 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
456 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
457 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
459 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
460 ;; https://github.com/rust-lang/rust/issues/47863
462 (substitute* "src/test/run-pass/out-of-stack.rs"
463 (("// ignore-android") "// ignore-test\n// ignore-android"))
466 (lambda* (#:key inputs outputs #:allow-other-keys)
467 (let* ((out (assoc-ref outputs "out"))
468 (doc (assoc-ref outputs "doc"))
469 (gcc (assoc-ref inputs "gcc"))
470 (gdb (assoc-ref inputs "gdb"))
471 (binutils (assoc-ref inputs "binutils"))
472 (python (assoc-ref inputs "python-2"))
473 (rustc (assoc-ref inputs "rustc-bootstrap"))
474 (cargo (assoc-ref inputs "cargo-bootstrap"))
475 (llvm (assoc-ref inputs "llvm"))
476 (jemalloc (assoc-ref inputs "jemalloc")))
477 (call-with-output-file "config.toml"
479 (display (string-append "
482 cargo = \"" cargo "/bin/cargo" "\"
483 rustc = \"" rustc "/bin/rustc" "\"
485 python = \"" python "/bin/python2" "\"
486 gdb = \"" gdb "/bin/gdb" "\"
491 docdir = \"" doc "/share/doc/rust" "\"
494 default-linker = \"" gcc "/bin/gcc" "\"
497 " ;; There are 2 failed codegen tests:
498 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
499 ;; These tests require a patched LLVM
500 "codegen-tests = false
501 [target." ,(nix-system->gnu-triplet-for-rust) "]
502 llvm-config = \"" llvm "/bin/llvm-config" "\"
503 cc = \"" gcc "/bin/gcc" "\"
504 cxx = \"" gcc "/bin/g++" "\"
505 ar = \"" binutils "/bin/ar" "\"
506 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
510 (add-after 'configure 'provide-cc
511 (lambda* (#:key inputs #:allow-other-keys)
512 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
514 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
516 (add-after 'provide-cc 'configure-archiver
517 (lambda* (#:key inputs #:allow-other-keys)
518 (substitute* "src/build_helper/lib.rs"
519 ;; Make sure "ar" is always used as the archiver.
520 (("\"musl\"") "\"\"")
521 ;; Then substitute "ar" by our name.
522 (("\"ar\"") (string-append "\""
523 (assoc-ref inputs "binutils")
526 (delete 'patch-cargo-tomls)
527 (add-before 'build 'reset-timestamps-after-changes
531 ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist".
532 ;; Therefore, use timestamp 1.
533 (utime filename 1 1 1 1))
534 (find-files "." #:directories? #t))
538 (invoke "./x.py" "build")
539 (invoke "./x.py" "build" "src/tools/cargo")))
542 ;; Disable parallel execution to prevent EAGAIN errors when
544 (invoke "./x.py" "-j1" "test" "-vv")
545 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
548 (lambda* (#:key outputs #:allow-other-keys)
549 (invoke "./x.py" "install")
550 (substitute* "config.toml"
551 ;; replace prefix to specific output
552 (("prefix = \"[^\"]*\"")
553 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
554 (invoke "./x.py" "install" "cargo")))
555 (add-after 'install 'wrap-rustc
556 (lambda* (#:key inputs outputs #:allow-other-keys)
557 (let ((out (assoc-ref outputs "out"))
558 (libc (assoc-ref inputs "libc"))
559 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
560 ;; Let gcc find ld and libc startup files.
561 (wrap-program (string-append out "/bin/rustc")
562 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
563 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
566 (define-public rust-1.21
567 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
568 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
572 (substitute-keyword-arguments (package-arguments base-rust)
574 `(modify-phases ,phases
575 (add-after 'configure 'remove-ar
576 (lambda* (#:key inputs #:allow-other-keys)
577 ;; Remove because toml complains about "unknown field".
578 (substitute* "config.toml"
582 (define-public rust-1.22
583 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
584 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
588 (substitute-keyword-arguments (package-arguments base-rust)
590 `(modify-phases ,phases
591 (add-after 'unpack 'remove-flaky-test
593 ;; See <https://github.com/rust-lang/rust/issues/43402>.
594 (when (file-exists? "src/test/run-make/issue-26092")
595 (delete-file-recursively "src/test/run-make/issue-26092"))
598 (define-public rust-1.23
599 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
600 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
604 (substitute-keyword-arguments (package-arguments base-rust)
606 `(modify-phases ,phases
607 (delete 'configure-archiver)
609 (add-after 'unpack 'dont-build-native
611 ;; XXX: Revisit this when we use gcc 6.
612 (substitute* "src/binaryen/CMakeLists.txt"
613 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
616 (define-public rust-1.24
618 (rust-bootstrapped-package rust-1.23 "1.24.1"
619 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
623 (substitute-keyword-arguments (package-arguments base-rust)
625 `(modify-phases ,phases
626 (delete 'use-readelf-for-tests)
627 (replace 'patch-aarch64-test
629 (substitute* "src/librustc_metadata/dynamic_lib.rs"
630 ;; This test is known to fail on aarch64 and powerpc64le:
631 ;; https://github.com/rust-lang/rust/issues/45410
632 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
635 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
636 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
637 ;;; Keep using llvm 3.9.1 until builds become determenistic
638 (define-public rust-1.25
640 (rust-bootstrapped-package rust-1.24 "1.25.0"
641 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf"
642 #:patches '("rust-1.25-accept-more-detailed-gdb-lines.patch"))))
646 (substitute-keyword-arguments (package-arguments base-rust)
648 `(modify-phases ,phases
649 (add-after 'patch-cargo-tests 'patch-cargo-index-update
651 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
652 ;; This test wants to update the crate index.
653 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
655 (replace 'patch-aarch64-test
657 (substitute* "src/librustc_metadata/dynamic_lib.rs"
658 ;; This test is known to fail on aarch64 and powerpc64le:
659 ;; https://github.com/rust-lang/rust/issues/45410
660 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
661 ;; This test fails on aarch64 with llvm@6.0:
662 ;; https://github.com/rust-lang/rust/issues/49807
663 ;; other possible solution:
664 ;; https://github.com/rust-lang/rust/pull/47688
665 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
667 (delete 'ignore-glibc-2.27-incompatible-test))))))))
669 (define-public rust-1.26
671 (rust-bootstrapped-package rust-1.25 "1.26.2"
672 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv"
673 #:patches '("rust-coresimd-doctest.patch"
674 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
678 (substitute-keyword-arguments (package-arguments base-rust)
680 `(modify-phases ,phases
681 ;; binaryen was replaced with LLD project from LLVM
682 (delete 'dont-build-native)
683 (replace 'remove-unsupported-tests
685 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
686 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
687 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
689 (replace 'patch-cargo-tests
691 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
692 (("/usr/bin/env") (which "env"))
693 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
694 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
695 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
696 ;; This is stuck when built in container.
697 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
698 ;; Prints test output in the wrong order when built on
700 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
701 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
703 ;; Avoid dependency on "git".
704 (substitute* "src/tools/cargo/tests/testsuite/new.rs"
705 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
706 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
707 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
709 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
711 ;; This test failed to work on "nightly" channel builds
712 ;; https://github.com/rust-lang/cargo/issues/5648
713 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
714 (("fn test_resolving_minimum_version_with_transitive_deps")
715 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
717 (replace 'patch-cargo-index-update
719 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
720 ;; This test wants to update the crate index.
721 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
724 (define-public rust-1.27
726 (rust-bootstrapped-package rust-1.26 "1.27.2"
727 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs"
729 '("rust-coresimd-doctest.patch"
730 "rust-bootstrap-stage0-test.patch"
731 "rust-1.25-accept-more-detailed-gdb-lines.patch"
732 "rust-reproducible-builds.patch"))))
736 (substitute-keyword-arguments (package-arguments base-rust)
738 `(modify-phases ,phases
739 (add-before 'install 'mkdir-prefix-paths
740 (lambda* (#:key outputs #:allow-other-keys)
741 ;; As result of https://github.com/rust-lang/rust/issues/36989
742 ;; `prefix' directory should exist before `install' call
743 (mkdir-p (assoc-ref outputs "out"))
744 (mkdir-p (assoc-ref outputs "cargo"))
746 (add-after 'patch-cargo-tests 'disable-thinlto-test
748 ;; thinlto required llvm 6.0 for work
749 (substitute* "src/tools/cargo/tests/testsuite/path.rs"
750 (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works"))
753 (define-public rust-1.28
755 (rust-bootstrapped-package rust-1.27 "1.28.0"
756 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx"
758 '("rust-coresimd-doctest.patch"
759 "rust-bootstrap-stage0-test.patch"
760 "rust-1.25-accept-more-detailed-gdb-lines.patch"
761 "rust-reproducible-builds.patch"))))
766 (alist-replace "llvm" (list llvm-6)
767 (package-inputs base-rust)))
769 (substitute-keyword-arguments (package-arguments base-rust)
771 `(modify-phases ,phases
772 (add-after 'configure 'enable-codegen-tests
773 ;; Codegen tests should pass with llvm 6, so enable them.
775 (substitute* "config.toml"
776 (("codegen-tests = false") ""))
778 (add-after 'patch-tests 'disable-amd64-avx-test
779 ;; That test would fail on x86_64 machines without avx.
781 (substitute* "src/test/run-pass/issue-44056.rs"
782 (("only-x86_64") "ignore-test"))
784 ;; The thinlto test should pass with llvm 6.
785 (delete 'disable-thinlto-test))))))))
787 (define-public rust-1.29
789 (rust-bootstrapped-package rust-1.28 "1.29.2"
790 "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h"
792 '("rust-1.25-accept-more-detailed-gdb-lines.patch"
793 "rust-reproducible-builds.patch"))))
795 (inherit base-rust))))
797 (define-public rust-1.30
799 (rust-bootstrapped-package rust-1.29 "1.30.1"
800 "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn"
802 '("rust-1.25-accept-more-detailed-gdb-lines.patch"
803 "rust-1.30-gdb-llvm.patch"
804 "rust-reproducible-builds.patch"))))
809 (alist-replace "llvm" (list llvm)
810 (package-inputs base-rust)))
812 (substitute-keyword-arguments (package-arguments base-rust)
814 `(modify-phases ,phases
815 (add-after 'patch-cargo-tests 'patch-cargo-env-shebang
816 (lambda* (#:key inputs #:allow-other-keys)
817 (let ((coreutils (assoc-ref inputs "coreutils")))
818 (substitute* "src/tools/cargo/tests/testsuite/fix.rs"
819 ;; Cargo has a test which explicitly sets a
820 ;; RUSTC_WRAPPER environment variable which points
821 ;; to /usr/bin/env. Since it's not a shebang, it
822 ;; needs to be manually patched
823 (("\"/usr/bin/env\"")
824 (string-append "\"" coreutils "/bin/env\"")))
826 (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests
828 (substitute* "src/tools/cargo/tests/testsuite/package.rs"
829 ;; These tests largely check that cargo outputs warning/error
830 ;; messages as expected. It seems that cargo outputs an
831 ;; absolute path to something in the store instead of the
832 ;; expected relative path (e.g. `[..]`) so we'll ignore
834 (("fn include") "#[ignore]\nfn include")
835 (("fn exclude") "#[ignore]\nfn exclude"))
837 ;; Appears that this test isn't currently running and has been
838 ;; moved elsewhere, so the patch doesn't apply.
839 (delete 'disable-amd64-avx-test))))))))
843 (rust-bootstrapped-package rust-1.30 "1.31.1"
844 "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli"
846 '("rust-1.25-accept-more-detailed-gdb-lines.patch"
847 "rust-1.30-gdb-llvm.patch"
848 "rust-reproducible-builds.patch"))))
852 (substitute-keyword-arguments (package-arguments base-rust)
854 `(modify-phases ,phases
855 (add-after 'patch-tests 'patch-command-exec-tests
856 (lambda* (#:key inputs #:allow-other-keys)
857 (let ((coreutils (assoc-ref inputs "coreutils")))
858 (substitute* "src/test/run-pass/command-exec.rs"
859 ;; This test suite includes some tests that the stdlib's
860 ;; `Command` execution properly handles situations where
861 ;; the environment or PATH variable are empty, but this
862 ;; fails since we don't have `echo` available in the usual
863 ;; Linux directories.
864 ;; NB: the leading space is so we don't fail a tidy check
865 ;; for trailing whitespace, and the newlines are to ensure
866 ;; we don't exceed the 100 chars tidy check as well
867 ((" Command::new\\(\"echo\"\\)")
868 (string-append "\nCommand::new(\"" coreutils "/bin/echo\")\n")))
870 (add-after 'patch-tests 'patch-process-docs-rev-cmd
872 ;; Disable some doc tests which depend on the "rev" command
873 ;; https://github.com/rust-lang/rust/pull/58746
874 (substitute* "src/libstd/process.rs"
875 (("```rust") "```rust,no_run"))