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