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