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 version-control)
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))))
72 (define rust-bootstrap
74 (name "rust-bootstrap")
77 (build-system gnu-build-system)
79 `(("patchelf" ,patchelf)))
81 `(("gcc" ,(canonical-package gcc))
82 ("gcc:lib" ,(canonical-package gcc) "lib")
88 "https://static.rust-lang.org/dist/"
89 "rust-" version "-" (nix-system->gnu-triplet-for-rust)
93 (match (nix-system->gnu-triplet-for-rust)
94 ("i686-unknown-linux-gnu"
95 "15zqbx86nm13d5vq2gm69b7av4vg479f74b5by64hs3bcwwm08pr")
96 ("x86_64-unknown-linux-gnu"
97 "1yll78x6b3abnvgjf2b66gvp6mmcb9y9jdiqcwhmgc0z0i0fix4c")
98 ("armv7-unknown-linux-gnueabihf"
99 "138a8l528kzp5wyk1mgjaxs304ac5ms8vlpq0ggjaznm6bn2j7a5")
100 ("aarch64-unknown-linux-gnu"
101 "0z6m9m1rx4d96nvybbfmpscq4dv616m615ijy16d5wh2vx0p4na8")
102 ("mips64el-unknown-linux-gnuabi64"
103 "07k4pcv7jvfa48cscdj8752lby7m7xdl88v3a6na1vs675lhgja2")
105 (outputs '("out" "cargo"))
110 (modify-phases %standard-phases
114 (lambda* (#:key inputs outputs #:allow-other-keys)
115 (let* ((out (assoc-ref outputs "out"))
116 (cargo-out (assoc-ref outputs "cargo"))
117 (gcc:lib (assoc-ref inputs "gcc:lib"))
118 (libc (assoc-ref inputs "libc"))
119 (zlib (assoc-ref inputs "zlib"))
120 (ld-so (string-append libc ,(glibc-dynamic-linker)))
121 (rpath (string-append out "/lib:" zlib "/lib:"
122 libc "/lib:" gcc:lib "/lib"))
123 (cargo-rpath (string-append cargo-out "/lib:" libc "/lib:"
125 (rustc (string-append out "/bin/rustc"))
126 (rustdoc (string-append out "/bin/rustdoc"))
127 (cargo (string-append cargo-out "/bin/cargo"))
128 (gcc (assoc-ref inputs "gcc")))
129 ;; Install rustc/rustdoc.
130 (invoke "bash" "install.sh"
131 (string-append "--prefix=" out)
132 (string-append "--components=rustc,"
134 ,(nix-system->gnu-triplet-for-rust)))
136 (invoke "bash" "install.sh"
137 (string-append "--prefix=" cargo-out)
138 (string-append "--components=cargo"))
139 (for-each (lambda (file)
140 (invoke "patchelf" "--set-rpath" rpath file))
141 (cons* rustc rustdoc (find-files out "\\.so$")))
142 (invoke "patchelf" "--set-rpath" cargo-rpath cargo)
143 (for-each (lambda (file)
144 (invoke "patchelf" "--set-interpreter" ld-so file))
145 (list rustc rustdoc cargo))
147 (home-page "https://www.rust-lang.org")
148 (synopsis "Prebuilt rust compiler and cargo package manager")
149 (description "This package provides a pre-built @command{rustc} compiler
150 and a pre-built @command{cargo} package manager, which can
151 in turn be used to build the final Rust.")
152 (license license:asl2.0)))
155 (define* (rust-source version hash #:key (patches '()))
158 (uri (string-append "https://static.rust-lang.org/dist/"
159 "rustc-" version "-src.tar.gz"))
160 (sha256 (base32 hash))
161 (modules '((guix build utils)))
162 (snippet '(begin (delete-file-recursively "src/llvm") #t))
163 (patches (map search-patch patches))))
165 (define* (rust-bootstrapped-package base-rust version checksum
167 "Bootstrap rust VERSION with source checksum CHECKSUM patched with PATCHES using BASE-RUST."
172 (rust-source version checksum #:patches patches))
174 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
175 (alist-replace "rustc-bootstrap" (list base-rust)
176 (package-native-inputs base-rust))))))
178 (define-public mrustc
179 (let ((rustc-version "1.19.0"))
186 (url "https://github.com/thepowersgang/mrustc.git")
187 (commit (string-append "v" version))))
188 (file-name (git-file-name name version))
191 "0a7v8ccyzp1sdkwni8h1698hxpfz2sxhcpx42n6l2pbm0rbjp08i"))))
192 (outputs '("out" "cargo"))
193 (build-system gnu-build-system)
195 `(("llvm" ,llvm-3.9.1)))
199 ;; Required for the libstd sources.
201 ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))))
204 #:make-flags (list (string-append "LLVM_CONFIG="
205 (assoc-ref %build-inputs "llvm")
208 (modify-phases %standard-phases
209 (add-after 'unpack 'patch-date
211 (substitute* "Makefile"
212 (("shell date") "shell date -d @1"))
214 (add-after 'patch-date 'unpack-target-compiler
215 (lambda* (#:key inputs outputs #:allow-other-keys)
216 (substitute* "minicargo.mk"
217 ;; Don't try to build LLVM.
218 (("^[$][(]LLVM_CONFIG[)]:") "xxx:")
219 ;; Build for the correct target architecture.
220 (("^RUSTC_TARGET := x86_64-unknown-linux-gnu")
221 (string-append "RUSTC_TARGET := "
222 ,(or (%current-target-system)
223 (nix-system->gnu-triplet-for-rust)))))
224 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
225 (chdir "rustc-1.19.0-src")
226 (invoke "patch" "-p0" "../rust_src.patch")
230 (lambda* (#:key inputs #:allow-other-keys)
231 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
233 (add-after 'build 'build-minicargo
235 (for-each (lambda (target)
236 (invoke "make" "-f" "minicargo.mk" target))
237 '("output/libstd.hir" "output/libpanic_unwind.hir"
238 "output/libproc_macro.hir" "output/libtest.hir"))
239 ;; Technically the above already does it - but we want to be clear.
240 (invoke "make" "-C" "tools/minicargo")))
242 (lambda* (#:key inputs outputs #:allow-other-keys)
243 (let* ((out (assoc-ref outputs "out"))
244 (bin (string-append out "/bin"))
245 (tools-bin (string-append out "/tools/bin"))
246 (cargo-out (assoc-ref outputs "cargo"))
247 (cargo-bin (string-append cargo-out "/bin"))
248 (lib (string-append out "/lib"))
249 (lib/rust (string-append lib "/mrust"))
250 (gcc (assoc-ref inputs "gcc")))
251 ;; These files are not reproducible.
252 (for-each delete-file (find-files "output" "\\.txt$"))
254 (copy-recursively "output" lib/rust)
257 (install-file "bin/mrustc" bin)
258 ;; minicargo uses relative paths to resolve mrustc.
259 (install-file "tools/bin/minicargo" tools-bin)
260 (install-file "tools/bin/minicargo" cargo-bin)
262 (synopsis "Compiler for the Rust progamming language")
263 (description "Rust is a systems programming language that provides memory
264 safety and thread safety guarantees.")
265 (home-page "https://github.com/thepowersgang/mrustc")
267 (license (list license:asl2.0 license:expat)))))
273 (source (rust-source version "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"
274 #:patches '("rust-1.19-mrustc.patch")))
275 (outputs '("out" "cargo"))
277 `(#:imported-modules ,%cargo-build-system-modules ;for `generate-checksums'
278 #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system))
280 (modify-phases %standard-phases
281 (add-after 'unpack 'set-env
282 (lambda* (#:key inputs #:allow-other-keys)
283 ;; Disable test for cross compilation support.
284 (setenv "CFG_DISABLE_CROSS_TESTS" "1")
285 (setenv "SHELL" (which "sh"))
286 (setenv "CONFIG_SHELL" (which "sh"))
287 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
288 ;; guix llvm-3.9.1 package installs only shared libraries
289 (setenv "LLVM_LINK_SHARED" "1")
291 (add-after 'unpack 'patch-cargo-tomls
292 (lambda* (#:key inputs outputs #:allow-other-keys)
293 (substitute* "src/librustc_errors/Cargo.toml"
294 (("[[]dependencies[]]") "
298 (substitute* "src/librustc/Cargo.toml"
299 (("[[]dependencies[]]") "
301 getopts = { path = \"../libgetopts\" }
303 (substitute* "src/librustdoc/Cargo.toml"
304 (("[[]dependencies[]]") "
306 test = { path = \"../libtest\" }
309 (add-after 'unpack 'patch-tests
310 (lambda* (#:key inputs #:allow-other-keys)
311 (let ((bash (assoc-ref inputs "bash")))
312 (substitute* "src/libstd/process.rs"
313 ;; The newline is intentional.
314 ;; There's a line length "tidy" check in Rust which would
316 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
317 (substitute* "src/libstd/net/tcp.rs"
318 ;; There is no network in build environment
319 (("fn connect_timeout_unroutable")
320 "#[ignore]\nfn connect_timeout_unroutable"))
321 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
322 (substitute* "src/libstd/sys/unix/process/process_common.rs"
323 (("fn test_process_mask") "#[allow(unused_attributes)]
325 fn test_process_mask"))
327 (add-after 'patch-tests 'patch-aarch64-test
329 (substitute* "src/librustc_back/dynamic_lib.rs"
330 ;; This test is known to fail on aarch64 and powerpc64le:
331 ;; https://github.com/rust-lang/rust/issues/45410
332 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
334 (add-after 'patch-tests 'use-readelf-for-tests
336 ;; nm doesn't recognize the file format because of the
337 ;; nonstandard sections used by the Rust compiler, but readelf
339 (substitute* "src/test/run-make/atomic-lock-free/Makefile"
343 (add-after 'patch-tests 'remove-unsupported-tests
345 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
346 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
347 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
349 (add-after 'patch-source-shebangs 'patch-cargo-checksums
351 (substitute* "src/Cargo.lock"
352 (("(\"checksum .* = )\".*\"" all name)
353 (string-append name "\"" ,%cargo-reference-hash "\"")))
356 (use-modules (guix build cargo-build-system))
357 (delete-file filename)
358 (let* ((dir (dirname filename)))
359 (display (string-append
360 "patch-cargo-checksums: generate-checksums for "
362 (generate-checksums dir ,%cargo-reference-project-file)))
363 (find-files "src/vendor" ".cargo-checksum.json"))
365 ;; This phase is overridden by newer versions.
368 ;; This phase is overridden by newer versions.
370 (lambda* (#:key inputs outputs #:allow-other-keys)
371 (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap")))
372 (setenv "CFG_COMPILER_HOST_TRIPLE"
373 ,(nix-system->gnu-triplet (%current-system)))
374 (setenv "CFG_RELEASE" "")
375 (setenv "CFG_RELEASE_CHANNEL" "stable")
376 (setenv "CFG_LIBDIR_RELATIVE" "lib")
377 (setenv "CFG_VERSION" "1.19.0-stable-mrustc")
378 ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path.
380 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
381 "src/rustc" "--vendor-dir" "src/vendor"
382 "--output-dir" "output/rustc-build"
383 "-L" (string-append rustc-bootstrap "/lib/mrust")
385 (setenv "CFG_COMPILER_HOST_TRIPLE" #f)
386 (setenv "CFG_RELEASE" #f)
387 (setenv "CFG_RELEASE_CHANNEL" #f)
388 (setenv "CFG_VERSION" #f)
389 (setenv "CFG_PREFIX" #f)
390 (setenv "CFG_LIBDIR_RELATIVE" #f)
391 (invoke (string-append rustc-bootstrap "/tools/bin/minicargo")
392 "src/tools/cargo" "--vendor-dir" "src/vendor"
393 "--output-dir" "output/cargo-build"
395 "-L" (string-append rustc-bootstrap "/lib/mrust")
397 ;; Now use the newly-built rustc to build the libraries.
398 ;; One day that could be replaced by:
399 ;; (invoke "output/cargo-build/cargo" "build"
400 ;; "--manifest-path" "src/bootstrap/Cargo.toml"
401 ;; "--verbose") ; "--locked" "--frozen"
402 ;; but right now, Cargo has problems with libstd's circular
404 (mkdir-p "output/target-libs")
405 (for-each (match-lambda
410 "output/rustc-build/rustc"
411 "-C" (string-append "linker="
413 "-L" "output/target-libs"
414 (string-append "src/" name "/lib.rs")
416 (string-append "output/target-libs/"
417 (car (string-split name #\/))
425 ("liblibc/src" "--cfg" "stdbuild")
426 ("libunwind" "-l" "gcc_s")
427 ("libcompiler_builtins")
430 ;; Uses "cc" to link.
431 ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread")
434 ;; This phase is overridden by newer versions.
437 ;; This phase is overridden by newer versions.
439 (lambda* (#:key inputs outputs #:allow-other-keys)
440 (let* ((out (assoc-ref outputs "out"))
441 (target-system ,(or (%current-target-system)
442 (nix-system->gnu-triplet
444 (out-libs (string-append out "/lib/rustlib/"
445 target-system "/lib")))
446 ;(setenv "CFG_PREFIX" out)
448 (copy-recursively "output/target-libs" out-libs)
449 (install-file "output/rustc-build/rustc"
450 (string-append out "/bin"))
451 (install-file "output/rustc-build/rustdoc"
452 (string-append out "/bin"))
453 (install-file "output/cargo-build/cargo"
454 (string-append (assoc-ref outputs "cargo")
457 (build-system gnu-build-system)
459 `(("bison" ,bison) ; For the tests
461 ("flex" ,flex) ; For the tests
462 ("gdb" ,gdb) ; For the tests
464 ("procps" ,procps) ; For the tests
465 ("python-2" ,python-2)
466 ("rustc-bootstrap" ,mrustc)
467 ("cargo-bootstrap" ,mrustc "cargo")
468 ("pkg-config" ,pkg-config) ; For "cargo"
471 `(("jemalloc" ,jemalloc-4.5.0)
474 ("libcurl" ,curl))) ; For "cargo"
476 ;; rustc invokes gcc, so we need to set its search paths accordingly.
477 ;; Note: duplicate its value here to cope with circular dependencies among
478 ;; modules (see <https://bugs.gnu.org/31392>).
480 (list (search-path-specification
481 (variable "C_INCLUDE_PATH")
482 (files '("include")))
483 (search-path-specification
484 (variable "CPLUS_INCLUDE_PATH")
485 (files '("include")))
486 (search-path-specification
487 (variable "LIBRARY_PATH")
488 (files '("lib" "lib64")))))
490 (synopsis "Compiler for the Rust progamming language")
491 (description "Rust is a systems programming language that provides memory
492 safety and thread safety guarantees.")
493 (home-page "https://www.rust-lang.org")
495 (license (list license:asl2.0 license:expat))))
497 (define-public rust-1.20
499 (rust-bootstrapped-package rust-1.19 "1.20.0"
500 "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a")))
503 (outputs '("out" "doc" "cargo"))
505 (substitute-keyword-arguments (package-arguments rust-1.19)
507 `(modify-phases ,phases
509 (lambda* (#:key inputs outputs #:allow-other-keys)
510 (let* ((out (assoc-ref outputs "out"))
511 (doc (assoc-ref outputs "doc"))
512 (gcc (assoc-ref inputs "gcc"))
513 (gdb (assoc-ref inputs "gdb"))
514 (binutils (assoc-ref inputs "binutils"))
515 (python (assoc-ref inputs "python-2"))
516 (rustc (assoc-ref inputs "rustc-bootstrap"))
517 (cargo (assoc-ref inputs "cargo-bootstrap"))
518 (llvm (assoc-ref inputs "llvm"))
519 (jemalloc (assoc-ref inputs "jemalloc")))
520 (call-with-output-file "config.toml"
522 (display (string-append "
525 cargo = \"" cargo "/bin/cargo" "\"
526 rustc = \"" rustc "/bin/rustc" "\"
528 python = \"" python "/bin/python2" "\"
529 gdb = \"" gdb "/bin/gdb" "\"
534 docdir = \"" doc "/share/doc/rust" "\"
536 localstatedir = \"var/lib\"
538 default-linker = \"" gcc "/bin/gcc" "\"
541 " ;; There are 2 failed codegen tests:
542 ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
543 ;; These tests require a patched LLVM
544 "codegen-tests = false
545 [target." ,(nix-system->gnu-triplet-for-rust) "]
546 llvm-config = \"" llvm "/bin/llvm-config" "\"
547 cc = \"" gcc "/bin/gcc" "\"
548 cxx = \"" gcc "/bin/g++" "\"
549 ar = \"" binutils "/bin/ar" "\"
550 jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
554 (add-after 'configure 'provide-cc
555 (lambda* (#:key inputs #:allow-other-keys)
556 (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc")
558 (setenv "PATH" (string-append "/tmp:" (getenv "PATH")))
560 (add-after 'provide-cc 'configure-archiver
561 (lambda* (#:key inputs #:allow-other-keys)
562 (substitute* "src/build_helper/lib.rs"
563 ;; Make sure "ar" is always used as the archiver.
564 (("\"musl\"") "\"\"")
565 ;; Then substitute "ar" by our name.
566 (("\"ar\"") (string-append "\""
567 (assoc-ref inputs "binutils")
570 (delete 'patch-cargo-tomls)
571 (add-before 'build 'reset-timestamps-after-changes
573 (define ref (stat "README.md"))
576 (set-file-time filename ref))
577 (find-files "." #:directories? #t))
581 (invoke "./x.py" "build")
582 (invoke "./x.py" "build" "src/tools/cargo")))
585 ;; Disable parallel execution to prevent EAGAIN errors when
587 (invoke "./x.py" "-j1" "test" "-vv")
588 (invoke "./x.py" "-j1" "test" "src/tools/cargo")
591 (lambda* (#:key outputs #:allow-other-keys)
592 (invoke "./x.py" "install")
593 (substitute* "config.toml"
594 ;; replace prefix to specific output
595 (("prefix = \"[^\"]*\"")
596 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
597 (invoke "./x.py" "install" "cargo")))
598 (add-after 'install 'wrap-rustc
599 (lambda* (#:key inputs outputs #:allow-other-keys)
600 (let ((out (assoc-ref outputs "out"))
601 (libc (assoc-ref inputs "libc"))
602 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
603 ;; Let gcc find ld and libc startup files.
604 (wrap-program (string-append out "/bin/rustc")
605 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
606 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
609 (define-public rust-1.21
610 (rust-bootstrapped-package rust-1.20 "1.21.0"
611 "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp"))
613 (define-public rust-1.22
614 (rust-bootstrapped-package rust-1.21 "1.22.1"
615 "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb"))
617 (define-public rust-1.23
622 (source (rust-source version "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l"))
624 `(("bison" ,bison) ; For the tests
626 ("flex" ,flex) ; For the tests
627 ("gdb" ,gdb) ; For the tests
629 ("procps" ,procps) ; For the tests
630 ("python-2" ,python-2)
631 ("rustc-bootstrap" ,rust-bootstrap)
632 ("cargo-bootstrap" ,rust-bootstrap "cargo")
633 ("pkg-config" ,pkg-config) ; For "cargo"
636 (substitute-keyword-arguments (package-arguments rust-1.20)
638 `(modify-phases ,phases
639 (delete 'configure-archiver)
640 (add-after 'unpack 'dont-build-native
642 ;; XXX: Revisit this when we use gcc 6.
643 (substitute* "src/binaryen/CMakeLists.txt"
644 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
646 (add-after 'patch-tests 'patch-cargo-tests
648 (substitute* "src/tools/cargo/tests/build.rs"
649 (("/usr/bin/env") (which "env"))
650 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
651 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
652 (substitute* "src/tools/cargo/tests/death.rs"
653 ;; This is stuck when built in container.
654 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
655 ;; Prints test output in the wrong order when built on
657 (substitute* "src/tools/cargo/tests/test.rs"
658 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
660 (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test
661 ;; https://github.com/rust-lang/rust/issues/47863
663 (substitute* "src/test/run-pass/out-of-stack.rs"
664 (("// ignore-android") "// ignore-test\n// ignore-android"))))
665 (add-after 'ignore-glibc-2.27-incompatible-test 'fix-mtime-bug
667 (substitute* "src/build_helper/lib.rs"
669 ;; Current implementation assume that if dst not exist then it's mtime
670 ;; is 0, but in same time "src" have 0 mtime in guix build!
671 (("let threshold = mtime\\(dst\\);")
672 "if !dst.exists() {\nreturn false\n}\n let threshold = mtime(dst);"))
675 (define-public rust-1.24
677 (rust-bootstrapped-package rust-1.23 "1.24.1"
678 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
682 (substitute-keyword-arguments (package-arguments base-rust)
684 `(modify-phases ,phases
685 (delete 'use-readelf-for-tests)
686 (replace 'patch-aarch64-test
688 (substitute* "src/librustc_metadata/dynamic_lib.rs"
689 ;; This test is known to fail on aarch64 and powerpc64le:
690 ;; https://github.com/rust-lang/rust/issues/45410
691 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
693 (delete 'fix-mtime-bug))))))))
695 (define-public rust-1.25
697 (rust-bootstrapped-package rust-1.24 "1.25.0"
698 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf"
699 #:patches '("rust-1.25-accept-more-detailed-gdb-lines.patch"))))
704 (alist-replace "llvm" (list llvm)
705 (package-inputs base-rust)))
707 (substitute-keyword-arguments (package-arguments base-rust)
709 `(modify-phases ,phases
710 (add-after 'patch-cargo-tests 'patch-cargo-index-update
712 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
713 ;; This test wants to update the crate index.
714 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
716 (add-after 'configure 'enable-codegen-tests
718 (substitute* "config.toml"
719 (("codegen-tests = false") ""))
721 ;; FIXME: Re-enable this test if it's indeed supposed to work.
722 ;; See <https://github.com/rust-lang/rust/issues/54178>.
723 (add-after 'enable-codegen-tests 'disable-nil-enum-test
725 (substitute* "src/test/debuginfo/nil-enum.rs"
726 (("ignore-lldb") "ignore-gdb"))
728 (replace 'patch-aarch64-test
730 (substitute* "src/librustc_metadata/dynamic_lib.rs"
731 ;; This test is known to fail on aarch64 and powerpc64le:
732 ;; https://github.com/rust-lang/rust/issues/45410
733 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
734 ;; This test fails on aarch64 with llvm@6.0:
735 ;; https://github.com/rust-lang/rust/issues/49807
736 ;; other possible solution:
737 ;; https://github.com/rust-lang/rust/pull/47688
738 (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs")
740 (delete 'ignore-glibc-2.27-incompatible-test))))))))
742 (define-public rust-1.26
744 (rust-bootstrapped-package rust-1.25 "1.26.2"
745 "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv"
746 #:patches '("rust-coresimd-doctest.patch"
747 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
751 (substitute-keyword-arguments (package-arguments base-rust)
753 `(modify-phases ,phases
754 ;; binaryen was replaced with LLD project from LLVM
755 (delete 'dont-build-native)
756 (replace 'remove-unsupported-tests
758 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
759 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
760 (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8")
762 (replace 'patch-cargo-tests
764 (substitute* "src/tools/cargo/tests/testsuite/build.rs"
765 (("/usr/bin/env") (which "env"))
766 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
767 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
768 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
769 ;; This is stuck when built in container.
770 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
771 ;; Prints test output in the wrong order when built on
773 (substitute* "src/tools/cargo/tests/testsuite/test.rs"
774 (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env"))
776 (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel
778 ;; This test failed to work on "nightly" channel builds
779 ;; https://github.com/rust-lang/cargo/issues/5648
780 (substitute* "src/tools/cargo/tests/testsuite/resolve.rs"
781 (("fn test_resolving_minimum_version_with_transitive_deps")
782 "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps"))
784 (replace 'patch-cargo-index-update
786 (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs"
787 ;; This test wants to update the crate index.
788 (("fn no_index_update") "#[ignore]\nfn no_index_update"))
793 (rust-bootstrapped-package rust-1.26 "1.27.2"
794 "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs"
796 '("rust-coresimd-doctest.patch"
797 "rust-bootstrap-stage0-test.patch"
798 "rust-1.25-accept-more-detailed-gdb-lines.patch"))))
802 (substitute-keyword-arguments (package-arguments base-rust)
804 `(modify-phases ,phases
805 (add-before 'install 'mkdir-prefix-paths
806 (lambda* (#:key outputs #:allow-other-keys)
807 ;; As result of https://github.com/rust-lang/rust/issues/36989
808 ;; `prefix' directory should exist before `install' call
809 (mkdir-p (assoc-ref outputs "out"))
810 (mkdir-p (assoc-ref outputs "cargo"))