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>
11 ;;; This file is part of GNU Guix.
13 ;;; GNU Guix is free software; you can redistribute it and/or modify it
14 ;;; under the terms of the GNU General Public License as published by
15 ;;; the Free Software Foundation; either version 3 of the License, or (at
16 ;;; your option) any later version.
18 ;;; GNU Guix is distributed in the hope that it will be useful, but
19 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;;; GNU General Public License for more details.
23 ;;; You should have received a copy of the GNU General Public License
24 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
26 (define-module (gnu packages rust)
27 #:use-module (gnu packages base)
28 #:use-module (gnu packages bison)
29 #:use-module (gnu packages bootstrap)
30 #:use-module (gnu packages cmake)
31 #:use-module (gnu packages compression)
32 #:use-module (gnu packages curl)
33 #:use-module (gnu packages elf)
34 #:use-module (gnu packages flex)
35 #:use-module (gnu packages gcc)
36 #:use-module (gnu packages gdb)
37 #:use-module (gnu packages jemalloc)
38 #:use-module (gnu packages linux)
39 #:use-module (gnu packages llvm)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages python)
42 #:use-module (gnu packages ssh)
43 #:use-module (gnu packages tls)
44 #:use-module (gnu packages)
45 #:use-module (guix build-system cargo)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system trivial)
48 #:use-module (guix download)
49 #:use-module (guix git-download)
50 #:use-module ((guix licenses) #:prefix license:)
51 #:use-module (guix packages)
52 #:use-module ((guix build utils) #:select (alist-replace))
53 #:use-module (guix utils)
54 #:use-module (ice-9 match)
55 #:use-module (srfi srfi-26))
57 (define %cargo-reference-project-file "/dev/null")
58 (define %cargo-reference-hash
59 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
61 (define* (nix-system->gnu-triplet-for-rust
62 #:optional (system (%current-system)))
64 ("x86_64-linux" "x86_64-unknown-linux-gnu")
65 ("i686-linux" "i686-unknown-linux-gnu")
66 ("armhf-linux" "armv7-unknown-linux-gnueabihf")
67 ("aarch64-linux" "aarch64-unknown-linux-gnu")
68 ("mips64el-linux" "mips64el-unknown-linux-gnuabi64")
69 (_ (nix-system->gnu-triplet system))))
72 (define* (rust-source version hash #:key (patches '()))
75 (uri (string-append "https://static.rust-lang.org/dist/"
76 "rustc-" version "-src.tar.gz"))
77 (sha256 (base32 hash))
78 (modules '((guix build utils)))
79 (snippet '(begin (delete-file-recursively "src/llvm") #t))
80 (patches (map search-patch patches))))
82 (define* (rust-bootstrapped-package base-rust version checksum
84 "Bootstrap rust VERSION with source checksum CHECKSUM patched with PATCHES using BASE-RUST."
89 (rust-source version checksum #:patches patches))
91 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
92 (alist-replace "rustc-bootstrap" (list base-rust)
93 (package-native-inputs base-rust))))))
96 (let ((rustc-version "1.19.0"))
103 (url "https://github.com/thepowersgang/mrustc.git")
104 (commit (string-append "v" version))))
105 (file-name (git-file-name name version))
108 "0a7v8ccyzp1sdkwni8h1698hxpfz2sxhcpx42n6l2pbm0rbjp08i"))))
109 (outputs '("out" "cargo"))
110 (build-system gnu-build-system)
112 `(("llvm" ,llvm-3.9.1)))
116 ;; Required for the libstd sources.
118 ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))))
120 `(#:test-target "local_tests"
121 #:make-flags (list (string-append "LLVM_CONFIG="
122 (assoc-ref %build-inputs "llvm")
125 (modify-phases %standard-phases
126 (add-after 'unpack 'patch-date
128 (substitute* "Makefile"
129 (("shell date") "shell date -d @1"))
131 (add-after 'patch-date 'unpack-target-compiler
132 (lambda* (#:key inputs outputs #:allow-other-keys)
133 (substitute* "minicargo.mk"
134 ;; Don't try to build LLVM.
135 (("^[$][(]LLVM_CONFIG[)]:") "xxx:")
136 ;; Build for the correct target architecture.
137 (("^RUSTC_TARGET := x86_64-unknown-linux-gnu")
138 (string-append "RUSTC_TARGET := "
139 ,(or (%current-target-system)
140 (nix-system->gnu-triplet-for-rust)))))
141 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
142 (chdir "rustc-1.19.0-src")
143 (invoke "patch" "-p0" "../rust_src.patch")
147 (lambda* (#:key inputs #:allow-other-keys)
148 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
150 (add-after 'build 'build-minicargo
152 (for-each (lambda (target)
153 (invoke "make" "-f" "minicargo.mk" target))
154 '("output/libstd.hir" "output/libpanic_unwind.hir"
155 "output/libproc_macro.hir" "output/libtest.hir"))
156 ;; Technically the above already does it - but we want to be clear.
157 (invoke "make" "-C" "tools/minicargo")))
159 (lambda* (#:key inputs outputs #:allow-other-keys)
160 (let* ((out (assoc-ref outputs "out"))
161 (bin (string-append out "/bin"))
162 (tools-bin (string-append out "/tools/bin"))
163 (cargo-out (assoc-ref outputs "cargo"))
164 (cargo-bin (string-append cargo-out "/bin"))
165 (lib (string-append out "/lib"))
166 (lib/rust (string-append lib "/mrust"))
167 (gcc (assoc-ref inputs "gcc")))
168 ;; These files are not reproducible.
169 (for-each delete-file (find-files "output" "\\.txt$"))
170 (delete-file-recursively "output/local_tests")
172 (copy-recursively "output" lib/rust)
175 (install-file "bin/mrustc" bin)
176 ;; minicargo uses relative paths to resolve mrustc.
177 (install-file "tools/bin/minicargo" tools-bin)
178 (install-file "tools/bin/minicargo" cargo-bin)
180 (synopsis "Compiler for the Rust progamming language")
181 (description "Rust is a systems programming language that provides memory
182 safety and thread safety guarantees.")
183 (home-page "https://github.com/thepowersgang/mrustc")
185 (license (list license:asl2.0 license:expat)))))
191 (source (rust-source version "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"
192 #:patches '("rust-1.19-mrustc.patch")))
193 (outputs '("out" "cargo"))
194 (properties '((timeout . 72000) ;20 hours
195 (max-silent-time . 18000))) ;5 hours (for armel)
197 `(#:imported-modules ,%cargo-build-system-modules ;for `generate-checksums'
198 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
200 (modify-phases %standard-phases
201 (add-after 'unpack 'set-env
202 (lambda* (#:key inputs #:allow-other-keys)
203 ;; Disable test for cross compilation support.
204 (setenv "CFG_DISABLE_CROSS_TESTS" "1")
205 (setenv "SHELL" (which "sh"))
206 (setenv "CONFIG_SHELL" (which "sh"))
207 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
208 ;; guix llvm-3.9.1 package installs only shared libraries
209 (setenv "LLVM_LINK_SHARED" "1")
211 (add-after 'unpack 'patch-cargo-tomls
212 (lambda* (#:key inputs outputs #:allow-other-keys)
213 (substitute* "src/librustc_errors/Cargo.toml"
214 (("[[]dependencies[]]") "
218 (substitute* "src/librustc/Cargo.toml"
219 (("[[]dependencies[]]") "
221 getopts = { path = \"../libgetopts\" }
223 (substitute* "src/librustdoc/Cargo.toml"
224 (("[[]dependencies[]]") "
226 test = { path = \"../libtest\" }
229 (add-after 'unpack 'patch-tests
230 (lambda* (#:key inputs #:allow-other-keys)
231 (let ((bash (assoc-ref inputs "bash")))
232 (substitute* "src/libstd/process.rs"
233 ;; The newline is intentional.
234 ;; There's a line length "tidy" check in Rust which would
236 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
237 (substitute* "src/libstd/net/tcp.rs"
238 ;; There is no network in build environment
239 (("fn connect_timeout_unroutable")
240 "#[ignore]\nfn connect_timeout_unroutable"))
241 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
242 (substitute* "src/libstd/sys/unix/process/process_common.rs"
243 (("fn test_process_mask") "#[allow(unused_attributes)]
245 fn test_process_mask"))
247 (add-after 'patch-tests 'patch-aarch64-test
249 (substitute* "src/librustc_back/dynamic_lib.rs"
250 ;; This test is known to fail on aarch64 and powerpc64le:
251 ;; https://github.com/rust-lang/rust/issues/45410
252 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
254 (add-after 'patch-tests 'use-readelf-for-tests
256 ;; nm doesn't recognize the file format because of the
257 ;; nonstandard sections used by the Rust compiler, but readelf
259 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
263 (add-after 'patch-tests 'remove-unsupported-tests
265 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
266 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
267 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
269 (add-after 'patch-source-shebangs 'patch-cargo-checksums
271 (substitute* "src/Cargo.lock"
272 (("(\"checksum .* = )\".*\"" all name)
273 (string-append name "\"" ,%cargo-reference-hash "\"")))
276 (use-modules (guix build cargo-build-system))
277 (delete-file filename)
278 (let* ((dir (dirname filename)))
279 (display (string-append
280 "patch-cargo-checksums: generate-checksums for "
282 (generate-checksums dir ,%cargo-reference-project-file)))
283 (find-files "src/vendor" ".cargo-checksum.json"))
285 ;; This phase is overridden by newer versions.
288 ;; This phase is overridden by newer versions.
290 (lambda* (#:key inputs outputs #:allow-other-keys)
291 (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap")))
292 (setenv "CFG_COMPILER_HOST_TRIPLE"
293 ,(nix-system->gnu-triplet (%current-system)))
294 (setenv "CFG_RELEASE" "")
295 (setenv "CFG_RELEASE_CHANNEL" "stable")
296 (setenv "CFG_LIBDIR_RELATIVE" "lib")
297 (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
298 ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path.
300 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
301 "src/rustc" "--vendor-dir" "src/vendor"
302 "--output-dir" "output/rustc-build"
303 "-L" (string-append rustc-bootstrap "/lib/mrust")
305 (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
306 (setenv "CFG_RELEASE" #f)
307 (setenv "CFG_RELEASE_CHANNEL" #f)
308 (setenv "CFG_VERSION" #f)
309 (setenv "CFG_PREFIX" #f)
310 (setenv "CFG_LIBDIR_RELATIVE" #f)
311 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
312 "src/tools/cargo" "--vendor-dir" "src/vendor"
313 "--output-dir" "output/cargo-build"
315 "-L" (string-append rustc-bootstrap "/lib/mrust")
317 ;; Now use the newly-built rustc to build the libraries.
318 ;; One day that could be replaced by:
319 ;; (invoke "output/cargo-build/cargo" "build"
320 ;; "--manifest-path" "src/bootstrap/Cargo.toml"
321 ;; "--verbose") ; "--locked" "--frozen"
322 ;; but right now, Cargo has problems with libstd's circular
324 (mkdir-p "output/target-libs")
325 (for-each (match-lambda
330 "output/rustc-build/rustc"
331 "-C" (string-append "linker="
333 ;; Required for libterm.
334 "-Z" "force-unstable-if-unmarked"
335 "-L" "output/target-libs"
336 (string-append "src/" name "/lib.rs")
338 (string-append "output/target-libs/"
339 (car (string-split name #\/))
347 ("liblibc/src" "--cfg" "stdbuild")
348 ("libunwind" "-l" "gcc_s")
349 ("libcompiler_builtins")
352 ;; Uses "cc" to link.
353 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
356 ;; Test dependencies:
362 ;; This phase is overridden by newer versions.
365 ;; This phase is overridden by newer versions.
367 (lambda* (#:key inputs outputs #:allow-other-keys)
368 (let* ((out (assoc-ref outputs "out"))
369 (target-system ,(or (%current-target-system)
370 (nix-system->gnu-triplet
372 (out-libs (string-append out "/lib/rustlib/"
373 target-system "/lib")))
374 ;(setenv "CFG_PREFIX" out)
376 (copy-recursively "output/target-libs" out-libs)
377 (install-file "output/rustc-build/rustc"
378 (string-append out "/bin"))
379 (install-file "output/rustc-build/rustdoc"
380 (string-append out "/bin"))
381 (install-file "output/cargo-build/cargo"
382 (string-append (assoc-ref outputs "cargo")
385 (build-system gnu-build-system)
387 `(("bison" ,bison) ; For the tests
389 ("flex" ,flex) ; For the tests
390 ("gdb" ,gdb) ; For the tests
391 ("procps" ,procps) ; For the tests
392 ("python-2" ,python-2)
393 ("rustc-bootstrap" ,mrustc)
394 ("cargo-bootstrap" ,mrustc "cargo")
395 ("pkg-config" ,pkg-config) ; For "cargo"
398 `(("jemalloc" ,jemalloc-4.5.0)
401 ("libssh2" ,libssh2) ; For "cargo"
402 ("libcurl" ,curl))) ; For "cargo"
404 ;; rustc invokes gcc, so we need to set its search paths accordingly.
405 ;; Note: duplicate its value here to cope with circular dependencies among
406 ;; modules (see <https://bugs.gnu.org/31392>).
408 (list (search-path-specification
410 (files '("include")))
411 (search-path-specification
412 (variable "LIBRARY_PATH")
413 (files '("lib" "lib64")))))
415 (synopsis "Compiler for the Rust progamming language")
416 (description "Rust is a systems programming language that provides memory
417 safety and thread safety guarantees.")
418 (home-page "https://www.rust-lang.org")
420 (license (list license:asl2.0 license:expat))))
422 (define-public rust-1.20
424 (rust-bootstrapped-package rust-1.19 "1.20.0"
425 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
428 (outputs '("out" "doc" "cargo"))
431 (substitute-keyword-arguments (package-arguments rust-1.19)
433 `(modify-phases ,phases
434 (add-after 'patch-tests 'patch-cargo-tests
436 (substitute* "src/tools/cargo/tests/build.rs"
437 (("/usr/bin/env") (which "env"))
438 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
439 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
440 (substitute* "src/tools/cargo/tests/death.rs"
441 ;; This is stuck when built in container.
442 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
443 ;; Prints test output in the wrong order when built on
445 (substitute* "src/tools/cargo/tests/test.rs"
446 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
448 ;; These tests pull in a dependency on "git", which changes
449 ;; too frequently take part in the Rust toolchain.
450 (substitute* "src/tools/cargo/tests/new.rs"
451 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
452 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
453 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
455 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
456 ;; https://github.com/rust-lang/rust/issues/47863
458 (substitute* "src/test/run-pass/out-of-stack.rs"
459 (("// ignore-android") "// ignore-test\n// ignore-android"))
462 (lambda* (#:key inputs outputs #:allow-other-keys)
463 (let* ((out (assoc-ref outputs "out"))
464 (doc (assoc-ref outputs "doc"))
465 (gcc (assoc-ref inputs "gcc"))
466 (gdb (assoc-ref inputs "gdb"))
467 (binutils (assoc-ref inputs "binutils"))
468 (python (assoc-ref inputs "python-2"))
469 (rustc (assoc-ref inputs "rustc-bootstrap"))
470 (cargo (assoc-ref inputs "cargo-bootstrap"))
471 (llvm (assoc-ref inputs "llvm"))
472 (jemalloc (assoc-ref inputs "jemalloc")))
473 (call-with-output-file "config.toml"
475 (display (string-append "
478 cargo = \"" cargo "/bin/cargo" "\"
479 rustc = \"" rustc "/bin/rustc" "\"
481 python = \"" python "/bin/python2" "\"
482 gdb = \"" gdb "/bin/gdb" "\"
487 docdir = \"" doc "/share/doc/rust" "\"
490 default-linker = \"" gcc "/bin/gcc" "\"
493 " ;; There are 2 failed codegen tests:
494 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
495 ;; These tests require a patched LLVM
496 "codegen-tests = false
497 [target." ,(nix-system->gnu-triplet-for-rust) "]
498 llvm-config = \"" llvm "/bin/llvm-config" "\"
499 cc = \"" gcc "/bin/gcc" "\"
500 cxx = \"" gcc "/bin/g++" "\"
501 ar = \"" binutils "/bin/ar" "\"
502 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
506 (add-after 'configure 'provide-cc
507 (lambda* (#:key inputs #:allow-other-keys)
508 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
510 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
512 (add-after 'provide-cc 'configure-archiver
513 (lambda* (#:key inputs #:allow-other-keys)
514 (substitute* "src/build_helper/lib.rs"
515 ;; Make sure "ar" is always used as the archiver.
516 (("\"musl\"") "\"\"")
517 ;; Then substitute "ar" by our name.
518 (("\"ar\"") (string-append "\""
519 (assoc-ref inputs "binutils")
522 (delete 'patch-cargo-tomls)
523 (add-before 'build 'reset-timestamps-after-changes
527 ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist".
528 ;; Therefore, use timestamp 1.
529 (utime filename 1 1 1 1))
530 (find-files "." #:directories? #t))
534 (invoke "./x.py" "build")
535 (invoke "./x.py" "build" "src/tools/cargo")))
538 ;; Disable parallel execution to prevent EAGAIN errors when
540 (invoke "./x.py" "-j1" "test" "-vv")
541 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
544 (lambda* (#:key outputs #:allow-other-keys)
545 (invoke "./x.py" "install")
546 (substitute* "config.toml"
547 ;; replace prefix to specific output
548 (("prefix = \"[^\"]*\"")
549 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
550 (invoke "./x.py" "install" "cargo")))
551 (add-after 'install 'wrap-rustc
552 (lambda* (#:key inputs outputs #:allow-other-keys)
553 (let ((out (assoc-ref outputs "out"))
554 (libc (assoc-ref inputs "libc"))
555 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
556 ;; Let gcc find ld and libc startup files.
557 (wrap-program (string-append out "/bin/rustc")
558 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
559 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
562 (define-public rust-1.21
563 (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0"
564 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp")))
568 (substitute-keyword-arguments (package-arguments base-rust)
570 `(modify-phases ,phases
571 (add-after 'configure 'remove-ar
572 (lambda* (#:key inputs #:allow-other-keys)
573 ;; Remove because toml complains about "unknown field".
574 (substitute* "config.toml"
578 (define-public rust-1.22
579 (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1"
580 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb")))
584 (substitute-keyword-arguments (package-arguments base-rust)
586 `(modify-phases ,phases
587 (add-after 'unpack 'remove-flaky-test
589 ;; See <https://github.com/rust-lang/rust/issues/43402>.
590 (when (file-exists? "src/test/run-make/issue-26092")
591 (delete-file-recursively "src/test/run-make/issue-26092"))
594 (define-public rust-1.23
595 (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0"
596 "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")))
600 (substitute-keyword-arguments (package-arguments base-rust)
602 `(modify-phases ,phases
603 (delete 'configure-archiver)
605 (add-after 'unpack 'dont-build-native
607 ;; XXX: Revisit this when we use gcc 6.
608 (substitute* "src/binaryen/CMakeLists.txt"
609 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
612 (define-public rust-1.24
614 (rust-bootstrapped-package rust-1.23 "1.24.1"
615 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
619 (substitute-keyword-arguments (package-arguments base-rust)
621 `(modify-phases ,phases
622 (delete 'use-readelf-for-tests)
623 (replace 'patch-aarch64-test
625 (substitute* "src/librustc_metadata/dynamic_lib.rs"
626 ;; This test is known to fail on aarch64 and powerpc64le:
627 ;; https://github.com/rust-lang/rust/issues/45410
628 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
631 ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is
632 ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>.
633 ;;; Keep using llvm 3.9.1 until builds become determenistic
634 (define-public rust-1.25
636 (rust-bootstrapped-package rust-1.24 "1.25.0"
637 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf"
638 #:patches '("rust-1.25-accept-more-detailed-gdb-lines.patch"))))
642 (substitute-keyword-arguments (package-arguments base-rust)
644 `(modify-phases ,phases
645 (add-after 'patch-cargo-tests 'patch-cargo-index-update
647 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
648 ;; This test wants to update the crate index.
649 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
651 (replace 'patch-aarch64-test
653 (substitute* "src/librustc_metadata/dynamic_lib.rs"
654 ;; This test is known to fail on aarch64 and powerpc64le:
655 ;; https://github.com/rust-lang/rust/issues/45410
656 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
657 ;; This test fails on aarch64 with llvm@6.0:
658 ;; https://github.com/rust-lang/rust/issues/49807
659 ;; other possible solution:
660 ;; https://github.com/rust-lang/rust/pull/47688
661 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
663 (delete 'ignore-glibc-2.27-incompatible-test))))))))
665 (define-public rust-1.26
667 (rust-bootstrapped-package rust-1.25 "1.26.2"
668 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv"
669 #:patches '("rust-coresimd-doctest.patch"
670 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
674 (substitute-keyword-arguments (package-arguments base-rust)
676 `(modify-phases ,phases
677 ;; binaryen was replaced with LLD project from LLVM
678 (delete 'dont-build-native)
679 (replace 'remove-unsupported-tests
681 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
682 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
683 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
685 (replace 'patch-cargo-tests
687 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
688 (("/usr/bin/env") (which "env"))
689 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
690 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
691 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
692 ;; This is stuck when built in container.
693 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
694 ;; Prints test output in the wrong order when built on
696 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
697 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
699 ;; Avoid dependency on "git".
700 (substitute* "src/tools/cargo/tests/testsuite/new.rs"
701 (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo")
702 (("fn finds_author_git") "#[ignore]\nfn finds_author_git")
703 (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git"))
705 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
707 ;; This test failed to work on "nightly" channel builds
708 ;; https://github.com/rust-lang/cargo/issues/5648
709 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
710 (("fn test_resolving_minimum_version_with_transitive_deps")
711 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
713 (replace 'patch-cargo-index-update
715 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
716 ;; This test wants to update the crate index.
717 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
720 (define-public rust-1.27
722 (rust-bootstrapped-package rust-1.26 "1.27.2"
723 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs"
725 '("rust-coresimd-doctest.patch"
726 "rust-bootstrap-stage0-test.patch"
727 "rust-1.25-accept-more-detailed-gdb-lines.patch"
728 "rust-reproducible-builds.patch"))))
732 (substitute-keyword-arguments (package-arguments base-rust)
734 `(modify-phases ,phases
735 (add-before 'install 'mkdir-prefix-paths
736 (lambda* (#:key outputs #:allow-other-keys)
737 ;; As result of https://github.com/rust-lang/rust/issues/36989
738 ;; `prefix' directory should exist before `install' call
739 (mkdir-p (assoc-ref outputs "out"))
740 (mkdir-p (assoc-ref outputs "cargo"))
742 (add-after 'patch-cargo-tests 'disable-thinlto-test
744 ;; thinlto required llvm 6.0 for work
745 (substitute* "src/tools/cargo/tests/testsuite/path.rs"
746 (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works"))
751 (rust-bootstrapped-package rust-1.27 "1.28.0"
752 "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx"
754 '("rust-coresimd-doctest.patch"
755 "rust-bootstrap-stage0-test.patch"
756 "rust-1.25-accept-more-detailed-gdb-lines.patch"
757 "rust-reproducible-builds.patch"))))
762 (alist-replace "llvm" (list llvm)
763 (package-inputs base-rust)))
765 (substitute-keyword-arguments (package-arguments base-rust)
767 `(modify-phases ,phases
768 (add-after 'configure 'enable-codegen-tests
769 ;; Codegen tests should pass with llvm 6, so enable them.
771 (substitute* "config.toml"
772 (("codegen-tests = false") ""))
774 (add-after 'patch-tests 'disable-amd64-avx-test
775 ;; That test would fail on x86_64 machines without avx.
777 (substitute* "src/test/run-pass/issue-44056.rs"
778 (("only-x86_64") "ignore-test"))
780 ;; The thinlto test should pass with llvm 6.
781 (delete 'disable-thinlto-test))))))))