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