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