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