Commit | Line | Data |
---|---|---|
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> |
3c986a7d | 4 | ;;; Copyright © 2016 Nikita <nikita@n0.is> |
fa73a7c1 | 5 | ;;; Copyright © 2017 Ben Woodcroft <donttrustben@gmail.com> |
f342bb58 | 6 | ;;; Copyright © 2017, 2018 Nikolai Merinov <nikolai.merinov@member.fsf.org> |
25cdd9f7 | 7 | ;;; Copyright © 2017, 2019, 2020 Efraim Flashner <efraim@flashner.co.il> |
03f9a8c3 | 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> |
062854de | 11 | ;;; Copyright © 2020, 2021 Jakub Kądziołka <kuba@kadziolka.net> |
2bab532f | 12 | ;;; Copyright © 2020 Pierre Langlois <pierre.langlois@gmx.com> |
48926b58 | 13 | ;;; Copyright © 2020 Matthew Kraai <kraai@ftbfs.org> |
423f9e44 DC |
14 | ;;; |
15 | ;;; This file is part of GNU Guix. | |
16 | ;;; | |
17 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
18 | ;;; under the terms of the GNU General Public License as published by | |
19 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
20 | ;;; your option) any later version. | |
21 | ;;; | |
22 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
23 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 | ;;; GNU General Public License for more details. | |
26 | ;;; | |
27 | ;;; You should have received a copy of the GNU General Public License | |
28 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
29 | ||
30 | (define-module (gnu packages rust) | |
31 | #:use-module (gnu packages base) | |
5f3d46ce | 32 | #:use-module (gnu packages bison) |
423f9e44 | 33 | #:use-module (gnu packages bootstrap) |
ecee2147 | 34 | #:use-module (gnu packages cmake) |
423f9e44 | 35 | #:use-module (gnu packages compression) |
b5a09649 | 36 | #:use-module (gnu packages curl) |
423f9e44 | 37 | #:use-module (gnu packages elf) |
5f3d46ce | 38 | #:use-module (gnu packages flex) |
423f9e44 | 39 | #:use-module (gnu packages gcc) |
d53fb678 | 40 | #:use-module (gnu packages gdb) |
ecee2147 | 41 | #:use-module (gnu packages jemalloc) |
5f3d46ce | 42 | #:use-module (gnu packages linux) |
ecee2147 | 43 | #:use-module (gnu packages llvm) |
b5a09649 | 44 | #:use-module (gnu packages pkg-config) |
ecee2147 | 45 | #:use-module (gnu packages python) |
b5a09649 DC |
46 | #:use-module (gnu packages ssh) |
47 | #:use-module (gnu packages tls) | |
d53fb678 | 48 | #:use-module (gnu packages) |
b5a09649 | 49 | #:use-module (guix build-system cargo) |
423f9e44 DC |
50 | #:use-module (guix build-system gnu) |
51 | #:use-module (guix build-system trivial) | |
52 | #:use-module (guix download) | |
a92bf11c | 53 | #:use-module (guix git-download) |
423f9e44 DC |
54 | #:use-module ((guix licenses) #:prefix license:) |
55 | #:use-module (guix packages) | |
f342bb58 NM |
56 | #:use-module ((guix build utils) #:select (alist-replace)) |
57 | #:use-module (guix utils) | |
423f9e44 DC |
58 | #:use-module (ice-9 match) |
59 | #:use-module (srfi srfi-26)) | |
60 | ||
9483782a JK |
61 | ;; This is the hash for the empty file, and the reason it's relevant is not |
62 | ;; the most obvious. | |
63 | ;; | |
64 | ;; The root of the problem is that Cargo keeps track of a file called | |
65 | ;; Cargo.lock, that contains the hash of the tarball source of each dependency. | |
66 | ;; | |
67 | ;; However, tarball sources aren't handled well by Guix because of the need to | |
68 | ;; patch shebangs in any helper scripts. This is why we use Cargo's vendoring | |
69 | ;; capabilities, where instead of the tarball, a directory is provided in its | |
70 | ;; place. (In the case of rustc, the source code already ships with vendored | |
71 | ;; dependencies, but crates built with cargo-build-system undergo vendoring | |
72 | ;; during the build.) | |
73 | ;; | |
74 | ;; To preserve the advantages of checksumming, vendored dependencies contain | |
75 | ;; a file called .cargo-checksum.json, which contains the hash of the tarball, | |
76 | ;; as well as the list of files in it, with the hash of each file. | |
77 | ;; | |
78 | ;; The patch-cargo-checksums phase of cargo-build-system runs after | |
79 | ;; any Guix-specific patches to the vendored dependencies and regenerates the | |
80 | ;; .cargo-checksum.json files, but it's hard to know the tarball checksum that | |
81 | ;; should be written to the file - and taking care of any unhandled edge case | |
82 | ;; would require rebuilding everything that depends on rust. This is why we lie, | |
83 | ;; and say that the tarball has the hash of an empty file. It's not a problem | |
84 | ;; because cargo-build-system removes the Cargo.lock file. We can't do that | |
85 | ;; for rustc because of a quirk of its build system, so we modify the lock file | |
86 | ;; to substitute the hash. | |
d53fb678 NM |
87 | (define %cargo-reference-hash |
88 | "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") | |
423f9e44 | 89 | |
2c790226 MW |
90 | (define* (nix-system->gnu-triplet-for-rust |
91 | #:optional (system (%current-system))) | |
92 | (match system | |
93 | ("x86_64-linux" "x86_64-unknown-linux-gnu") | |
94 | ("i686-linux" "i686-unknown-linux-gnu") | |
95 | ("armhf-linux" "armv7-unknown-linux-gnueabihf") | |
96 | ("aarch64-linux" "aarch64-unknown-linux-gnu") | |
97 | ("mips64el-linux" "mips64el-unknown-linux-gnuabi64") | |
98 | (_ (nix-system->gnu-triplet system)))) | |
99 | ||
4ed20d3c IP |
100 | (define* (rust-uri version #:key (dist "static")) |
101 | (string-append "https://" dist ".rust-lang.org/dist/" | |
102 | "rustc-" version "-src.tar.gz")) | |
339c1365 | 103 | |
4ed20d3c IP |
104 | (define* (rust-bootstrapped-package base-rust version checksum) |
105 | "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST." | |
339c1365 IP |
106 | (package |
107 | (inherit base-rust) | |
108 | (version version) | |
109 | (source | |
4ed20d3c IP |
110 | (origin |
111 | (inherit (package-source base-rust)) | |
112 | (uri (rust-uri version)) | |
113 | (sha256 (base32 checksum)))) | |
24d298b4 DM |
114 | (native-inputs |
115 | (alist-replace "cargo-bootstrap" (list base-rust "cargo") | |
116 | (alist-replace "rustc-bootstrap" (list base-rust) | |
117 | (package-native-inputs base-rust)))))) | |
118 | ||
119 | (define-public mrustc | |
120 | (let ((rustc-version "1.19.0")) | |
121 | (package | |
122 | (name "mrustc") | |
5b600fca | 123 | (version "0.9") |
24d298b4 DM |
124 | (source (origin |
125 | (method git-fetch) | |
126 | (uri (git-reference | |
b0e7b699 | 127 | (url "https://github.com/thepowersgang/mrustc") |
24d298b4 DM |
128 | (commit (string-append "v" version)))) |
129 | (file-name (git-file-name name version)) | |
130 | (sha256 | |
131 | (base32 | |
5b600fca | 132 | "194ny7vsks5ygiw7d8yxjmp1qwigd71ilchis6xjl6bb2sj97rd2")))) |
24d298b4 DM |
133 | (outputs '("out" "cargo")) |
134 | (build-system gnu-build-system) | |
135 | (inputs | |
b07384b5 | 136 | `(("zlib" ,zlib))) |
24d298b4 DM |
137 | (native-inputs |
138 | `(("bison" ,bison) | |
139 | ("flex" ,flex) | |
140 | ;; Required for the libstd sources. | |
b07384b5 | 141 | ("rustc" ,(package-source rust-1.19)))) |
24d298b4 | 142 | (arguments |
5b600fca | 143 | `(#:test-target "test" |
b07384b5 DM |
144 | #:make-flags |
145 | (list ,(string-append "RUSTC_TARGET=" | |
146 | (or (%current-target-system) | |
147 | (nix-system->gnu-triplet-for-rust)))) | |
24d298b4 DM |
148 | #:phases |
149 | (modify-phases %standard-phases | |
150 | (add-after 'unpack 'patch-date | |
151 | (lambda _ | |
152 | (substitute* "Makefile" | |
153 | (("shell date") "shell date -d @1")) | |
b07384b5 DM |
154 | (substitute* "run_rustc/Makefile" |
155 | (("[$]Vtime ") "$V ")) | |
24d298b4 DM |
156 | #t)) |
157 | (add-after 'patch-date 'unpack-target-compiler | |
158 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
24d298b4 | 159 | (invoke "tar" "xf" (assoc-ref inputs "rustc")) |
b07384b5 | 160 | (chdir ,(string-append "rustc-" rustc-version "-src")) |
5b600fca DM |
161 | (invoke "patch" "-p0" ,(string-append "../rustc-" rustc-version |
162 | "-src.patch")) | |
24d298b4 | 163 | (chdir "..") |
5b600fca DM |
164 | (setenv "RUSTC_VERSION" ,rustc-version) |
165 | (setenv "MRUSTC_TARGET_VER" | |
166 | ,(version-major+minor rustc-version)) | |
167 | (setenv "OUTDIR_SUF" "") | |
24d298b4 DM |
168 | #t)) |
169 | (replace 'configure | |
170 | (lambda* (#:key inputs #:allow-other-keys) | |
b07384b5 DM |
171 | (setenv "CC" (string-append (assoc-ref inputs "gcc") |
172 | "/bin/gcc")) | |
173 | (setenv "CXX" (string-append (assoc-ref inputs "gcc") | |
174 | "/bin/g++")) | |
24d298b4 DM |
175 | #t)) |
176 | (add-after 'build 'build-minicargo | |
b07384b5 | 177 | (lambda* (#:key make-flags #:allow-other-keys) |
5b600fca | 178 | ;; TODO: minicargo.mk: RUSTC_VERSION=$(RUSTC_VERSION) RUSTC_CHANNEL=$(RUSTC_SRC_TY) OUTDIR_SUF=$(OUTDIR_SUF) |
b07384b5 DM |
179 | (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags) |
180 | (apply invoke "make" "-C" "tools/minicargo" make-flags))) | |
5b600fca DM |
181 | ;(add-after 'check 'check-locally |
182 | ; (lambda* (#:key make-flags #:allow-other-keys) | |
183 | ; ;; The enum test wouldn't work otherwise. | |
184 | ; ;; See <https://github.com/thepowersgang/mrustc/issues/137>. | |
185 | ; (setenv "MRUSTC_TARGET_VER" ,(version-major+minor rustc-version)) | |
186 | ; (apply invoke "make" "local_tests" make-flags))) | |
24d298b4 DM |
187 | (replace 'install |
188 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
189 | (let* ((out (assoc-ref outputs "out")) | |
190 | (bin (string-append out "/bin")) | |
191 | (tools-bin (string-append out "/tools/bin")) | |
192 | (cargo-out (assoc-ref outputs "cargo")) | |
193 | (cargo-bin (string-append cargo-out "/bin")) | |
194 | (lib (string-append out "/lib")) | |
195 | (lib/rust (string-append lib "/mrust")) | |
b07384b5 | 196 | (gcc (assoc-ref inputs "gcc")) |
5b600fca DM |
197 | (run_rustc (string-append out |
198 | "/share/mrustc/run_rustc"))) | |
24d298b4 DM |
199 | ;; These files are not reproducible. |
200 | (for-each delete-file (find-files "output" "\\.txt$")) | |
5b600fca DM |
201 | ;(delete-file-recursively "output/local_tests") |
202 | (mkdir-p (dirname lib/rust)) | |
24d298b4 DM |
203 | (copy-recursively "output" lib/rust) |
204 | (mkdir-p bin) | |
205 | (mkdir-p tools-bin) | |
206 | (install-file "bin/mrustc" bin) | |
207 | ;; minicargo uses relative paths to resolve mrustc. | |
208 | (install-file "tools/bin/minicargo" tools-bin) | |
209 | (install-file "tools/bin/minicargo" cargo-bin) | |
b07384b5 DM |
210 | (mkdir-p run_rustc) |
211 | (copy-file "run_rustc/Makefile" | |
212 | (string-append run_rustc "/Makefile")) | |
24d298b4 | 213 | #t)))))) |
7af0f215 | 214 | (synopsis "Compiler for the Rust programming language") |
24d298b4 DM |
215 | (description "Rust is a systems programming language that provides memory |
216 | safety and thread safety guarantees.") | |
217 | (home-page "https://github.com/thepowersgang/mrustc") | |
218 | ;; Dual licensed. | |
219 | (license (list license:asl2.0 license:expat))))) | |
220 | ||
4f963b6f | 221 | (define rust-1.19 |
ecee2147 | 222 | (package |
f342bb58 | 223 | (name "rust") |
8fdde581 | 224 | (version "1.19.0") |
4ed20d3c IP |
225 | (source |
226 | (origin | |
227 | (method url-fetch) | |
228 | (uri (rust-uri "1.19.0")) | |
229 | (sha256 (base32 "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm")) | |
230 | (modules '((guix build utils))) | |
231 | (snippet '(begin (delete-file-recursively "src/llvm") #t)) | |
e28a824f | 232 | (patches (search-patches "rust-1.19-mrustc.patch")))) |
8fdde581 | 233 | (outputs '("out" "cargo")) |
b7c1c2b8 DM |
234 | (properties '((timeout . 72000) ;20 hours |
235 | (max-silent-time . 18000))) ;5 hours (for armel) | |
ecee2147 | 236 | (arguments |
e07b0488 | 237 | `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums' |
3159ef7c | 238 | #:modules ((guix build utils) (ice-9 match) (guix build gnu-build-system)) |
d53fb678 | 239 | #:phases |
ecee2147 | 240 | (modify-phases %standard-phases |
ecee2147 | 241 | (add-after 'unpack 'set-env |
1bb23335 NM |
242 | (lambda* (#:key inputs #:allow-other-keys) |
243 | ;; Disable test for cross compilation support. | |
244 | (setenv "CFG_DISABLE_CROSS_TESTS" "1") | |
ecee2147 | 245 | (setenv "SHELL" (which "sh")) |
326249ba | 246 | (setenv "CONFIG_SHELL" (which "sh")) |
1bb23335 | 247 | (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) |
d53fb678 NM |
248 | ;; guix llvm-3.9.1 package installs only shared libraries |
249 | (setenv "LLVM_LINK_SHARED" "1") | |
326249ba | 250 | #t)) |
3159ef7c DM |
251 | (add-after 'unpack 'patch-cargo-tomls |
252 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
253 | (substitute* "src/librustc_errors/Cargo.toml" | |
254 | (("[[]dependencies[]]") " | |
255 | [dependencies] | |
256 | term = \"0.4.4\" | |
257 | ")) | |
258 | (substitute* "src/librustc/Cargo.toml" | |
259 | (("[[]dependencies[]]") " | |
260 | [dependencies] | |
261 | getopts = { path = \"../libgetopts\" } | |
262 | ")) | |
263 | (substitute* "src/librustdoc/Cargo.toml" | |
264 | (("[[]dependencies[]]") " | |
265 | [dependencies] | |
266 | test = { path = \"../libtest\" } | |
267 | ")) | |
268 | #t)) | |
84aac61c DM |
269 | (add-after 'unpack 'patch-tests |
270 | (lambda* (#:key inputs #:allow-other-keys) | |
9b7a9580 | 271 | (let ((bash (assoc-ref inputs "bash"))) |
9b7a9580 | 272 | (substitute* "src/libstd/process.rs" |
5f3d46ce DM |
273 | ;; The newline is intentional. |
274 | ;; There's a line length "tidy" check in Rust which would | |
275 | ;; fail otherwise. | |
d53fb678 NM |
276 | (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\""))) |
277 | (substitute* "src/libstd/net/tcp.rs" | |
278 | ;; There is no network in build environment | |
279 | (("fn connect_timeout_unroutable") | |
280 | "#[ignore]\nfn connect_timeout_unroutable")) | |
281 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html> | |
5f3d46ce | 282 | (substitute* "src/libstd/sys/unix/process/process_common.rs" |
237587f1 DM |
283 | (("fn test_process_mask") "#[allow(unused_attributes)] |
284 | #[ignore] | |
af4ea9c5 | 285 | fn test_process_mask")) |
9b7a9580 | 286 | #t))) |
b47b2d32 NM |
287 | (add-after 'patch-tests 'patch-aarch64-test |
288 | (lambda* _ | |
289 | (substitute* "src/librustc_back/dynamic_lib.rs" | |
290 | ;; This test is known to fail on aarch64 and powerpc64le: | |
291 | ;; https://github.com/rust-lang/rust/issues/45410 | |
292 | (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine")) | |
293 | #t)) | |
294 | (add-after 'patch-tests 'use-readelf-for-tests | |
295 | (lambda* _ | |
296 | ;; nm doesn't recognize the file format because of the | |
297 | ;; nonstandard sections used by the Rust compiler, but readelf | |
298 | ;; ignores them. | |
299 | (substitute* "src/test/run-make/atomic-lock-free/Makefile" | |
300 | (("\tnm ") | |
301 | "\treadelf -c ")) | |
302 | #t)) | |
303 | (add-after 'patch-tests 'remove-unsupported-tests | |
304 | (lambda* _ | |
305 | ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH. | |
306 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html> | |
307 | (delete-file-recursively "src/test/run-make/linker-output-non-utf8") | |
308 | #t)) | |
d53fb678 | 309 | (add-after 'patch-source-shebangs 'patch-cargo-checksums |
f342bb58 | 310 | (lambda* _ |
4585859f | 311 | (use-modules (guix build cargo-utils)) |
d53fb678 NM |
312 | (substitute* "src/Cargo.lock" |
313 | (("(\"checksum .* = )\".*\"" all name) | |
314 | (string-append name "\"" ,%cargo-reference-hash "\""))) | |
e07b0488 | 315 | (generate-all-checksums "src/vendor") |
d53fb678 | 316 | #t)) |
3159ef7c | 317 | ;; This phase is overridden by newer versions. |
ecee2147 | 318 | (replace 'configure |
8fdde581 | 319 | (const #t)) |
3159ef7c DM |
320 | ;; This phase is overridden by newer versions. |
321 | (replace 'build | |
322 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
323 | (let ((rustc-bootstrap (assoc-ref inputs "rustc-bootstrap"))) | |
324 | (setenv "CFG_COMPILER_HOST_TRIPLE" | |
325 | ,(nix-system->gnu-triplet (%current-system))) | |
326 | (setenv "CFG_RELEASE" "") | |
327 | (setenv "CFG_RELEASE_CHANNEL" "stable") | |
328 | (setenv "CFG_LIBDIR_RELATIVE" "lib") | |
329 | (setenv "CFG_VERSION" "1.19.0-stable-mrustc") | |
5b600fca | 330 | (setenv "MRUSTC_TARGET_VER" ,(version-major+minor version)) |
3159ef7c DM |
331 | ; bad: (setenv "CFG_PREFIX" "mrustc") ; FIXME output path. |
332 | (mkdir-p "output") | |
5b600fca DM |
333 | ;; mrustc 0.9 doesn't check the search paths for crates anymore. |
334 | (copy-recursively (string-append rustc-bootstrap "/lib/mrust") | |
335 | "output") | |
3159ef7c DM |
336 | (invoke (string-append rustc-bootstrap "/tools/bin/minicargo") |
337 | "src/rustc" "--vendor-dir" "src/vendor" | |
338 | "--output-dir" "output/rustc-build" | |
339 | "-L" (string-append rustc-bootstrap "/lib/mrust") | |
340 | "-j" "1") | |
3159ef7c DM |
341 | (setenv "CFG_COMPILER_HOST_TRIPLE" #f) |
342 | (setenv "CFG_RELEASE" #f) | |
343 | (setenv "CFG_RELEASE_CHANNEL" #f) | |
344 | (setenv "CFG_VERSION" #f) | |
345 | (setenv "CFG_PREFIX" #f) | |
346 | (setenv "CFG_LIBDIR_RELATIVE" #f) | |
347 | (invoke (string-append rustc-bootstrap "/tools/bin/minicargo") | |
348 | "src/tools/cargo" "--vendor-dir" "src/vendor" | |
349 | "--output-dir" "output/cargo-build" | |
350 | "-L" "output/" | |
351 | "-L" (string-append rustc-bootstrap "/lib/mrust") | |
352 | "-j" "1") | |
353 | ;; Now use the newly-built rustc to build the libraries. | |
354 | ;; One day that could be replaced by: | |
355 | ;; (invoke "output/cargo-build/cargo" "build" | |
356 | ;; "--manifest-path" "src/bootstrap/Cargo.toml" | |
357 | ;; "--verbose") ; "--locked" "--frozen" | |
358 | ;; but right now, Cargo has problems with libstd's circular | |
359 | ;; dependencies. | |
360 | (mkdir-p "output/target-libs") | |
0bcd1bc7 | 361 | (for-each (match-lambda |
3159ef7c DM |
362 | ((name . flags) |
363 | (write name) | |
364 | (newline) | |
365 | (apply invoke | |
366 | "output/rustc-build/rustc" | |
367 | "-C" (string-append "linker=" | |
368 | (getenv "CC")) | |
6c1a6584 DM |
369 | ;; Required for libterm. |
370 | "-Z" "force-unstable-if-unmarked" | |
3159ef7c DM |
371 | "-L" "output/target-libs" |
372 | (string-append "src/" name "/lib.rs") | |
373 | "-o" | |
374 | (string-append "output/target-libs/" | |
375 | (car (string-split name #\/)) | |
376 | ".rlib") | |
377 | flags))) | |
378 | '(("libcore") | |
379 | ("libstd_unicode") | |
380 | ("liballoc") | |
381 | ("libcollections") | |
382 | ("librand") | |
383 | ("liblibc/src" "--cfg" "stdbuild") | |
384 | ("libunwind" "-l" "gcc_s") | |
385 | ("libcompiler_builtins") | |
386 | ("liballoc_system") | |
387 | ("libpanic_unwind") | |
388 | ;; Uses "cc" to link. | |
389 | ("libstd" "-l" "dl" "-l" "rt" "-l" "pthread") | |
6c1a6584 DM |
390 | ("libarena") |
391 | ||
392 | ;; Test dependencies: | |
393 | ||
394 | ("libgetopts") | |
395 | ("libterm") | |
396 | ("libtest"))) | |
3159ef7c DM |
397 | #t))) |
398 | ;; This phase is overridden by newer versions. | |
8fdde581 DM |
399 | (replace 'check |
400 | (const #t)) | |
3159ef7c | 401 | ;; This phase is overridden by newer versions. |
8fdde581 | 402 | (replace 'install |
3159ef7c DM |
403 | (lambda* (#:key inputs outputs #:allow-other-keys) |
404 | (let* ((out (assoc-ref outputs "out")) | |
405 | (target-system ,(or (%current-target-system) | |
406 | (nix-system->gnu-triplet | |
407 | (%current-system)))) | |
408 | (out-libs (string-append out "/lib/rustlib/" | |
409 | target-system "/lib"))) | |
410 | ;(setenv "CFG_PREFIX" out) | |
411 | (mkdir-p out-libs) | |
412 | (copy-recursively "output/target-libs" out-libs) | |
413 | (install-file "output/rustc-build/rustc" | |
414 | (string-append out "/bin")) | |
5a3fcf5b DM |
415 | (install-file "output/rustc-build/rustdoc" |
416 | (string-append out "/bin")) | |
3159ef7c DM |
417 | (install-file "output/cargo-build/cargo" |
418 | (string-append (assoc-ref outputs "cargo") | |
419 | "/bin"))) | |
420 | #t))))) | |
8fdde581 DM |
421 | (build-system gnu-build-system) |
422 | (native-inputs | |
423 | `(("bison" ,bison) ; For the tests | |
c69959f0 | 424 | ("cmake" ,cmake-minimal) |
8fdde581 | 425 | ("flex" ,flex) ; For the tests |
6ba3980e MB |
426 | ;; FIXME: Rust 1.27 and some later versions require GDB 8.2 specifically. |
427 | ;; See <https://bugs.gnu.org/37810>. Use it on all Rusts for simplicity. | |
428 | ("gdb" ,gdb-8.2) ; For the tests | |
8fdde581 DM |
429 | ("procps" ,procps) ; For the tests |
430 | ("python-2" ,python-2) | |
3159ef7c DM |
431 | ("rustc-bootstrap" ,mrustc) |
432 | ("cargo-bootstrap" ,mrustc "cargo") | |
8fdde581 DM |
433 | ("pkg-config" ,pkg-config) ; For "cargo" |
434 | ("which" ,which))) | |
435 | (inputs | |
436 | `(("jemalloc" ,jemalloc-4.5.0) | |
437 | ("llvm" ,llvm-3.9.1) | |
e74f153a | 438 | ("openssl" ,openssl-1.0) |
e027a494 NM |
439 | ("libssh2" ,libssh2) ; For "cargo" |
440 | ("libcurl" ,curl))) ; For "cargo" | |
afc2bf53 | 441 | |
8fdde581 | 442 | ;; rustc invokes gcc, so we need to set its search paths accordingly. |
afc2bf53 LC |
443 | ;; Note: duplicate its value here to cope with circular dependencies among |
444 | ;; modules (see <https://bugs.gnu.org/31392>). | |
445 | (native-search-paths | |
446 | (list (search-path-specification | |
fd1fde60 | 447 | (variable "C_INCLUDE_PATH") |
afc2bf53 | 448 | (files '("include"))) |
fd1fde60 LC |
449 | (search-path-specification |
450 | (variable "CPLUS_INCLUDE_PATH") | |
451 | (files '("include/c++" "include"))) | |
afc2bf53 LC |
452 | (search-path-specification |
453 | (variable "LIBRARY_PATH") | |
03f9a8c3 | 454 | (files '("lib" "lib64"))))) |
afc2bf53 | 455 | |
0ed63186 | 456 | (supported-systems '("x86_64-linux")) |
7230f6d5 | 457 | (synopsis "Compiler for the Rust programming language") |
8fdde581 DM |
458 | (description "Rust is a systems programming language that provides memory |
459 | safety and thread safety guarantees.") | |
460 | (home-page "https://www.rust-lang.org") | |
461 | ;; Dual licensed. | |
462 | (license (list license:asl2.0 license:expat)))) | |
463 | ||
614cfd5c DM |
464 | (define-public rust-1.20 |
465 | (let ((base-rust | |
4ed20d3c | 466 | (rust-bootstrapped-package rust-1.19 "1.20.0" |
614cfd5c DM |
467 | "0542y4rnzlsrricai130mqyxl8r6rd991frb4qsnwb27yigqg91a"))) |
468 | (package | |
469 | (inherit base-rust) | |
4ed20d3c IP |
470 | (source |
471 | (origin | |
472 | (inherit (package-source base-rust)) | |
473 | (snippet '(begin | |
474 | (delete-file-recursively "src/jemalloc") | |
475 | (delete-file-recursively "src/llvm") | |
476 | #t)) | |
477 | (patches '()))) | |
47cd0feb MB |
478 | (native-inputs |
479 | `(;; The tests fail with newer versions of GNU Make. | |
480 | ("make" ,gnu-make-4.2) | |
481 | ,@(package-native-inputs base-rust))) | |
614cfd5c | 482 | (outputs '("out" "doc" "cargo")) |
7311ed3f DM |
483 | ;; Since rust-1.19 is local, it's quite probable that Hydra |
484 | ;; will build rust-1.19 only as a dependency of rust-1.20. | |
485 | ;; But then Hydra will use the wrong properties, the ones here, | |
486 | ;; for rust-1.19. Therefore, we copied the properties of | |
487 | ;; rust-1.19 here. | |
488 | (properties '((timeout . 72000) ;20 hours | |
489 | (max-silent-time . 18000))) ;5 hours (for armel) | |
614cfd5c DM |
490 | (arguments |
491 | (substitute-keyword-arguments (package-arguments rust-1.19) | |
492 | ((#:phases phases) | |
493 | `(modify-phases ,phases | |
1bfaae25 DM |
494 | (add-after 'patch-tests 'patch-cargo-tests |
495 | (lambda _ | |
496 | (substitute* "src/tools/cargo/tests/build.rs" | |
497 | (("/usr/bin/env") (which "env")) | |
498 | ;; Guix llvm is compiled without asmjs-unknown-emscripten. | |
499 | (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs")) | |
500 | (substitute* "src/tools/cargo/tests/death.rs" | |
501 | ;; This is stuck when built in container. | |
502 | (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone")) | |
503 | ;; Prints test output in the wrong order when built on | |
504 | ;; i686-linux. | |
505 | (substitute* "src/tools/cargo/tests/test.rs" | |
506 | (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env")) | |
01cef16f MB |
507 | |
508 | ;; These tests pull in a dependency on "git", which changes | |
509 | ;; too frequently take part in the Rust toolchain. | |
510 | (substitute* "src/tools/cargo/tests/new.rs" | |
511 | (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo") | |
512 | (("fn finds_author_git") "#[ignore]\nfn finds_author_git") | |
513 | (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git")) | |
1bfaae25 DM |
514 | #t)) |
515 | (add-after 'patch-cargo-tests 'ignore-glibc-2.27-incompatible-test | |
516 | ;; https://github.com/rust-lang/rust/issues/47863 | |
517 | (lambda _ | |
518 | (substitute* "src/test/run-pass/out-of-stack.rs" | |
519 | (("// ignore-android") "// ignore-test\n// ignore-android")) | |
520 | #t)) | |
614cfd5c DM |
521 | (replace 'configure |
522 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
523 | (let* ((out (assoc-ref outputs "out")) | |
524 | (doc (assoc-ref outputs "doc")) | |
525 | (gcc (assoc-ref inputs "gcc")) | |
526 | (gdb (assoc-ref inputs "gdb")) | |
527 | (binutils (assoc-ref inputs "binutils")) | |
528 | (python (assoc-ref inputs "python-2")) | |
529 | (rustc (assoc-ref inputs "rustc-bootstrap")) | |
530 | (cargo (assoc-ref inputs "cargo-bootstrap")) | |
531 | (llvm (assoc-ref inputs "llvm")) | |
532 | (jemalloc (assoc-ref inputs "jemalloc"))) | |
533 | (call-with-output-file "config.toml" | |
534 | (lambda (port) | |
535 | (display (string-append " | |
536 | [llvm] | |
537 | [build] | |
538 | cargo = \"" cargo "/bin/cargo" "\" | |
539 | rustc = \"" rustc "/bin/rustc" "\" | |
540 | docs = true | |
541 | python = \"" python "/bin/python2" "\" | |
542 | gdb = \"" gdb "/bin/gdb" "\" | |
543 | vendor = true | |
544 | submodules = false | |
545 | [install] | |
546 | prefix = \"" out "\" | |
547 | docdir = \"" doc "/share/doc/rust" "\" | |
548 | sysconfdir = \"etc\" | |
614cfd5c DM |
549 | [rust] |
550 | default-linker = \"" gcc "/bin/gcc" "\" | |
614cfd5c DM |
551 | channel = \"stable\" |
552 | rpath = true | |
553 | " ;; There are 2 failed codegen tests: | |
554 | ;; codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs | |
555 | ;; These tests require a patched LLVM | |
556 | "codegen-tests = false | |
557 | [target." ,(nix-system->gnu-triplet-for-rust) "] | |
558 | llvm-config = \"" llvm "/bin/llvm-config" "\" | |
559 | cc = \"" gcc "/bin/gcc" "\" | |
560 | cxx = \"" gcc "/bin/g++" "\" | |
91294b53 | 561 | ar = \"" binutils "/bin/ar" "\" |
614cfd5c DM |
562 | jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\" |
563 | [dist] | |
564 | ") port))) | |
565 | #t))) | |
566 | (add-after 'configure 'provide-cc | |
567 | (lambda* (#:key inputs #:allow-other-keys) | |
568 | (symlink (string-append (assoc-ref inputs "gcc") "/bin/gcc") | |
569 | "/tmp/cc") | |
570 | (setenv "PATH" (string-append "/tmp:" (getenv "PATH"))) | |
571 | #t)) | |
572 | (add-after 'provide-cc 'configure-archiver | |
573 | (lambda* (#:key inputs #:allow-other-keys) | |
574 | (substitute* "src/build_helper/lib.rs" | |
575 | ;; Make sure "ar" is always used as the archiver. | |
576 | (("\"musl\"") "\"\"") | |
577 | ;; Then substitute "ar" by our name. | |
578 | (("\"ar\"") (string-append "\"" | |
579 | (assoc-ref inputs "binutils") | |
580 | "/bin/ar\""))) | |
581 | #t)) | |
582 | (delete 'patch-cargo-tomls) | |
583 | (add-before 'build 'reset-timestamps-after-changes | |
584 | (lambda* _ | |
614cfd5c DM |
585 | (for-each |
586 | (lambda (filename) | |
e0b07ccc DM |
587 | ;; Rust 1.20.0 treats timestamp 0 as "file doesn't exist". |
588 | ;; Therefore, use timestamp 1. | |
589 | (utime filename 1 1 1 1)) | |
614cfd5c DM |
590 | (find-files "." #:directories? #t)) |
591 | #t)) | |
592 | (replace 'build | |
593 | (lambda* _ | |
594 | (invoke "./x.py" "build") | |
595 | (invoke "./x.py" "build" "src/tools/cargo"))) | |
596 | (replace 'check | |
597 | (lambda* _ | |
598 | ;; Disable parallel execution to prevent EAGAIN errors when | |
599 | ;; running tests. | |
600 | (invoke "./x.py" "-j1" "test" "-vv") | |
601 | (invoke "./x.py" "-j1" "test" "src/tools/cargo") | |
602 | #t)) | |
603 | (replace 'install | |
604 | (lambda* (#:key outputs #:allow-other-keys) | |
605 | (invoke "./x.py" "install") | |
606 | (substitute* "config.toml" | |
607 | ;; replace prefix to specific output | |
608 | (("prefix = \"[^\"]*\"") | |
609 | (string-append "prefix = \"" (assoc-ref outputs "cargo") "\""))) | |
610 | (invoke "./x.py" "install" "cargo"))) | |
bea01c0d IP |
611 | (add-after 'install 'delete-install-logs |
612 | (lambda* (#:key outputs #:allow-other-keys) | |
613 | (define (delete-manifest-file out-path file) | |
614 | (delete-file (string-append out-path "/lib/rustlib/" file))) | |
615 | ||
616 | (let ((out (assoc-ref outputs "out")) | |
617 | (cargo-out (assoc-ref outputs "cargo"))) | |
618 | (for-each | |
619 | (lambda (file) (delete-manifest-file out file)) | |
620 | '("install.log" | |
621 | "manifest-rust-docs" | |
2bab532f PL |
622 | ,(string-append "manifest-rust-std-" |
623 | (nix-system->gnu-triplet-for-rust)) | |
bea01c0d IP |
624 | "manifest-rustc")) |
625 | (for-each | |
626 | (lambda (file) (delete-manifest-file cargo-out file)) | |
627 | '("install.log" | |
628 | "manifest-cargo")) | |
629 | #t))) | |
614cfd5c DM |
630 | (add-after 'install 'wrap-rustc |
631 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
632 | (let ((out (assoc-ref outputs "out")) | |
633 | (libc (assoc-ref inputs "libc")) | |
634 | (ld-wrapper (assoc-ref inputs "ld-wrapper"))) | |
635 | ;; Let gcc find ld and libc startup files. | |
636 | (wrap-program (string-append out "/bin/rustc") | |
637 | `("PATH" ":" prefix (,(string-append ld-wrapper "/bin"))) | |
638 | `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib")))) | |
639 | #t)))))))))) | |
640 | ||
05ebff92 | 641 | (define-public rust-1.21 |
4ed20d3c | 642 | (let ((base-rust (rust-bootstrapped-package rust-1.20 "1.21.0" |
7bf169f7 DM |
643 | "1yj8lnxybjrybp00fqhxw8fpr641dh8wcn9mk44xjnsb4i1c21qp"))) |
644 | (package | |
645 | (inherit base-rust) | |
646 | (arguments | |
647 | (substitute-keyword-arguments (package-arguments base-rust) | |
648 | ((#:phases phases) | |
649 | `(modify-phases ,phases | |
650 | (add-after 'configure 'remove-ar | |
651 | (lambda* (#:key inputs #:allow-other-keys) | |
652 | ;; Remove because toml complains about "unknown field". | |
653 | (substitute* "config.toml" | |
654 | (("^ar =.*") "\n")) | |
655 | #t))))))))) | |
05ebff92 | 656 | |
1ab3e1dd | 657 | (define-public rust-1.22 |
4ed20d3c | 658 | (let ((base-rust (rust-bootstrapped-package rust-1.21 "1.22.1" |
8cddb0d6 DM |
659 | "1lrzzp0nh7s61wgfs2h6ilaqi6iq89f1pd1yaf65l87bssyl4ylb"))) |
660 | (package | |
661 | (inherit base-rust) | |
662 | (arguments | |
663 | (substitute-keyword-arguments (package-arguments base-rust) | |
664 | ((#:phases phases) | |
665 | `(modify-phases ,phases | |
666 | (add-after 'unpack 'remove-flaky-test | |
667 | (lambda _ | |
668 | ;; See <https://github.com/rust-lang/rust/issues/43402>. | |
669 | (when (file-exists? "src/test/run-make/issue-26092") | |
670 | (delete-file-recursively "src/test/run-make/issue-26092")) | |
671 | #t))))))))) | |
1ab3e1dd | 672 | |
8fdde581 | 673 | (define-public rust-1.23 |
4ed20d3c | 674 | (let ((base-rust (rust-bootstrapped-package rust-1.22 "1.23.0" |
44d530ef DM |
675 | "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l"))) |
676 | (package | |
677 | (inherit base-rust) | |
678 | (arguments | |
679 | (substitute-keyword-arguments (package-arguments base-rust) | |
680 | ((#:phases phases) | |
681 | `(modify-phases ,phases | |
682 | (delete 'configure-archiver) | |
683 | (delete 'remove-ar) | |
684 | (add-after 'unpack 'dont-build-native | |
685 | (lambda _ | |
686 | ;; XXX: Revisit this when we use gcc 6. | |
687 | (substitute* "src/binaryen/CMakeLists.txt" | |
688 | (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") "")) | |
689 | #t))))))))) | |
b5a09649 | 690 | |
fe61c88a | 691 | (define-public rust-1.24 |
ca523cc5 | 692 | (let ((base-rust |
4ed20d3c | 693 | (rust-bootstrapped-package rust-1.23 "1.24.1" |
339c1365 | 694 | "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y"))) |
f342bb58 NM |
695 | (package |
696 | (inherit base-rust) | |
f342bb58 NM |
697 | (arguments |
698 | (substitute-keyword-arguments (package-arguments base-rust) | |
ca523cc5 DM |
699 | ((#:phases phases) |
700 | `(modify-phases ,phases | |
b47b2d32 NM |
701 | (delete 'use-readelf-for-tests) |
702 | (replace 'patch-aarch64-test | |
703 | (lambda* _ | |
704 | (substitute* "src/librustc_metadata/dynamic_lib.rs" | |
705 | ;; This test is known to fail on aarch64 and powerpc64le: | |
706 | ;; https://github.com/rust-lang/rust/issues/45410 | |
707 | (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine")) | |
e0b07ccc | 708 | #t))))))))) |
fe61c88a | 709 | |
e027a494 NM |
710 | ;;; Rust 1.25 release support work with llvm 6--but build with llvm 6 is |
711 | ;;; not determenistic due to <https://github.com/rust-lang/rust/issues/50556>. | |
712 | ;;; Keep using llvm 3.9.1 until builds become determenistic | |
b47b2d32 NM |
713 | (define-public rust-1.25 |
714 | (let ((base-rust | |
4ed20d3c IP |
715 | (rust-bootstrapped-package rust-1.24 "1.25.0" |
716 | "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf"))) | |
fe61c88a NM |
717 | (package |
718 | (inherit base-rust) | |
4ed20d3c IP |
719 | (source |
720 | (origin | |
721 | (inherit (package-source base-rust)) | |
722 | (snippet '(begin | |
723 | (delete-file-recursively "src/jemalloc") | |
724 | (delete-file-recursively "src/llvm") | |
725 | (delete-file-recursively "src/llvm-emscripten") | |
726 | #t)) | |
e28a824f JK |
727 | (patches (search-patches |
728 | "rust-1.25-accept-more-detailed-gdb-lines.patch")))) | |
fe61c88a NM |
729 | (arguments |
730 | (substitute-keyword-arguments (package-arguments base-rust) | |
731 | ((#:phases phases) | |
732 | `(modify-phases ,phases | |
733 | (add-after 'patch-cargo-tests 'patch-cargo-index-update | |
080e11b4 | 734 | (lambda _ |
fe61c88a NM |
735 | (substitute* "src/tools/cargo/tests/generate-lockfile.rs" |
736 | ;; This test wants to update the crate index. | |
080e11b4 EF |
737 | (("fn no_index_update") "#[ignore]\nfn no_index_update")) |
738 | #t)) | |
080e11b4 EF |
739 | (replace 'patch-aarch64-test |
740 | (lambda _ | |
741 | (substitute* "src/librustc_metadata/dynamic_lib.rs" | |
742 | ;; This test is known to fail on aarch64 and powerpc64le: | |
743 | ;; https://github.com/rust-lang/rust/issues/45410 | |
744 | (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine")) | |
745 | ;; This test fails on aarch64 with llvm@6.0: | |
746 | ;; https://github.com/rust-lang/rust/issues/49807 | |
747 | ;; other possible solution: | |
748 | ;; https://github.com/rust-lang/rust/pull/47688 | |
749 | (delete-file "src/test/debuginfo/by-value-self-argument-in-trait-impl.rs") | |
750 | #t)) | |
b47b2d32 NM |
751 | (delete 'ignore-glibc-2.27-incompatible-test)))))))) |
752 | ||
f510a2b9 | 753 | (define-public rust-1.26 |
b47b2d32 | 754 | (let ((base-rust |
4ed20d3c IP |
755 | (rust-bootstrapped-package rust-1.25 "1.26.2" |
756 | "0047ais0fvmqvngqkdsxgrzhb0kljg8wy85b01kbbjc88hqcz7pv"))) | |
b47b2d32 NM |
757 | (package |
758 | (inherit base-rust) | |
4ed20d3c IP |
759 | (source |
760 | (origin | |
761 | (inherit (package-source base-rust)) | |
e28a824f JK |
762 | (patches (search-patches |
763 | "rust-coresimd-doctest.patch" | |
764 | "rust-1.25-accept-more-detailed-gdb-lines.patch")))) | |
b9c30fe7 EF |
765 | (inputs |
766 | (alist-replace "openssl" (list openssl) | |
767 | (package-inputs base-rust))) | |
b47b2d32 NM |
768 | (arguments |
769 | (substitute-keyword-arguments (package-arguments base-rust) | |
770 | ((#:phases phases) | |
771 | `(modify-phases ,phases | |
772 | ;; binaryen was replaced with LLD project from LLVM | |
773 | (delete 'dont-build-native) | |
55548cdc DM |
774 | (replace 'check |
775 | (lambda* _ | |
776 | ;; Enable parallel execution. | |
777 | (let ((parallel-job-spec | |
778 | (string-append "-j" (number->string | |
779 | (min 4 | |
780 | (parallel-job-count)))))) | |
781 | (invoke "./x.py" parallel-job-spec "test" "-vv") | |
782 | (invoke "./x.py" parallel-job-spec "test" | |
783 | "src/tools/cargo")))) | |
b47b2d32 NM |
784 | (replace 'remove-unsupported-tests |
785 | (lambda* _ | |
786 | ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH. | |
787 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html> | |
788 | (delete-file-recursively "src/test/run-make-fulldeps/linker-output-non-utf8") | |
789 | #t)) | |
790 | (replace 'patch-cargo-tests | |
791 | (lambda* _ | |
792 | (substitute* "src/tools/cargo/tests/testsuite/build.rs" | |
793 | (("/usr/bin/env") (which "env")) | |
794 | ;; Guix llvm is compiled without asmjs-unknown-emscripten. | |
795 | (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs")) | |
796 | (substitute* "src/tools/cargo/tests/testsuite/death.rs" | |
797 | ;; This is stuck when built in container. | |
798 | (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone")) | |
799 | ;; Prints test output in the wrong order when built on | |
800 | ;; i686-linux. | |
801 | (substitute* "src/tools/cargo/tests/testsuite/test.rs" | |
802 | (("fn cargo_test_env") "#[ignore]\nfn cargo_test_env")) | |
01cef16f MB |
803 | |
804 | ;; Avoid dependency on "git". | |
805 | (substitute* "src/tools/cargo/tests/testsuite/new.rs" | |
806 | (("fn author_prefers_cargo") "#[ignore]\nfn author_prefers_cargo") | |
807 | (("fn finds_author_git") "#[ignore]\nfn finds_author_git") | |
808 | (("fn finds_local_author_git") "#[ignore]\nfn finds_local_author_git")) | |
b47b2d32 NM |
809 | #t)) |
810 | (add-after 'patch-cargo-tests 'disable-cargo-test-for-nightly-channel | |
811 | (lambda* _ | |
812 | ;; This test failed to work on "nightly" channel builds | |
813 | ;; https://github.com/rust-lang/cargo/issues/5648 | |
814 | (substitute* "src/tools/cargo/tests/testsuite/resolve.rs" | |
815 | (("fn test_resolving_minimum_version_with_transitive_deps") | |
816 | "#[ignore]\nfn test_resolving_minimum_version_with_transitive_deps")) | |
817 | #t)) | |
818 | (replace 'patch-cargo-index-update | |
819 | (lambda* _ | |
820 | (substitute* "src/tools/cargo/tests/testsuite/generate_lockfile.rs" | |
821 | ;; This test wants to update the crate index. | |
822 | (("fn no_index_update") "#[ignore]\nfn no_index_update")) | |
823 | #t))))))))) | |
f510a2b9 | 824 | |
2e2b8635 | 825 | (define-public rust-1.27 |
f510a2b9 | 826 | (let ((base-rust |
4ed20d3c IP |
827 | (rust-bootstrapped-package rust-1.26 "1.27.2" |
828 | "0pg1s37bhx9zqbynxyydq5j6q7kij9vxkcv8maz0m25prm88r0cs"))) | |
f510a2b9 NM |
829 | (package |
830 | (inherit base-rust) | |
4ed20d3c IP |
831 | (source |
832 | (origin | |
833 | (inherit (package-source base-rust)) | |
e28a824f JK |
834 | (patches (search-patches "rust-coresimd-doctest.patch" |
835 | "rust-bootstrap-stage0-test.patch" | |
836 | "rust-1.25-accept-more-detailed-gdb-lines.patch" | |
837 | "rust-reproducible-builds.patch")))) | |
f510a2b9 NM |
838 | (arguments |
839 | (substitute-keyword-arguments (package-arguments base-rust) | |
840 | ((#:phases phases) | |
841 | `(modify-phases ,phases | |
842 | (add-before 'install 'mkdir-prefix-paths | |
843 | (lambda* (#:key outputs #:allow-other-keys) | |
844 | ;; As result of https://github.com/rust-lang/rust/issues/36989 | |
845 | ;; `prefix' directory should exist before `install' call | |
846 | (mkdir-p (assoc-ref outputs "out")) | |
847 | (mkdir-p (assoc-ref outputs "cargo")) | |
e027a494 NM |
848 | #t)) |
849 | (add-after 'patch-cargo-tests 'disable-thinlto-test | |
850 | (lambda* _ | |
851 | ;; thinlto required llvm 6.0 for work | |
852 | (substitute* "src/tools/cargo/tests/testsuite/path.rs" | |
853 | (("fn thin_lto_works") "#[ignore]\nfn thin_lto_works")) | |
f510a2b9 | 854 | #t))))))))) |
2e2b8635 | 855 | |
0e9811f4 | 856 | (define-public rust-1.28 |
2e2b8635 | 857 | (let ((base-rust |
4ed20d3c IP |
858 | (rust-bootstrapped-package rust-1.27 "1.28.0" |
859 | "11k4rn77bca2rikykkk9fmprrgjswd4x4kaq7fia08vgkir82nhx"))) | |
2e2b8635 NM |
860 | (package |
861 | (inherit base-rust) | |
4ed20d3c IP |
862 | (source |
863 | (origin | |
864 | (inherit (package-source base-rust)) | |
e28a824f JK |
865 | (patches (search-patches "rust-coresimd-doctest.patch" |
866 | "rust-bootstrap-stage0-test.patch" | |
867 | "rust-1.25-accept-more-detailed-gdb-lines.patch" | |
868 | "rust-reproducible-builds.patch")))) | |
2e2b8635 NM |
869 | (inputs |
870 | ;; Use LLVM 6.0 | |
de6ad8c2 | 871 | (alist-replace "llvm" (list llvm-6) |
2e2b8635 NM |
872 | (package-inputs base-rust))) |
873 | (arguments | |
874 | (substitute-keyword-arguments (package-arguments base-rust) | |
875 | ((#:phases phases) | |
876 | `(modify-phases ,phases | |
877 | (add-after 'configure 'enable-codegen-tests | |
878 | ;; Codegen tests should pass with llvm 6, so enable them. | |
879 | (lambda* _ | |
880 | (substitute* "config.toml" | |
881 | (("codegen-tests = false") "")) | |
882 | #t)) | |
883 | (add-after 'patch-tests 'disable-amd64-avx-test | |
884 | ;; That test would fail on x86_64 machines without avx. | |
885 | (lambda* _ | |
886 | (substitute* "src/test/run-pass/issue-44056.rs" | |
887 | (("only-x86_64") "ignore-test")) | |
888 | #t)) | |
810f4cc1 EF |
889 | ;; This is no longer needed as of 1.28 |
890 | (delete 'disable-cargo-test-for-nightly-channel) | |
2e2b8635 NM |
891 | ;; The thinlto test should pass with llvm 6. |
892 | (delete 'disable-thinlto-test)))))))) | |
0e9811f4 | 893 | |
1a3db0b2 | 894 | (define-public rust-1.29 |
0e9811f4 | 895 | (let ((base-rust |
4ed20d3c IP |
896 | (rust-bootstrapped-package rust-1.28 "1.29.2" |
897 | "1jb787080z754caa2w3w1amsygs4qlzj9rs1vy64firfmabfg22h"))) | |
0e9811f4 | 898 | (package |
4ed20d3c IP |
899 | (inherit base-rust) |
900 | (source | |
901 | (origin | |
902 | (inherit (package-source base-rust)) | |
e28a824f JK |
903 | (patches (search-patches "rust-1.25-accept-more-detailed-gdb-lines.patch" |
904 | "rust-reproducible-builds.patch"))))))) | |
1a3db0b2 IP |
905 | |
906 | (define-public rust-1.30 | |
907 | (let ((base-rust | |
4ed20d3c IP |
908 | (rust-bootstrapped-package rust-1.29 "1.30.1" |
909 | "0aavdc1lqv0cjzbqwl5n59yd0bqdlhn0zas61ljf38yrvc18k8rn"))) | |
1a3db0b2 IP |
910 | (package |
911 | (inherit base-rust) | |
4ed20d3c IP |
912 | (source |
913 | (origin | |
914 | (inherit (package-source base-rust)) | |
915 | (snippet '(begin | |
916 | (delete-file-recursively "src/jemalloc") | |
917 | (delete-file-recursively "src/llvm") | |
918 | (delete-file-recursively "src/llvm-emscripten") | |
919 | (delete-file-recursively "src/tools/clang") | |
920 | (delete-file-recursively "src/tools/lldb") | |
f309420b | 921 | #t)))) |
1a3db0b2 IP |
922 | (arguments |
923 | (substitute-keyword-arguments (package-arguments base-rust) | |
924 | ((#:phases phases) | |
925 | `(modify-phases ,phases | |
926 | (add-after 'patch-cargo-tests 'patch-cargo-env-shebang | |
927 | (lambda* (#:key inputs #:allow-other-keys) | |
928 | (let ((coreutils (assoc-ref inputs "coreutils"))) | |
929 | (substitute* "src/tools/cargo/tests/testsuite/fix.rs" | |
930 | ;; Cargo has a test which explicitly sets a | |
931 | ;; RUSTC_WRAPPER environment variable which points | |
932 | ;; to /usr/bin/env. Since it's not a shebang, it | |
933 | ;; needs to be manually patched | |
934 | (("\"/usr/bin/env\"") | |
935 | (string-append "\"" coreutils "/bin/env\""))) | |
936 | #t))) | |
937 | (add-after 'patch-cargo-env-shebang 'ignore-cargo-package-tests | |
938 | (lambda* _ | |
939 | (substitute* "src/tools/cargo/tests/testsuite/package.rs" | |
940 | ;; These tests largely check that cargo outputs warning/error | |
941 | ;; messages as expected. It seems that cargo outputs an | |
942 | ;; absolute path to something in the store instead of the | |
943 | ;; expected relative path (e.g. `[..]`) so we'll ignore | |
944 | ;; these for now | |
945 | (("fn include") "#[ignore]\nfn include") | |
946 | (("fn exclude") "#[ignore]\nfn exclude")) | |
947 | #t)) | |
586d30ca DM |
948 | ;; The test has been moved elsewhere. |
949 | (replace 'disable-amd64-avx-test | |
950 | (lambda _ | |
951 | (substitute* "src/test/ui/run-pass/issues/issue-44056.rs" | |
444bc2dd | 952 | (("only-x86_64") "ignore-test")) |
586d30ca | 953 | #t))))))))) |
1a3db0b2 | 954 | |
444bc2dd JK |
955 | (define (patch-command-exec-tests-phase test-path) |
956 | "The command-exec.rs test moves around between releases. We need to apply | |
957 | a Guix-specific patch to it for each release. This function generates the phase | |
958 | that applies said patch, parametrized by the test-path. This is done this way | |
959 | because the phase is more complex than the equivalents for other tests that | |
960 | move around." | |
961 | `(lambda* (#:key inputs #:allow-other-keys) | |
962 | (let ((coreutils (assoc-ref inputs "coreutils"))) | |
963 | (substitute* ,test-path | |
964 | ;; This test suite includes some tests that the stdlib's | |
965 | ;; `Command` execution properly handles situations where | |
966 | ;; the environment or PATH variable are empty, but this | |
967 | ;; fails since we don't have `echo` available in the usual | |
968 | ;; Linux directories. | |
969 | ;; NB: the leading space is so we don't fail a tidy check | |
970 | ;; for trailing whitespace, and the newlines are to ensure | |
971 | ;; we don't exceed the 100 chars tidy check as well | |
972 | ((" Command::new\\(\"echo\"\\)") | |
973 | (string-append "\nCommand::new(\"" coreutils "/bin/echo\")\n"))) | |
974 | #t))) | |
975 | ||
d7d3bdca | 976 | (define-public rust-1.31 |
1a3db0b2 | 977 | (let ((base-rust |
4ed20d3c IP |
978 | (rust-bootstrapped-package rust-1.30 "1.31.1" |
979 | "0sk84ff0cklybcp0jbbxcw7lk7mrm6kb6km5nzd6m64dy0igrlli"))) | |
1a3db0b2 IP |
980 | (package |
981 | (inherit base-rust) | |
982 | (arguments | |
983 | (substitute-keyword-arguments (package-arguments base-rust) | |
984 | ((#:phases phases) | |
985 | `(modify-phases ,phases | |
986 | (add-after 'patch-tests 'patch-command-exec-tests | |
444bc2dd JK |
987 | ,(patch-command-exec-tests-phase |
988 | "src/test/run-pass/command-exec.rs")) | |
989 | ;; The test has been moved elsewhere. | |
990 | (replace 'disable-amd64-avx-test | |
991 | (lambda _ | |
992 | (substitute* "src/test/ui/issues/issue-44056.rs" | |
993 | (("only-x86_64") "ignore-test")) | |
994 | #t)) | |
1a3db0b2 IP |
995 | (add-after 'patch-tests 'patch-process-docs-rev-cmd |
996 | (lambda* _ | |
997 | ;; Disable some doc tests which depend on the "rev" command | |
998 | ;; https://github.com/rust-lang/rust/pull/58746 | |
999 | (substitute* "src/libstd/process.rs" | |
1000 | (("```rust") "```rust,no_run")) | |
1001 | #t))))))))) | |
d7d3bdca | 1002 | |
6d511a53 | 1003 | (define-public rust-1.32 |
d7d3bdca IP |
1004 | (let ((base-rust |
1005 | (rust-bootstrapped-package rust-1.31 "1.32.0" | |
4ed20d3c | 1006 | "0ji2l9xv53y27xy72qagggvq47gayr5lcv2jwvmfirx029vlqnac"))) |
d7d3bdca IP |
1007 | (package |
1008 | (inherit base-rust) | |
4ed20d3c IP |
1009 | (source |
1010 | (origin | |
1011 | (inherit (package-source base-rust)) | |
1012 | (snippet '(begin (delete-file-recursively "src/llvm") | |
1013 | (delete-file-recursively "src/llvm-emscripten") | |
1014 | (delete-file-recursively "src/tools/clang") | |
1015 | (delete-file-recursively "src/tools/lldb") | |
1016 | (delete-file-recursively "vendor/jemalloc-sys/jemalloc") | |
1017 | #t)) | |
e28a824f | 1018 | (patches (search-patches "rust-reproducible-builds.patch")) |
4ed20d3c IP |
1019 | ;; the vendor directory has moved to the root of |
1020 | ;; the tarball, so we have to strip an extra prefix | |
1021 | (patch-flags '("-p2")))) | |
d7d3bdca IP |
1022 | (inputs |
1023 | ;; Downgrade to LLVM 6, all LTO tests appear to fail with LLVM 7.0.1 | |
1024 | (alist-replace "llvm" (list llvm-6) | |
1025 | (package-inputs base-rust))) | |
1026 | (arguments | |
1027 | (substitute-keyword-arguments (package-arguments base-rust) | |
1028 | ((#:phases phases) | |
1029 | `(modify-phases ,phases | |
1030 | ;; Cargo.lock and the vendor/ directory have been moved to the | |
1031 | ;; root of the rust tarball | |
1032 | (replace 'patch-cargo-checksums | |
1033 | (lambda* _ | |
4585859f | 1034 | (use-modules (guix build cargo-utils)) |
d7d3bdca IP |
1035 | (substitute* "Cargo.lock" |
1036 | (("(\"checksum .* = )\".*\"" all name) | |
1037 | (string-append name "\"" ,%cargo-reference-hash "\""))) | |
e07b0488 | 1038 | (generate-all-checksums "vendor") |
d7d3bdca IP |
1039 | #t)) |
1040 | (add-after 'enable-codegen-tests 'override-jemalloc | |
1041 | (lambda* (#:key inputs #:allow-other-keys) | |
1042 | ;; The compiler is no longer directly built against jemalloc, | |
1043 | ;; but rather via the jemalloc-sys crate (which vendors the | |
1044 | ;; jemalloc source). To use jemalloc we must enable linking to | |
1045 | ;; it (otherwise it would use the system allocator), and set | |
1046 | ;; an environment variable pointing to the compiled jemalloc. | |
1047 | (substitute* "config.toml" | |
1048 | (("^jemalloc =.*$") "") | |
1049 | (("[[]rust[]]") "\n[rust]\njemalloc=true\n")) | |
1050 | (setenv "JEMALLOC_OVERRIDE" (string-append (assoc-ref inputs "jemalloc") | |
1051 | "/lib/libjemalloc_pic.a")) | |
1052 | #t)) | |
1053 | ;; Remove no longer relevant steps | |
1054 | (delete 'remove-flaky-test) | |
1055 | (delete 'patch-aarch64-test)))))))) | |
6d511a53 IP |
1056 | |
1057 | (define-public rust-1.33 | |
1058 | (let ((base-rust | |
1059 | (rust-bootstrapped-package rust-1.32 "1.33.0" | |
4ed20d3c | 1060 | "152x91mg7bz4ygligwjb05fgm1blwy2i70s2j03zc9jiwvbsh0as"))) |
6d511a53 IP |
1061 | (package |
1062 | (inherit base-rust) | |
4ed20d3c IP |
1063 | (source |
1064 | (origin | |
1065 | (inherit (package-source base-rust)) | |
1066 | (patches '()) | |
1067 | (patch-flags '("-p1")))) | |
6d511a53 IP |
1068 | (inputs |
1069 | ;; Upgrade to jemalloc@5.1.0 | |
1070 | (alist-replace "jemalloc" (list jemalloc) | |
1071 | (package-inputs base-rust))) | |
1072 | (arguments | |
1073 | (substitute-keyword-arguments (package-arguments base-rust) | |
1074 | ((#:phases phases) | |
1075 | `(modify-phases ,phases | |
1076 | (delete 'ignore-cargo-package-tests) | |
1077 | (add-after 'configure 'configure-test-threads | |
1078 | ;; Several rustc and cargo tests will fail if run on one core | |
1079 | ;; https://github.com/rust-lang/rust/issues/59122 | |
1080 | ;; https://github.com/rust-lang/cargo/issues/6746 | |
1081 | ;; https://github.com/rust-lang/rust/issues/58907 | |
1082 | (lambda* (#:key inputs #:allow-other-keys) | |
1083 | (setenv "RUST_TEST_THREADS" "2") | |
1084 | #t))))))))) | |
1085 | ||
0ab5e91e | 1086 | (define-public rust-1.34 |
a5c72da4 | 1087 | (let ((base-rust |
3d8033af IP |
1088 | (rust-bootstrapped-package rust-1.33 "1.34.1" |
1089 | "19s09k7y5j6g3y4d2rk6kg9pvq6ml94c49w6b72dmq8p9lk8bixh"))) | |
a5c72da4 IP |
1090 | (package |
1091 | (inherit base-rust) | |
1092 | (source | |
1093 | (origin | |
1094 | (inherit (package-source base-rust)) | |
1095 | (snippet '(begin | |
1096 | (delete-file-recursively "src/llvm-emscripten") | |
1097 | (delete-file-recursively "src/llvm-project") | |
1098 | (delete-file-recursively "vendor/jemalloc-sys/jemalloc") | |
1099 | #t))))))) | |
0ab5e91e | 1100 | |
f67f93b6 | 1101 | (define-public rust-1.35 |
0ab5e91e IP |
1102 | (let ((base-rust |
1103 | (rust-bootstrapped-package rust-1.34 "1.35.0" | |
1104 | "0bbizy6b7002v1rdhrxrf5gijclbyizdhkglhp81ib3bf5x66kas"))) | |
1105 | (package | |
1106 | (inherit base-rust) | |
f5de2b9a IP |
1107 | (inputs |
1108 | (alist-replace "llvm" (list llvm-8) | |
1109 | (package-inputs base-rust))) | |
0ab5e91e IP |
1110 | (arguments |
1111 | (substitute-keyword-arguments (package-arguments base-rust) | |
1112 | ((#:phases phases) | |
1113 | `(modify-phases ,phases | |
1114 | ;; The tidy test includes a pass which ensures large binaries | |
1115 | ;; don't accidentally get checked into the rust git repo. | |
1116 | ;; Unfortunately the test assumes that git is always available, | |
1117 | ;; so we'll comment out the invocation of this pass. | |
1118 | (add-after 'configure 'disable-tidy-bins-check | |
1119 | (lambda* _ | |
1120 | (substitute* "src/tools/tidy/src/main.rs" | |
1121 | (("bins::check") "//bins::check")) | |
1122 | #t))))))))) | |
f67f93b6 | 1123 | |
02c61278 | 1124 | (define-public rust-1.36 |
f67f93b6 IP |
1125 | (let ((base-rust |
1126 | (rust-bootstrapped-package rust-1.35 "1.36.0" | |
ca31f76b | 1127 | "06xv2p6zq03lidr0yaf029ii8wnjjqa894nkmrm6s0rx47by9i04"))) |
f67f93b6 IP |
1128 | (package |
1129 | (inherit base-rust) | |
1130 | (arguments | |
1131 | (substitute-keyword-arguments (package-arguments base-rust) | |
1132 | ((#:phases phases) | |
1133 | `(modify-phases ,phases | |
1134 | (delete 'patch-process-docs-rev-cmd)))))))) | |
02c61278 | 1135 | |
444bc2dd | 1136 | (define-public rust-1.37 |
02c61278 IP |
1137 | (let ((base-rust |
1138 | (rust-bootstrapped-package rust-1.36 "1.37.0" | |
1139 | "1hrqprybhkhs6d9b5pjskfnc5z9v2l2gync7nb39qjb5s0h703hj"))) | |
1140 | (package | |
1141 | (inherit base-rust) | |
1142 | (arguments | |
1143 | (substitute-keyword-arguments (package-arguments base-rust) | |
1144 | ((#:phases phases) | |
1145 | `(modify-phases ,phases | |
1146 | (add-before 'configure 'configure-cargo-home | |
1147 | (lambda _ | |
1148 | (let ((cargo-home (string-append (getcwd) "/.cargo"))) | |
1149 | (mkdir-p cargo-home) | |
1150 | (setenv "CARGO_HOME" cargo-home) | |
1151 | #t)))))))))) | |
444bc2dd JK |
1152 | |
1153 | (define-public rust-1.38 | |
1154 | (let ((base-rust | |
1155 | (rust-bootstrapped-package rust-1.37 "1.38.0" | |
1156 | "101dlpsfkq67p0hbwx4acqq6n90dj4bbprndizpgh1kigk566hk4"))) | |
1157 | (package | |
1158 | (inherit base-rust) | |
db560487 | 1159 | (inputs |
7befec25 JK |
1160 | (alist-replace "llvm" (list llvm-9) |
1161 | (package-inputs base-rust))) | |
444bc2dd JK |
1162 | (arguments |
1163 | (substitute-keyword-arguments (package-arguments base-rust) | |
1164 | ((#:phases phases) | |
1165 | `(modify-phases ,phases | |
1166 | (replace 'patch-command-exec-tests | |
1167 | ,(patch-command-exec-tests-phase | |
1168 | "src/test/ui/command-exec.rs")) | |
1169 | (add-after 'patch-tests 'patch-command-uid-gid-test | |
1170 | (lambda _ | |
1171 | (substitute* "src/test/ui/command-uid-gid.rs" | |
1172 | (("/bin/sh") (which "sh")) | |
1173 | (("ignore-sgx") "ignore-sgx\n// ignore-tidy-linelength")) | |
1174 | #t))))))))) | |
1175 | ||
9483782a JK |
1176 | (define-public rust-1.39 |
1177 | (let ((base-rust | |
1178 | (rust-bootstrapped-package rust-1.38 "1.39.0" | |
1179 | "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl"))) | |
1180 | (package | |
1181 | (inherit base-rust) | |
1182 | (arguments | |
1183 | (substitute-keyword-arguments (package-arguments base-rust) | |
1184 | ((#:phases phases) | |
1185 | `(modify-phases ,phases | |
1186 | (replace 'patch-cargo-checksums | |
1187 | ;; The Cargo.lock format changed. | |
1188 | (lambda* _ | |
1189 | (use-modules (guix build cargo-utils)) | |
1190 | (substitute* "Cargo.lock" | |
1191 | (("(checksum = )\".*\"" all name) | |
1192 | (string-append name "\"" ,%cargo-reference-hash "\""))) | |
1193 | (generate-all-checksums "vendor") | |
1194 | #t))))))))) | |
1195 | ||
7befec25 JK |
1196 | (define-public rust-1.40 |
1197 | (let ((base-rust | |
1198 | (rust-bootstrapped-package rust-1.39 "1.40.0" | |
1199 | "1ba9llwhqm49w7sz3z0gqscj039m53ky9wxzhaj11z6yg1ah15yx"))) | |
1200 | (package | |
1201 | (inherit base-rust) | |
7befec25 JK |
1202 | (source |
1203 | (origin | |
1204 | (inherit (package-source base-rust)) | |
1205 | ;; llvm-emscripten is no longer bundled, as that codegen backend | |
1206 | ;; got removed. | |
1207 | (snippet '(begin | |
1208 | (delete-file-recursively "src/llvm-project") | |
1209 | (delete-file-recursively "vendor/jemalloc-sys/jemalloc") | |
1210 | #t)))) | |
1211 | (arguments | |
1212 | ;; Rust 1.40 does not ship rustc-internal libraries by default | |
1213 | ;; (see rustc-dev-split). This means that librustc_driver.so is no | |
1214 | ;; longer available in lib/rustlib/$target/lib, which is the directory | |
1215 | ;; included in the runpath of librustc_codegen_llvm-llvm.so. | |
1216 | ;; This is detected by our validate-runpath phase as an error, but it | |
1217 | ;; is harmless as the codegen backend is loaded by librustc_driver.so | |
1218 | ;; itself, which must at that point have been already loaded. | |
1219 | ;; As such, we skip validating the runpath for Rust 1.40. | |
1220 | ;; Rust 1.41 stopped putting the codegen backend in a separate library, | |
1221 | ;; which makes this workaround only necessary for this release. | |
1222 | (cons* #:validate-runpath? #f | |
1223 | (substitute-keyword-arguments (package-arguments base-rust) | |
1224 | ((#:phases phases) | |
1225 | `(modify-phases ,phases | |
1226 | ;; We often need to patch tests with various Guix-specific paths. | |
1227 | ;; This often increases the line length and makes tidy, rustc's | |
1228 | ;; style checker, complain. We could insert additional newlines | |
1229 | ;; or add an "// ignore-tidy-linelength" comment, but as an | |
1230 | ;; ignore comment must be used, both approaches are fragile due | |
1231 | ;; to upstream formatting changes. As such, disable running the | |
1232 | ;; linter during tests, since it's intended for rustc developers | |
1233 | ;; anyway. | |
1234 | ;; | |
1235 | ;; TODO(rebuild-rust): This phase could be added earlier to | |
1236 | ;; simplify a significant amount of code, but it would require | |
1237 | ;; rebuilding the entire rusty universe. | |
1238 | (add-after 'patch-tests 'neuter-tidy | |
1239 | (lambda _ | |
1240 | (substitute* "src/bootstrap/builder.rs" | |
1241 | (("^.*::Tidy,") "")) | |
1242 | #t)) | |
1243 | ;; TODO(rebuild-rust): Adapt the find-files approach for | |
1244 | ;; earlier testsuite patches. | |
1245 | (replace 'patch-command-uid-gid-test | |
1246 | (lambda _ | |
1247 | (match (find-files "src/test" "command-uid-gid\\.rs") | |
1248 | ((file) | |
1249 | (substitute* file | |
1250 | (("/bin/sh") (which "sh"))))) | |
1251 | #t)) | |
1252 | (replace 'patch-command-exec-tests | |
1253 | ,(patch-command-exec-tests-phase | |
1254 | '(match (find-files "src/test" "command-exec\\.rs") | |
1255 | ((file) file)))) | |
7befec25 JK |
1256 | ;; The test got removed in commit 000fe63b6fc57b09828930cacbab20c2ee6e6d15 |
1257 | ;; "Remove painful test that is not pulling its weight" | |
1258 | (delete 'remove-unsupported-tests))))))))) | |
1259 | ||
1260 | (define-public rust-1.41 | |
1261 | (let ((base-rust | |
1262 | (rust-bootstrapped-package rust-1.40 "1.41.1" | |
1263 | "0ws5x0fxv57fyllsa6025h3q6j9v3m8nb3syl4x0hgkddq0kvj9q"))) | |
1264 | (package | |
1265 | (inherit base-rust) | |
1266 | (arguments | |
1267 | (substitute-keyword-arguments (package-arguments base-rust) | |
1268 | ((#:validate-runpath? _) #t)))))) | |
1269 | ||
1270 | (define-public rust-1.42 | |
1271 | (rust-bootstrapped-package rust-1.41 "1.42.0" | |
1272 | "0x9lxs82may6c0iln0b908cxyn1cv7h03n5cmbx3j1bas4qzks6j")) | |
1273 | ||
1274 | (define-public rust-1.43 | |
1275 | (rust-bootstrapped-package rust-1.42 "1.43.0" | |
1276 | "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm")) | |
1277 | ||
1278 | (define-public rust-1.44 | |
1279 | (rust-bootstrapped-package rust-1.43 "1.44.1" | |
1280 | "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky")) | |
1281 | ||
17666c09 JK |
1282 | (define-public rust-1.45 |
1283 | (let ((base-rust | |
4ad8f5ff JK |
1284 | (rust-bootstrapped-package rust-1.44 "1.45.2" |
1285 | "0273a1g3f59plyi1n0azf21qjzwml1yqdnj5z472crz37qggr8xp"))) | |
17666c09 JK |
1286 | (package |
1287 | (inherit base-rust) | |
1288 | (source | |
1289 | (origin | |
1290 | (inherit (package-source base-rust)) | |
1291 | (patches (search-patches "rust-1.45-linker-locale.patch")))) | |
1292 | (inputs | |
1293 | (alist-replace "llvm" (list llvm-10) | |
1294 | (package-inputs base-rust))) | |
1295 | (arguments | |
1296 | (substitute-keyword-arguments (package-arguments base-rust) | |
1297 | ((#:phases phases) | |
1298 | `(modify-phases ,phases | |
1299 | ;; These tests make sure that the parser behaves properly when | |
1300 | ;; a source file starts with a shebang. Unfortunately, | |
1301 | ;; the patch-shebangs phase changes the meaning of these edge-cases. | |
1302 | ;; We skip the test since it's drastically unlikely Guix's packaging | |
1303 | ;; will introduce a bug here. | |
1304 | (add-after 'patch-tests 'skip-shebang-tests | |
1305 | (lambda _ | |
1306 | (with-directory-excursion "src/test/ui/parser/shebang" | |
1307 | (delete-file "shebang-doc-comment.rs") | |
1308 | (delete-file "sneaky-attrib.rs") | |
1309 | #t))) | |
1310 | ;; This test case synchronizes itself by starting a localhost TCP | |
1311 | ;; server. This doesn't work as networking is not available. | |
1312 | (add-after 'patch-tests 'skip-networking-test | |
1313 | (lambda _ | |
1314 | (substitute* "src/tools/cargo/tests/testsuite/freshness.rs" | |
1315 | (("fn linking_interrupted" all) | |
1316 | (string-append "#[ignore] " all))) | |
1317 | #t))))))))) | |
7befec25 | 1318 | |
83bc4164 | 1319 | (define-public rust-1.46 |
48926b58 MK |
1320 | (let ((base-rust |
1321 | (rust-bootstrapped-package rust-1.45 "1.46.0" | |
1322 | "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))) | |
1323 | (package | |
1324 | (inherit base-rust) | |
1325 | (outputs (cons "rustfmt" (package-outputs base-rust))) | |
1326 | (arguments | |
1327 | (substitute-keyword-arguments (package-arguments base-rust) | |
1328 | ((#:phases phases) | |
1329 | `(modify-phases ,phases | |
1330 | (replace 'build | |
1331 | (lambda* _ | |
1332 | (invoke "./x.py" "build") | |
1333 | (invoke "./x.py" "build" "src/tools/cargo") | |
1334 | (invoke "./x.py" "build" "src/tools/rustfmt"))) | |
1335 | (replace 'check | |
1336 | (lambda* _ | |
1337 | ;; Test rustfmt. | |
1338 | (let ((parallel-job-spec | |
1339 | (string-append "-j" (number->string | |
1340 | (min 4 | |
1341 | (parallel-job-count)))))) | |
1342 | (invoke "./x.py" parallel-job-spec "test" "-vv") | |
1343 | (invoke "./x.py" parallel-job-spec "test" | |
1344 | "src/tools/cargo") | |
1345 | (invoke "./x.py" parallel-job-spec "test" | |
1346 | "src/tools/rustfmt")))) | |
1347 | (replace 'install | |
1348 | (lambda* (#:key outputs #:allow-other-keys) | |
1349 | (invoke "./x.py" "install") | |
1350 | (substitute* "config.toml" | |
1351 | ;; replace prefix to specific output | |
1352 | (("prefix = \"[^\"]*\"") | |
1353 | (string-append "prefix = \"" (assoc-ref outputs "cargo") "\""))) | |
1354 | (invoke "./x.py" "install" "cargo") | |
1355 | (substitute* "config.toml" | |
1356 | ;; replace prefix to specific output | |
1357 | (("prefix = \"[^\"]*\"") | |
1358 | (string-append "prefix = \"" (assoc-ref outputs "rustfmt") "\""))) | |
1359 | (invoke "./x.py" "install" "rustfmt"))) | |
1360 | (replace 'delete-install-logs | |
1361 | (lambda* (#:key outputs #:allow-other-keys) | |
1362 | (define (delete-manifest-file out-path file) | |
1363 | (delete-file (string-append out-path "/lib/rustlib/" file))) | |
1364 | ||
1365 | (let ((out (assoc-ref outputs "out")) | |
1366 | (cargo-out (assoc-ref outputs "cargo")) | |
1367 | (rustfmt-out (assoc-ref outputs "rustfmt"))) | |
1368 | (for-each | |
1369 | (lambda (file) (delete-manifest-file out file)) | |
1370 | '("install.log" | |
1371 | "manifest-rust-docs" | |
1372 | ,(string-append "manifest-rust-std-" | |
1373 | (nix-system->gnu-triplet-for-rust)) | |
1374 | "manifest-rustc")) | |
1375 | (for-each | |
1376 | (lambda (file) (delete-manifest-file cargo-out file)) | |
1377 | '("install.log" | |
1378 | "manifest-cargo")) | |
1379 | (for-each | |
1380 | (lambda (file) (delete-manifest-file rustfmt-out file)) | |
1381 | '("install.log" | |
1382 | "manifest-rustfmt-preview")) | |
1383 | #t)))))))))) | |
83bc4164 | 1384 | |
7d0e111e MK |
1385 | (define-public rust-1.47 |
1386 | (let ((base-rust | |
1387 | (rust-bootstrapped-package rust-1.46 "1.47.0" | |
1388 | "07fqd2vp7cf1ka3hr207dnnz93ymxml4935vp74g4is79h3dz19i"))) | |
1389 | (package | |
1390 | (inherit base-rust) | |
1391 | (inputs | |
1392 | (alist-replace "llvm" (list llvm-11) | |
1393 | (package-inputs base-rust))) | |
1394 | (arguments | |
1395 | (substitute-keyword-arguments (package-arguments base-rust) | |
1396 | ((#:phases phases) | |
1397 | `(modify-phases ,phases | |
1398 | ;; The source code got rearranged: libstd is now in the newly created library folder. | |
1399 | (replace 'patch-tests | |
1400 | (lambda* (#:key inputs #:allow-other-keys) | |
1401 | (let ((bash (assoc-ref inputs "bash"))) | |
1402 | (substitute* "library/std/src/process.rs" | |
1403 | (("\"/bin/sh\"") (string-append "\"" bash "/bin/sh\""))) | |
1404 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html> | |
1405 | (substitute* "library/std/src/sys/unix/process/process_common.rs" | |
1406 | (("fn test_process_mask") "#[allow(unused_attributes)] | |
1407 | #[ignore] | |
1408 | fn test_process_mask")) | |
1409 | #t))) | |
1410 | (delete 'patch-cargo-checksums) | |
1411 | (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums | |
1412 | ;; Generate checksums after patching generated files (in | |
1413 | ;; particular, vendor/jemalloc/rep/Makefile). | |
1414 | (lambda* _ | |
1415 | (use-modules (guix build cargo-utils)) | |
1416 | (substitute* "Cargo.lock" | |
1417 | (("(checksum = )\".*\"" all name) | |
1418 | (string-append name "\"" ,%cargo-reference-hash "\""))) | |
1419 | (generate-all-checksums "vendor") | |
1420 | #t))))))))) | |
1421 | ||
402e697a MK |
1422 | (define-public rust-1.48 |
1423 | (let ((base-rust | |
1424 | (rust-bootstrapped-package rust-1.47 "1.48.0" | |
1425 | "0fz4gbb5hp5qalrl9lcl8yw4kk7ai7wx511jb28nypbxninkwxhf"))) | |
1426 | (package | |
1427 | (inherit base-rust) | |
1428 | (source | |
1429 | (origin | |
1430 | (inherit (package-source base-rust)) | |
1431 | ;; New patch required due to the second part of the source code rearrangement: | |
1432 | ;; the relevant source code is now in the compiler directory. | |
1433 | (patches (search-patches "rust-1.48-linker-locale.patch")))) | |
1434 | (arguments | |
1435 | (substitute-keyword-arguments (package-arguments base-rust) | |
1436 | ((#:phases phases) | |
1437 | `(modify-phases ,phases | |
1438 | ;; Some tests got split out into separate files. | |
1439 | (replace 'patch-tests | |
1440 | (lambda* (#:key inputs #:allow-other-keys) | |
1441 | (let ((bash (assoc-ref inputs "bash"))) | |
1442 | (substitute* "library/std/src/process/tests.rs" | |
1443 | (("\"/bin/sh\"") (string-append "\"" bash "/bin/sh\""))) | |
1444 | (substitute* "library/std/src/sys/unix/process/process_common/tests.rs" | |
1445 | (("fn test_process_mask") "#[allow(unused_attributes)] | |
1446 | #[ignore] | |
1447 | fn test_process_mask")) | |
1448 | #t)))))))))) | |
1449 | ||
062854de JK |
1450 | (define-public rust-1.49 |
1451 | (rust-bootstrapped-package rust-1.48 "1.49.0" | |
1452 | "0yf7kll517398dgqsr7m3gldzj0iwsp3ggzxrayckpqzvylfy2mm")) | |
1453 | ||
7befec25 | 1454 | ;; TODO(staging): Bump this variable to the latest packaged rust. |
25cdd9f7 | 1455 | (define-public rust rust-1.45) |