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> |
4a78fd46 | 4 | ;;; Copyright © 2016 Nils Gillmann <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> |
423f9e44 DC |
10 | ;;; |
11 | ;;; This file is part of GNU Guix. | |
12 | ;;; | |
13 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
14 | ;;; under the terms of the GNU General Public License as published by | |
15 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
16 | ;;; your option) any later version. | |
17 | ;;; | |
18 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
19 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;;; GNU General Public License for more details. | |
22 | ;;; | |
23 | ;;; You should have received a copy of the GNU General Public License | |
24 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
25 | ||
26 | (define-module (gnu packages rust) | |
27 | #:use-module (gnu packages base) | |
5f3d46ce | 28 | #:use-module (gnu packages bison) |
423f9e44 | 29 | #:use-module (gnu packages bootstrap) |
ecee2147 | 30 | #:use-module (gnu packages cmake) |
423f9e44 | 31 | #:use-module (gnu packages compression) |
b5a09649 | 32 | #:use-module (gnu packages curl) |
423f9e44 | 33 | #:use-module (gnu packages elf) |
5f3d46ce | 34 | #:use-module (gnu packages flex) |
423f9e44 | 35 | #:use-module (gnu packages gcc) |
d53fb678 | 36 | #:use-module (gnu packages gdb) |
ecee2147 | 37 | #:use-module (gnu packages jemalloc) |
5f3d46ce | 38 | #:use-module (gnu packages linux) |
ecee2147 | 39 | #:use-module (gnu packages llvm) |
b5a09649 | 40 | #:use-module (gnu packages pkg-config) |
ecee2147 | 41 | #:use-module (gnu packages python) |
b5a09649 DC |
42 | #:use-module (gnu packages ssh) |
43 | #:use-module (gnu packages tls) | |
ecee2147 | 44 | #:use-module (gnu packages version-control) |
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-project-file "/dev/null") |
59 | (define %cargo-reference-hash | |
60 | "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") | |
423f9e44 | 61 | |
f342bb58 | 62 | (define rust-bootstrap |
423f9e44 | 63 | (package |
f342bb58 NM |
64 | (name "rust-bootstrap") |
65 | (version "1.22.1") | |
66 | (source (origin | |
67 | (method url-fetch) | |
68 | (uri (string-append | |
69 | "https://static.rust-lang.org/dist/" | |
70 | "rust-" version "-" %host-type ".tar.gz")) | |
71 | (sha256 | |
72 | (base32 | |
73 | (match %host-type | |
74 | ("i686-unknown-linux-gnu" | |
75 | "15zqbx86nm13d5vq2gm69b7av4vg479f74b5by64hs3bcwwm08pr") | |
76 | ("x86_64-unknown-linux-gnu" | |
77 | "1yll78x6b3abnvgjf2b66gvp6mmcb9y9jdiqcwhmgc0z0i0fix4c") | |
78 | ("armv7-unknown-linux-gnueabihf" | |
79 | "138a8l528kzp5wyk1mgjaxs304ac5ms8vlpq0ggjaznm6bn2j7a5") | |
80 | ("aarch64-unknown-linux-gnu" | |
81 | "0z6m9m1rx4d96nvybbfmpscq4dv616m615ijy16d5wh2vx0p4na8") | |
82 | ("mips64el-unknown-linux-gnuabi64" | |
83 | "07k4pcv7jvfa48cscdj8752lby7m7xdl88v3a6na1vs675lhgja2") | |
84 | (_ "")))))) | |
423f9e44 DC |
85 | (build-system gnu-build-system) |
86 | (native-inputs | |
87 | `(("patchelf" ,patchelf))) | |
88 | (inputs | |
f342bb58 NM |
89 | `(("gcc" ,(canonical-package gcc)) |
90 | ("gcc:lib" ,(canonical-package gcc) "lib") | |
423f9e44 | 91 | ("zlib" ,zlib))) |
f342bb58 | 92 | (outputs '("out" "cargo")) |
423f9e44 DC |
93 | (arguments |
94 | `(#:tests? #f | |
95 | #:strip-binaries? #f | |
423f9e44 DC |
96 | #:phases |
97 | (modify-phases %standard-phases | |
98 | (delete 'configure) | |
99 | (delete 'build) | |
100 | (replace 'install | |
101 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
102 | (let* ((out (assoc-ref outputs "out")) | |
f342bb58 | 103 | (cargo-out (assoc-ref outputs "cargo")) |
423f9e44 DC |
104 | (gcc:lib (assoc-ref inputs "gcc:lib")) |
105 | (libc (assoc-ref inputs "libc")) | |
106 | (zlib (assoc-ref inputs "zlib")) | |
d53fb678 | 107 | (ld-so (string-append libc ,(glibc-dynamic-linker))) |
423f9e44 DC |
108 | (rpath (string-append out "/lib:" zlib "/lib:" |
109 | libc "/lib:" gcc:lib "/lib")) | |
f342bb58 NM |
110 | (cargo-rpath (string-append cargo-out "/lib:" libc "/lib:" |
111 | gcc:lib "/lib")) | |
423f9e44 | 112 | (rustc (string-append out "/bin/rustc")) |
f342bb58 NM |
113 | (rustdoc (string-append out "/bin/rustdoc")) |
114 | (cargo (string-append cargo-out "/bin/cargo")) | |
115 | (gcc (assoc-ref inputs "gcc"))) | |
116 | ;; Install rustc/rustdoc | |
117 | (invoke "bash" "install.sh" | |
423f9e44 DC |
118 | (string-append "--prefix=" out) |
119 | (string-append "--components=rustc," | |
d53fb678 | 120 | "rust-std-" %host-type)) |
f342bb58 NM |
121 | ;; Instal cargo |
122 | (invoke "bash" "install.sh" | |
123 | (string-append "--prefix=" cargo-out) | |
124 | (string-append "--components=cargo")) | |
423f9e44 | 125 | (for-each (lambda (file) |
f342bb58 | 126 | (invoke "patchelf" "--set-rpath" rpath file)) |
423f9e44 | 127 | (cons* rustc rustdoc (find-files out "\\.so$"))) |
f342bb58 | 128 | (invoke "patchelf" "--set-rpath" cargo-rpath cargo) |
423f9e44 | 129 | (for-each (lambda (file) |
f342bb58 NM |
130 | (invoke "patchelf" "--set-interpreter" ld-so file)) |
131 | (list rustc rustdoc cargo)) | |
132 | ;; Rust requires a C toolchain for linking. The prebuilt | |
133 | ;; binaries expect a compiler called cc. Thus symlink gcc | |
134 | ;; to cc. | |
135 | (symlink (string-append gcc "/bin/gcc") | |
136 | (string-append out "/bin/cc")) | |
137 | #t)))))) | |
423f9e44 | 138 | (home-page "https://www.rust-lang.org") |
f342bb58 NM |
139 | (synopsis "Prebuilt rust compiler and cargo package manager") |
140 | (description "This package provides a pre-built @command{rustc} compiler | |
141 | and a pre-built @command{cargo} package manaer, which can | |
142 | in turn be used to build the final Rust.") | |
423f9e44 DC |
143 | (license license:asl2.0))) |
144 | ||
d53fb678 | 145 | \f |
f342bb58 NM |
146 | (define (rust-source version hash) |
147 | (origin | |
148 | (method url-fetch) | |
149 | (uri (string-append "https://static.rust-lang.org/dist/" | |
150 | "rustc-" version "-src.tar.gz")) | |
151 | (sha256 (base32 hash)) | |
152 | (modules '((guix build utils))) | |
153 | (snippet '(begin (delete-file-recursively "src/llvm") #t)))) | |
154 | ||
8fdde581 | 155 | (define-public rust-1.19 |
ecee2147 | 156 | (package |
f342bb58 | 157 | (name "rust") |
8fdde581 DM |
158 | (version "1.19.0") |
159 | (source (rust-source version "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm")) | |
160 | (outputs '("out" "cargo")) | |
ecee2147 | 161 | (arguments |
d53fb678 NM |
162 | `(#:imported-modules ,%cargo-build-system-modules ;for `generate-checksums' |
163 | #:phases | |
ecee2147 | 164 | (modify-phases %standard-phases |
ecee2147 | 165 | (add-after 'unpack 'set-env |
1bb23335 NM |
166 | (lambda* (#:key inputs #:allow-other-keys) |
167 | ;; Disable test for cross compilation support. | |
168 | (setenv "CFG_DISABLE_CROSS_TESTS" "1") | |
ecee2147 | 169 | (setenv "SHELL" (which "sh")) |
326249ba | 170 | (setenv "CONFIG_SHELL" (which "sh")) |
1bb23335 | 171 | (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) |
d53fb678 NM |
172 | ;; guix llvm-3.9.1 package installs only shared libraries |
173 | (setenv "LLVM_LINK_SHARED" "1") | |
326249ba | 174 | #t)) |
84aac61c DM |
175 | (add-after 'unpack 'patch-tests |
176 | (lambda* (#:key inputs #:allow-other-keys) | |
9b7a9580 | 177 | (let ((bash (assoc-ref inputs "bash"))) |
9b7a9580 | 178 | (substitute* "src/libstd/process.rs" |
5f3d46ce DM |
179 | ;; The newline is intentional. |
180 | ;; There's a line length "tidy" check in Rust which would | |
181 | ;; fail otherwise. | |
d53fb678 NM |
182 | (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\""))) |
183 | (substitute* "src/libstd/net/tcp.rs" | |
184 | ;; There is no network in build environment | |
185 | (("fn connect_timeout_unroutable") | |
186 | "#[ignore]\nfn connect_timeout_unroutable")) | |
187 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html> | |
5f3d46ce | 188 | (substitute* "src/libstd/sys/unix/process/process_common.rs" |
237587f1 DM |
189 | (("fn test_process_mask") "#[allow(unused_attributes)] |
190 | #[ignore] | |
af4ea9c5 | 191 | fn test_process_mask")) |
5f3d46ce | 192 | ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH. |
d53fb678 | 193 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html> |
5f3d46ce | 194 | (delete-file-recursively "src/test/run-make/linker-output-non-utf8") |
94b22905 EF |
195 | (substitute* "src/librustc_back/dynamic_lib.rs" |
196 | ;; This test is known to fail on aarch64 and powerpc64le: | |
197 | ;; https://github.com/rust-lang/rust/issues/45410 | |
198 | (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine")) | |
9b7a9580 | 199 | #t))) |
d53fb678 | 200 | (add-after 'patch-source-shebangs 'patch-cargo-checksums |
f342bb58 | 201 | (lambda* _ |
d53fb678 NM |
202 | (substitute* "src/Cargo.lock" |
203 | (("(\"checksum .* = )\".*\"" all name) | |
204 | (string-append name "\"" ,%cargo-reference-hash "\""))) | |
205 | (for-each | |
206 | (lambda (filename) | |
207 | (use-modules (guix build cargo-build-system)) | |
208 | (delete-file filename) | |
209 | (let* ((dir (dirname filename))) | |
210 | (display (string-append | |
211 | "patch-cargo-checksums: generate-checksums for " | |
212 | dir "\n")) | |
213 | (generate-checksums dir ,%cargo-reference-project-file))) | |
214 | (find-files "src/vendor" ".cargo-checksum.json")) | |
215 | #t)) | |
ecee2147 | 216 | (replace 'configure |
8fdde581 DM |
217 | (const #t)) |
218 | (replace 'check | |
219 | (const #t)) | |
220 | (replace 'install | |
221 | (const #t))))) | |
222 | (build-system gnu-build-system) | |
223 | (native-inputs | |
224 | `(("bison" ,bison) ; For the tests | |
225 | ("cmake" ,cmake) | |
226 | ("flex" ,flex) ; For the tests | |
227 | ("gdb" ,gdb) ; For the tests | |
228 | ("git" ,git) | |
229 | ("procps" ,procps) ; For the tests | |
230 | ("python-2" ,python-2) | |
231 | ("rustc-bootstrap" ,rust-bootstrap) | |
232 | ("cargo-bootstrap" ,rust-bootstrap "cargo") | |
233 | ("pkg-config" ,pkg-config) ; For "cargo" | |
234 | ("which" ,which))) | |
235 | (inputs | |
236 | `(("jemalloc" ,jemalloc-4.5.0) | |
237 | ("llvm" ,llvm-3.9.1) | |
238 | ("openssl" ,openssl) | |
239 | ("libcurl" ,curl))) ; For "cargo" | |
240 | ;; rustc invokes gcc, so we need to set its search paths accordingly. | |
241 | (native-search-paths (package-native-search-paths gcc)) | |
242 | (synopsis "Compiler for the Rust progamming language") | |
243 | (description "Rust is a systems programming language that provides memory | |
244 | safety and thread safety guarantees.") | |
245 | (home-page "https://www.rust-lang.org") | |
246 | ;; Dual licensed. | |
247 | (license (list license:asl2.0 license:expat)))) | |
248 | ||
ca523cc5 DM |
249 | (define (rust-bootstrapped-package base-rust version checksum) |
250 | "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST." | |
251 | (package | |
252 | (inherit base-rust) | |
253 | (version version) | |
254 | (source | |
255 | (rust-source version checksum)) | |
256 | (native-inputs | |
257 | (alist-replace "cargo-bootstrap" (list base-rust "cargo") | |
258 | (alist-replace "rustc-bootstrap" (list base-rust) | |
259 | (package-native-inputs base-rust)))))) | |
260 | ||
a92bf11c | 261 | (define-public mrustc |
8366a67b DM |
262 | (let ((commit "4f98e4322ef7aabd3bbef8cd93c0980cd6eeeed1") |
263 | (revision "1") | |
a92bf11c DM |
264 | (rustc-version "1.19.0")) |
265 | (package | |
266 | (name "mrustc") | |
267 | (version (git-version "0.0.0" revision commit)) | |
268 | (source (origin | |
269 | (method git-fetch) | |
270 | (uri (git-reference | |
271 | (url "https://github.com/thepowersgang/mrustc.git") | |
272 | (commit commit))) | |
273 | (file-name (git-file-name name version)) | |
274 | (sha256 | |
275 | (base32 | |
8366a67b | 276 | "1hk1x2iv64il5g2n3z06d6h219hnxg1w84lj7vi1lydqa65qk92p")))) |
a92bf11c DM |
277 | (outputs '("out" "cargo")) |
278 | (build-system gnu-build-system) | |
279 | (inputs | |
280 | `(("llvm" ,llvm-3.9.1))) | |
281 | (native-inputs | |
282 | `(("bison" ,bison) | |
283 | ("flex" ,flex) | |
284 | ;; Required for the libstd sources. | |
285 | ("rustc" | |
286 | ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm")))) | |
287 | (arguments | |
288 | `(#:tests? #f | |
289 | #:make-flags (list (string-append "LLVM_CONFIG=" | |
290 | (assoc-ref %build-inputs "llvm") | |
291 | "/bin/llvm-config")) | |
292 | #:phases | |
293 | (modify-phases %standard-phases | |
294 | (add-after 'unpack 'unpack-target-compiler | |
295 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
296 | (substitute* "minicargo.mk" | |
297 | ;; Don't try to build LLVM. | |
298 | (("^[$][(]LLVM_CONFIG[)]:") "xxx:") | |
299 | ;; Build for the correct target architecture. | |
300 | (("^RUSTC_TARGET := x86_64-unknown-linux-gnu") | |
301 | (string-append "RUSTC_TARGET := " | |
302 | ,(or (%current-target-system) | |
303 | (nix-system->gnu-triplet | |
304 | (%current-system)))))) | |
305 | (invoke "tar" "xf" (assoc-ref inputs "rustc")) | |
306 | (chdir "rustc-1.19.0-src") | |
307 | (invoke "patch" "-p0" "../rust_src.patch") | |
308 | (chdir "..") | |
309 | #t)) | |
310 | (delete 'configure) | |
311 | (add-after 'build 'build-minicargo | |
312 | (lambda _ | |
313 | (for-each (lambda (target) | |
314 | (invoke "make" "-f" "minicargo.mk" target)) | |
315 | '("output/libstd.hir" "output/libpanic_unwind.hir" | |
316 | "output/libproc_macro.hir" "output/libtest.hir")) | |
317 | ;; Technically the above already does it - but we want to be clear. | |
318 | (invoke "make" "-C" "tools/minicargo"))) | |
319 | (replace 'install | |
320 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
321 | (let* ((out (assoc-ref outputs "out")) | |
322 | (bin (string-append out "/bin")) | |
323 | (tools-bin (string-append out "/tools/bin")) | |
324 | (cargo-out (assoc-ref outputs "cargo")) | |
325 | (cargo-bin (string-append cargo-out "/bin")) | |
326 | (lib (string-append out "/lib")) | |
327 | (lib/rust (string-append lib "/mrust")) | |
328 | (gcc (assoc-ref inputs "gcc"))) | |
329 | ;; These files are not reproducible. | |
330 | (for-each delete-file (find-files "output" "\\.txt$")) | |
331 | (mkdir-p lib) | |
332 | (copy-recursively "output" lib/rust) | |
333 | (mkdir-p bin) | |
334 | (mkdir-p tools-bin) | |
335 | (install-file "bin/mrustc" bin) | |
336 | ;; minicargo uses relative paths to resolve mrustc. | |
337 | (install-file "tools/bin/minicargo" tools-bin) | |
338 | (install-file "tools/bin/minicargo" cargo-bin) | |
339 | #t)))))) | |
340 | (synopsis "Compiler for the Rust progamming language") | |
341 | (description "Rust is a systems programming language that provides memory | |
342 | safety and thread safety guarantees.") | |
343 | (home-page "https://github.com/thepowersgang/mrustc") | |
344 | ;; Dual licensed. | |
345 | (license (list license:asl2.0 license:expat))))) | |
346 | ||
8fdde581 DM |
347 | (define-public rust-1.23 |
348 | (package | |
349 | (inherit rust-1.19) | |
350 | (name "rust") | |
351 | (version "1.23.0") | |
352 | (source (rust-source version "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l")) | |
353 | (outputs '("out" "doc" "cargo")) | |
354 | (arguments | |
355 | (substitute-keyword-arguments (package-arguments rust-1.19) | |
356 | ((#:phases phases) | |
357 | `(modify-phases ,phases | |
67ca98ec EF |
358 | (add-after 'unpack 'dont-build-native |
359 | (lambda _ | |
360 | ;; XXX: Revisit this when we use gcc 6. | |
361 | (substitute* "src/binaryen/CMakeLists.txt" | |
362 | (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") "")) | |
363 | #t)) | |
1bb23335 NM |
364 | (add-after 'patch-tests 'patch-cargo-tests |
365 | (lambda _ | |
366 | (substitute* "src/tools/cargo/tests/build.rs" | |
367 | (("/usr/bin/env") (which "env")) | |
368 | ;; Guix llvm is compiled without asmjs-unknown-emscripten. | |
369 | (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs")) | |
370 | (substitute* "src/tools/cargo/tests/death.rs" | |
371 | ;; This is stuck when built in container. | |
372 | (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone")) | |
373 | #t)) | |
374 | (add-after 'patch-cargo-tests 'fix-mtime-bug | |
8fdde581 DM |
375 | (lambda* _ |
376 | (substitute* "src/build_helper/lib.rs" | |
377 | ;; Bug in Rust code. | |
378 | ;; Current implementation assume that if dst not exist then it's mtime | |
379 | ;; is 0, but in same time "src" have 0 mtime in guix build! | |
380 | (("let threshold = mtime\\(dst\\);") | |
381 | "if !dst.exists() {\nreturn false\n}\n let threshold = mtime(dst);")) | |
382 | #t)) | |
383 | (replace 'configure | |
384 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
385 | (let* ((out (assoc-ref outputs "out")) | |
386 | (doc (assoc-ref outputs "doc")) | |
387 | (gcc (assoc-ref inputs "gcc")) | |
388 | (gdb (assoc-ref inputs "gdb")) | |
389 | (binutils (assoc-ref inputs "binutils")) | |
390 | (python (assoc-ref inputs "python-2")) | |
391 | (rustc (assoc-ref inputs "rustc-bootstrap")) | |
392 | (cargo (assoc-ref inputs "cargo-bootstrap")) | |
393 | (llvm (assoc-ref inputs "llvm")) | |
394 | (jemalloc (assoc-ref inputs "jemalloc"))) | |
395 | (call-with-output-file "config.toml" | |
396 | (lambda (port) | |
397 | (display (string-append " | |
d53fb678 NM |
398 | [llvm] |
399 | [build] | |
400 | cargo = \"" cargo "/bin/cargo" "\" | |
401 | rustc = \"" rustc "/bin/rustc" "\" | |
f342bb58 | 402 | docs = true |
d53fb678 NM |
403 | python = \"" python "/bin/python2" "\" |
404 | gdb = \"" gdb "/bin/gdb" "\" | |
405 | vendor = true | |
406 | submodules = false | |
407 | [install] | |
408 | prefix = \"" out "\" | |
f342bb58 NM |
409 | docdir = \"" doc "/share/doc/rust" "\" |
410 | sysconfdir = \"etc\" | |
411 | localstatedir = \"var/lib\" | |
d53fb678 NM |
412 | [rust] |
413 | default-linker = \"" gcc "/bin/gcc" "\" | |
d53fb678 NM |
414 | channel = \"stable\" |
415 | rpath = true | |
416 | # There is 2 failed codegen tests: | |
417 | # codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs | |
418 | # This tests required patched LLVM | |
419 | codegen-tests = false | |
420 | [target." %host-type "] | |
421 | llvm-config = \"" llvm "/bin/llvm-config" "\" | |
422 | cc = \"" gcc "/bin/gcc" "\" | |
423 | cxx = \"" gcc "/bin/g++" "\" | |
f342bb58 | 424 | ar = \"" binutils "/bin/ar" "\" |
d53fb678 NM |
425 | jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\" |
426 | [dist] | |
427 | ") port))) | |
428 | #t))) | |
429 | (add-before 'build 'reset-timestamps-after-changes | |
f342bb58 | 430 | (lambda* _ |
d53fb678 NM |
431 | (define ref (stat "README.md")) |
432 | (for-each | |
433 | (lambda (filename) | |
434 | (set-file-time filename ref)) | |
435 | (find-files "." #:directories? #t)) | |
436 | #t)) | |
437 | (replace 'build | |
f342bb58 NM |
438 | (lambda* _ |
439 | (invoke "./x.py" "build") | |
440 | (invoke "./x.py" "build" "src/tools/cargo"))) | |
d53fb678 | 441 | (replace 'check |
f342bb58 | 442 | (lambda* _ |
1bb23335 NM |
443 | (invoke "./x.py" "test") |
444 | (invoke "./x.py" "test" "src/tools/cargo"))) | |
d53fb678 | 445 | (replace 'install |
f342bb58 NM |
446 | (lambda* (#:key outputs #:allow-other-keys) |
447 | (invoke "./x.py" "install") | |
448 | (substitute* "config.toml" | |
449 | ;; replace prefix to specific output | |
450 | (("prefix = \"[^\"]*\"") | |
451 | (string-append "prefix = \"" (assoc-ref outputs "cargo") "\""))) | |
452 | (invoke "./x.py" "install" "cargo") | |
453 | #t)) | |
5d18d776 DC |
454 | (add-after 'install 'wrap-rustc |
455 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
456 | (let ((out (assoc-ref outputs "out")) | |
457 | (libc (assoc-ref inputs "libc")) | |
458 | (ld-wrapper (assoc-ref inputs "ld-wrapper"))) | |
459 | ;; Let gcc find ld and libc startup files. | |
460 | (wrap-program (string-append out "/bin/rustc") | |
461 | `("PATH" ":" prefix (,(string-append ld-wrapper "/bin"))) | |
326249ba | 462 | `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib")))) |
8fdde581 | 463 | #t))))))))) |
b5a09649 | 464 | |
fe61c88a | 465 | (define-public rust-1.24 |
ca523cc5 DM |
466 | (let ((base-rust |
467 | (rust-bootstrapped-package rust-1.23 "1.24.1" | |
468 | "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y"))) | |
f342bb58 NM |
469 | (package |
470 | (inherit base-rust) | |
f342bb58 NM |
471 | (arguments |
472 | (substitute-keyword-arguments (package-arguments base-rust) | |
ca523cc5 DM |
473 | ((#:phases phases) |
474 | `(modify-phases ,phases | |
94b22905 EF |
475 | (replace 'patch-tests |
476 | (lambda* (#:key inputs #:allow-other-keys) | |
477 | (let ((bash (assoc-ref inputs "bash"))) | |
478 | (substitute* "src/libstd/process.rs" | |
479 | ;; The newline is intentional. | |
480 | ;; There's a line length "tidy" check in Rust which would | |
481 | ;; fail otherwise. | |
482 | (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\""))) | |
483 | (substitute* "src/libstd/net/tcp.rs" | |
484 | ;; There is no network in build environment | |
485 | (("fn connect_timeout_unroutable") | |
486 | "#[ignore]\nfn connect_timeout_unroutable")) | |
487 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html> | |
488 | (substitute* "src/libstd/sys/unix/process/process_common.rs" | |
489 | (("fn test_process_mask") "#[allow(unused_attributes)] | |
490 | #[ignore] | |
491 | fn test_process_mask")) | |
492 | ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH. | |
493 | ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html> | |
494 | (delete-file-recursively "src/test/run-make/linker-output-non-utf8") | |
495 | (substitute* "src/librustc_metadata/dynamic_lib.rs" | |
496 | ;; This test is known to fail on aarch64 and powerpc64le: | |
497 | ;; https://github.com/rust-lang/rust/issues/45410 | |
498 | (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine")) | |
499 | #t))) | |
ca523cc5 | 500 | (delete 'fix-mtime-bug)))))))) |
fe61c88a NM |
501 | |
502 | (define-public rust | |
503 | (let ((base-rust rust-1.24)) | |
504 | (package | |
505 | (inherit base-rust) | |
506 | (version "1.25.0") | |
507 | (source | |
508 | (rust-source version | |
509 | "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf")) | |
510 | (native-inputs | |
511 | (alist-replace "cargo-bootstrap" (list base-rust "cargo") | |
512 | (alist-replace "rustc-bootstrap" (list base-rust) | |
513 | (package-native-inputs base-rust)))) | |
514 | (arguments | |
515 | (substitute-keyword-arguments (package-arguments base-rust) | |
516 | ((#:phases phases) | |
517 | `(modify-phases ,phases | |
518 | (add-after 'patch-cargo-tests 'patch-cargo-index-update | |
519 | (lambda* _ | |
520 | (substitute* "src/tools/cargo/tests/generate-lockfile.rs" | |
521 | ;; This test wants to update the crate index. | |
522 | (("fn no_index_update") "#[ignore]\nfn no_index_update"))))))))))) |