gnu: wine-staging: Update to 3.9.
[jackhill/guix/guix.git] / gnu / packages / rust.scm
CommitLineData
423f9e44
DC
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 David Craven <david@craven.ch>
ecee2147 3;;; Copyright © 2016 Eric Le Bihan <eric.le.bihan.dev@free.fr>
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
141and a pre-built @command{cargo} package manaer, which can
142in 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"
afc2bf53 240
8fdde581 241 ;; rustc invokes gcc, so we need to set its search paths accordingly.
afc2bf53
LC
242 ;; Note: duplicate its value here to cope with circular dependencies among
243 ;; modules (see <https://bugs.gnu.org/31392>).
244 (native-search-paths
245 (list (search-path-specification
246 (variable "C_INCLUDE_PATH")
247 (files '("include")))
248 (search-path-specification
249 (variable "CPLUS_INCLUDE_PATH")
250 (files '("include")))
251 (search-path-specification
252 (variable "LIBRARY_PATH")
253 (files '("lib" "lib64")))))
254
8fdde581
DM
255 (synopsis "Compiler for the Rust progamming language")
256 (description "Rust is a systems programming language that provides memory
257safety and thread safety guarantees.")
258 (home-page "https://www.rust-lang.org")
259 ;; Dual licensed.
260 (license (list license:asl2.0 license:expat))))
261
ca523cc5
DM
262(define (rust-bootstrapped-package base-rust version checksum)
263 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
264 (package
265 (inherit base-rust)
266 (version version)
267 (source
268 (rust-source version checksum))
269 (native-inputs
270 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
271 (alist-replace "rustc-bootstrap" (list base-rust)
272 (package-native-inputs base-rust))))))
273
a92bf11c 274(define-public mrustc
c75c9b05
DM
275 (let ((commit "b5b70897015ee70d62ddda9711c256ca7c720e0f")
276 (revision "3")
a92bf11c
DM
277 (rustc-version "1.19.0"))
278 (package
279 (name "mrustc")
280 (version (git-version "0.0.0" revision commit))
281 (source (origin
282 (method git-fetch)
283 (uri (git-reference
284 (url "https://github.com/thepowersgang/mrustc.git")
285 (commit commit)))
286 (file-name (git-file-name name version))
287 (sha256
288 (base32
c75c9b05 289 "1d6jr6agiy598ab8lax0h9dfn9n67wg906y1f46l1c27sz3w82lb"))))
a92bf11c
DM
290 (outputs '("out" "cargo"))
291 (build-system gnu-build-system)
292 (inputs
293 `(("llvm" ,llvm-3.9.1)))
294 (native-inputs
295 `(("bison" ,bison)
296 ("flex" ,flex)
297 ;; Required for the libstd sources.
298 ("rustc"
299 ,(rust-source "1.19.0" "0l8c14qsf42rmkqy92ahij4vf356dbyspxcips1aswpvad81y8qm"))))
300 (arguments
301 `(#:tests? #f
302 #:make-flags (list (string-append "LLVM_CONFIG="
303 (assoc-ref %build-inputs "llvm")
304 "/bin/llvm-config"))
305 #:phases
306 (modify-phases %standard-phases
307 (add-after 'unpack 'unpack-target-compiler
308 (lambda* (#:key inputs outputs #:allow-other-keys)
309 (substitute* "minicargo.mk"
310 ;; Don't try to build LLVM.
311 (("^[$][(]LLVM_CONFIG[)]:") "xxx:")
312 ;; Build for the correct target architecture.
313 (("^RUSTC_TARGET := x86_64-unknown-linux-gnu")
314 (string-append "RUSTC_TARGET := "
315 ,(or (%current-target-system)
316 (nix-system->gnu-triplet
317 (%current-system))))))
318 (invoke "tar" "xf" (assoc-ref inputs "rustc"))
319 (chdir "rustc-1.19.0-src")
320 (invoke "patch" "-p0" "../rust_src.patch")
321 (chdir "..")
322 #t))
39b40f16
DM
323 (replace 'configure
324 (lambda* (#:key inputs #:allow-other-keys)
325 (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
326 #t))
a92bf11c
DM
327 (add-after 'build 'build-minicargo
328 (lambda _
329 (for-each (lambda (target)
330 (invoke "make" "-f" "minicargo.mk" target))
331 '("output/libstd.hir" "output/libpanic_unwind.hir"
332 "output/libproc_macro.hir" "output/libtest.hir"))
333 ;; Technically the above already does it - but we want to be clear.
334 (invoke "make" "-C" "tools/minicargo")))
335 (replace 'install
336 (lambda* (#:key inputs outputs #:allow-other-keys)
337 (let* ((out (assoc-ref outputs "out"))
338 (bin (string-append out "/bin"))
339 (tools-bin (string-append out "/tools/bin"))
340 (cargo-out (assoc-ref outputs "cargo"))
341 (cargo-bin (string-append cargo-out "/bin"))
342 (lib (string-append out "/lib"))
343 (lib/rust (string-append lib "/mrust"))
344 (gcc (assoc-ref inputs "gcc")))
345 ;; These files are not reproducible.
346 (for-each delete-file (find-files "output" "\\.txt$"))
347 (mkdir-p lib)
348 (copy-recursively "output" lib/rust)
349 (mkdir-p bin)
350 (mkdir-p tools-bin)
351 (install-file "bin/mrustc" bin)
352 ;; minicargo uses relative paths to resolve mrustc.
353 (install-file "tools/bin/minicargo" tools-bin)
354 (install-file "tools/bin/minicargo" cargo-bin)
355 #t))))))
356 (synopsis "Compiler for the Rust progamming language")
357 (description "Rust is a systems programming language that provides memory
358safety and thread safety guarantees.")
359 (home-page "https://github.com/thepowersgang/mrustc")
360 ;; Dual licensed.
361 (license (list license:asl2.0 license:expat)))))
362
8fdde581
DM
363(define-public rust-1.23
364 (package
365 (inherit rust-1.19)
366 (name "rust")
367 (version "1.23.0")
368 (source (rust-source version "14fb8vhjzsxlbi6yrn1r6fl5dlbdd1m92dn5zj5gmzfwf4w9ar3l"))
369 (outputs '("out" "doc" "cargo"))
370 (arguments
371 (substitute-keyword-arguments (package-arguments rust-1.19)
372 ((#:phases phases)
373 `(modify-phases ,phases
67ca98ec
EF
374 (add-after 'unpack 'dont-build-native
375 (lambda _
376 ;; XXX: Revisit this when we use gcc 6.
377 (substitute* "src/binaryen/CMakeLists.txt"
378 (("ADD_COMPILE_FLAG\\(\\\"-march=native\\\"\\)") ""))
379 #t))
1bb23335
NM
380 (add-after 'patch-tests 'patch-cargo-tests
381 (lambda _
382 (substitute* "src/tools/cargo/tests/build.rs"
383 (("/usr/bin/env") (which "env"))
384 ;; Guix llvm is compiled without asmjs-unknown-emscripten.
385 (("fn wasm32_final_outputs") "#[ignore]\nfn wasm32_final_outputs"))
386 (substitute* "src/tools/cargo/tests/death.rs"
387 ;; This is stuck when built in container.
388 (("fn ctrl_c_kills_everyone") "#[ignore]\nfn ctrl_c_kills_everyone"))
389 #t))
390 (add-after 'patch-cargo-tests 'fix-mtime-bug
8fdde581
DM
391 (lambda* _
392 (substitute* "src/build_helper/lib.rs"
393 ;; Bug in Rust code.
394 ;; Current implementation assume that if dst not exist then it's mtime
395 ;; is 0, but in same time "src" have 0 mtime in guix build!
396 (("let threshold = mtime\\(dst\\);")
397 "if !dst.exists() {\nreturn false\n}\n let threshold = mtime(dst);"))
398 #t))
399 (replace 'configure
400 (lambda* (#:key inputs outputs #:allow-other-keys)
401 (let* ((out (assoc-ref outputs "out"))
402 (doc (assoc-ref outputs "doc"))
403 (gcc (assoc-ref inputs "gcc"))
404 (gdb (assoc-ref inputs "gdb"))
405 (binutils (assoc-ref inputs "binutils"))
406 (python (assoc-ref inputs "python-2"))
407 (rustc (assoc-ref inputs "rustc-bootstrap"))
408 (cargo (assoc-ref inputs "cargo-bootstrap"))
409 (llvm (assoc-ref inputs "llvm"))
410 (jemalloc (assoc-ref inputs "jemalloc")))
411 (call-with-output-file "config.toml"
412 (lambda (port)
413 (display (string-append "
d53fb678
NM
414[llvm]
415[build]
416cargo = \"" cargo "/bin/cargo" "\"
417rustc = \"" rustc "/bin/rustc" "\"
f342bb58 418docs = true
d53fb678
NM
419python = \"" python "/bin/python2" "\"
420gdb = \"" gdb "/bin/gdb" "\"
421vendor = true
422submodules = false
423[install]
424prefix = \"" out "\"
f342bb58
NM
425docdir = \"" doc "/share/doc/rust" "\"
426sysconfdir = \"etc\"
427localstatedir = \"var/lib\"
d53fb678
NM
428[rust]
429default-linker = \"" gcc "/bin/gcc" "\"
d53fb678
NM
430channel = \"stable\"
431rpath = true
432# There is 2 failed codegen tests:
433# codegen/mainsubprogram.rs and codegen/mainsubprogramstart.rs
434# This tests required patched LLVM
435codegen-tests = false
436[target." %host-type "]
437llvm-config = \"" llvm "/bin/llvm-config" "\"
438cc = \"" gcc "/bin/gcc" "\"
439cxx = \"" gcc "/bin/g++" "\"
f342bb58 440ar = \"" binutils "/bin/ar" "\"
d53fb678
NM
441jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
442[dist]
443") port)))
444 #t)))
445 (add-before 'build 'reset-timestamps-after-changes
f342bb58 446 (lambda* _
d53fb678
NM
447 (define ref (stat "README.md"))
448 (for-each
449 (lambda (filename)
450 (set-file-time filename ref))
451 (find-files "." #:directories? #t))
452 #t))
453 (replace 'build
f342bb58
NM
454 (lambda* _
455 (invoke "./x.py" "build")
456 (invoke "./x.py" "build" "src/tools/cargo")))
d53fb678 457 (replace 'check
f342bb58 458 (lambda* _
1bb23335
NM
459 (invoke "./x.py" "test")
460 (invoke "./x.py" "test" "src/tools/cargo")))
d53fb678 461 (replace 'install
f342bb58
NM
462 (lambda* (#:key outputs #:allow-other-keys)
463 (invoke "./x.py" "install")
464 (substitute* "config.toml"
465 ;; replace prefix to specific output
466 (("prefix = \"[^\"]*\"")
467 (string-append "prefix = \"" (assoc-ref outputs "cargo") "\"")))
468 (invoke "./x.py" "install" "cargo")
469 #t))
5d18d776
DC
470 (add-after 'install 'wrap-rustc
471 (lambda* (#:key inputs outputs #:allow-other-keys)
472 (let ((out (assoc-ref outputs "out"))
473 (libc (assoc-ref inputs "libc"))
474 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
475 ;; Let gcc find ld and libc startup files.
476 (wrap-program (string-append out "/bin/rustc")
477 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
326249ba 478 `("LIBRARY_PATH" ":" suffix (,(string-append libc "/lib"))))
8fdde581 479 #t)))))))))
b5a09649 480
fe61c88a 481(define-public rust-1.24
ca523cc5
DM
482 (let ((base-rust
483 (rust-bootstrapped-package rust-1.23 "1.24.1"
484 "1vv10x2h9kq7fxh2v01damdq8pvlp5acyh1kzcda9sfjx12kv99y")))
f342bb58
NM
485 (package
486 (inherit base-rust)
f342bb58
NM
487 (arguments
488 (substitute-keyword-arguments (package-arguments base-rust)
ca523cc5
DM
489 ((#:phases phases)
490 `(modify-phases ,phases
94b22905
EF
491 (replace 'patch-tests
492 (lambda* (#:key inputs #:allow-other-keys)
493 (let ((bash (assoc-ref inputs "bash")))
494 (substitute* "src/libstd/process.rs"
495 ;; The newline is intentional.
496 ;; There's a line length "tidy" check in Rust which would
497 ;; fail otherwise.
498 (("\"/bin/sh\"") (string-append "\n\"" bash "/bin/sh\"")))
499 (substitute* "src/libstd/net/tcp.rs"
500 ;; There is no network in build environment
501 (("fn connect_timeout_unroutable")
502 "#[ignore]\nfn connect_timeout_unroutable"))
503 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00222.html>
504 (substitute* "src/libstd/sys/unix/process/process_common.rs"
505 (("fn test_process_mask") "#[allow(unused_attributes)]
506 #[ignore]
507 fn test_process_mask"))
508 ;; Our ld-wrapper cannot process non-UTF8 bytes in LIBRARY_PATH.
509 ;; <https://lists.gnu.org/archive/html/guix-devel/2017-06/msg00193.html>
510 (delete-file-recursively "src/test/run-make/linker-output-non-utf8")
511 (substitute* "src/librustc_metadata/dynamic_lib.rs"
512 ;; This test is known to fail on aarch64 and powerpc64le:
513 ;; https://github.com/rust-lang/rust/issues/45410
514 (("fn test_loading_cosine") "#[ignore]\nfn test_loading_cosine"))
515 #t)))
ca523cc5 516 (delete 'fix-mtime-bug))))))))
fe61c88a
NM
517
518(define-public rust
519 (let ((base-rust rust-1.24))
520 (package
521 (inherit base-rust)
522 (version "1.25.0")
523 (source
524 (rust-source version
525 "0baxjr99311lvwdq0s38bipbnj72pn6fgbk6lcq7j555xq53mxpf"))
526 (native-inputs
527 (alist-replace "cargo-bootstrap" (list base-rust "cargo")
528 (alist-replace "rustc-bootstrap" (list base-rust)
529 (package-native-inputs base-rust))))
530 (arguments
531 (substitute-keyword-arguments (package-arguments base-rust)
532 ((#:phases phases)
533 `(modify-phases ,phases
534 (add-after 'patch-cargo-tests 'patch-cargo-index-update
535 (lambda* _
536 (substitute* "src/tools/cargo/tests/generate-lockfile.rs"
537 ;; This test wants to update the crate index.
538 (("fn no_index_update") "#[ignore]\nfn no_index_update")))))))))))