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