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