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