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