projects/guix·blob python-team · refs

2581 lines · 121.2 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2016 David Craven <[email protected]>
3;;; Copyright © 2016 Eric Le Bihan <[email protected]>
4;;; Copyright © 2016 Nikita <[email protected]>
5;;; Copyright © 2017 Ben Woodcroft <[email protected]>
6;;; Copyright © 2017, 2018 Nikolai Merinov <[email protected]>
7;;; Copyright © 2017, 2019-2026 Efraim Flashner <[email protected]>
8;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <[email protected]>
9;;; Copyright © 2018 Danny Milosavljevic <[email protected]>
10;;; Copyright © 2019 Ivan Petkov <[email protected]>
11;;; Copyright © 2020, 2021 Jakub Kądziołka <[email protected]>
12;;; Copyright © 2020 Pierre Langlois <[email protected]>
13;;; Copyright © 2020 Matthew James Kraai <[email protected]>
14;;; Copyright © 2021, 2025 Maxim Cournoyer <[email protected]>
15;;; Copyright © 2021 (unmatched parenthesis <[email protected]>
16;;; Copyright © 2022 Zheng Junjie <[email protected]>
17;;; Copyright © 2022 Jim Newsome <[email protected]>
18;;; Copyright © 2022 Mark H Weaver <[email protected]>
19;;; Copyright © 2023 Fries <[email protected]>
20;;; Copyright © 2023 Herman Rimm <[email protected]>
21;;; Copyright © 2026 Untrusem <[email protected]>
22;;;
23;;; This file is part of GNU Guix.
24;;;
25;;; GNU Guix is free software; you can redistribute it and/or modify it
26;;; under the terms of the GNU General Public License as published by
27;;; the Free Software Foundation; either version 3 of the License, or (at
28;;; your option) any later version.
29;;;
30;;; GNU Guix is distributed in the hope that it will be useful, but
31;;; WITHOUT ANY WARRANTY; without even the implied warranty of
32;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33;;; GNU General Public License for more details.
34;;;
35;;; You should have received a copy of the GNU General Public License
36;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
37
38(define-module (gnu packages rust)
39 #:use-module (gnu packages base)
40 #:use-module (gnu packages bash)
41 #:use-module (gnu packages bison)
42 #:use-module (gnu packages bootstrap)
43 #:use-module (gnu packages cmake)
44 #:use-module (gnu packages compression)
45 #:use-module (gnu packages cross-base)
46 #:use-module (gnu packages curl)
47 #:use-module (gnu packages elf)
48 #:use-module (gnu packages compiler-tools)
49 #:use-module (gnu packages gcc)
50 #:use-module (gnu packages gdb)
51 #:use-module (gnu packages libffi)
52 #:use-module (gnu packages linux)
53 #:use-module (gnu packages llvm)
54 #:use-module (gnu packages llvm-meta)
55 #:use-module (gnu packages mingw)
56 #:use-module (gnu packages pkg-config)
57 #:use-module (gnu packages python)
58 #:use-module (gnu packages python-build)
59 #:use-module (gnu packages ssh)
60 #:use-module (gnu packages tls)
61 #:use-module (gnu packages version-control)
62 #:use-module (gnu packages web)
63 #:use-module (gnu packages)
64 #:use-module (guix build-system cargo)
65 #:use-module (guix build-system gnu)
66 #:use-module (guix build-system trivial)
67 #:use-module (guix search-paths)
68 #:use-module (guix download)
69 #:use-module (guix memoization)
70 #:use-module (guix git-download)
71 #:use-module ((guix licenses) #:prefix license:)
72 #:use-module (guix packages)
73 #:use-module (guix platform)
74 #:use-module ((guix build utils) #:select (alist-replace))
75 #:use-module (guix utils)
76 #:use-module (guix gexp)
77 #:use-module (ice-9 match)
78 #:use-module (ice-9 optargs)
79 #:use-module (srfi srfi-1)
80 #:use-module (srfi srfi-26)
81 #:use-module (srfi srfi-34)
82 #:use-module (srfi srfi-35))
83
84;; This is the hash for the empty file, and the reason it's relevant is not
85;; the most obvious.
86;;
87;; The root of the problem is that Cargo keeps track of a file called
88;; Cargo.lock, that contains the hash of the tarball source of each dependency.
89;;
90;; However, tarball sources aren't handled well by Guix because of the need to
91;; patch shebangs in any helper scripts. This is why we use Cargo's vendoring
92;; capabilities, where instead of the tarball, a directory is provided in its
93;; place. (In the case of rustc, the source code already ships with vendored
94;; dependencies, but crates built with cargo-build-system undergo vendoring
95;; during the build.)
96;;
97;; To preserve the advantages of checksumming, vendored dependencies contain
98;; a file called .cargo-checksum.json, which contains the hash of the tarball,
99;; as well as the list of files in it, with the hash of each file.
100;;
101;; The patch-cargo-checksums phase of cargo-build-system runs after
102;; any Guix-specific patches to the vendored dependencies and regenerates the
103;; .cargo-checksum.json files, but it's hard to know the tarball checksum that
104;; should be written to the file - and taking care of any unhandled edge case
105;; would require rebuilding everything that depends on rust. This is why we lie,
106;; and say that the tarball has the hash of an empty file. It's not a problem
107;; because cargo-build-system removes the Cargo.lock file. We can't do that
108;; for rustc because of a quirk of its build system, so we modify the lock file
109;; to substitute the hash.
110(define %cargo-reference-hash
111 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
112
113(define* (rust-uri version #:key (dist "static"))
114 (string-append "https://" dist ".rust-lang.org/dist/"
115 "rustc-" version "-src.tar.gz"))
116
117(define* (rust-bootstrapped-package base-rust version checksum)
118 "Bootstrap rust VERSION with source checksum CHECKSUM using BASE-RUST."
119 (package
120 (inherit base-rust)
121 (version version)
122 (source
123 (origin
124 (inherit (package-source base-rust))
125 (uri (rust-uri version))
126 (sha256 (base32 checksum))))
127 (arguments
128 (substitute-keyword-arguments (package-arguments base-rust)
129 ((#:disallowed-references _ '())
130 (list (this-package-native-input "rustc-bootstrap")))))
131 (native-inputs
132 (modify-inputs native-inputs
133 (replace "rustc-bootstrap" base-rust)
134 (replace "cargo-bootstrap" (list base-rust "cargo"))))))
135
136;;; Note: mrustc's only purpose is to be able to bootstrap Rust; it's designed
137;;; to be used in source form.
138(define %mrustc-commit "06b87d1af49d2db3bd850fdee8888055dd540dd1")
139(define %mrustc-source
140 (let* ((version "0.11.2")
141 (commit %mrustc-commit)
142 (revision "1")
143 (name "mrustc"))
144 (origin
145 (method git-fetch)
146 (uri (git-reference
147 (url "https://github.com/thepowersgang/mrustc")
148 (commit %mrustc-commit)))
149 (file-name (git-file-name name (git-version version revision commit)))
150 (sha256
151 (base32 "1m6ya3d653b5z0ygvr4y8hay1445gww9s8vyk8h0jdi42zkhzqkf"))
152 (patches (search-patches "mrustc-patches.patch"))
153 (modules '((guix build utils)))
154 (snippet
155 '(begin
156 ;; Drastically reduces memory and build time requirements
157 ;; by disabling debug by default.
158 (substitute* (find-files "." "Makefile")
159 (("LINKFLAGS := -g") "LINKFLAGS :=")
160 (("-g ") ""))
161 (substitute* "minicargo.mk"
162 ;; Don't assume tarball with gzip compression.
163 (("-xzf") "-xf")
164 ;; Don't use the vendored openssl sources.
165 (("--features vendored-openssl") "")))))))
166
167;;; The rust-bootstrap packages are special in that they are built with mrustc,
168;;; which shortens the bootstrap path.
169(define-public rust-bootstrap-1.54
170 (package
171 (name "rust")
172 (version "1.54.0")
173 (source
174 (origin
175 (method url-fetch)
176 (uri (rust-uri version))
177 (sha256 (base32 "0xk9dhfff16caambmwij67zgshd8v9djw6ha0fnnanlv7rii31dc"))
178 (modules '((guix build utils)))
179 (snippet
180 '(begin
181 (for-each delete-file-recursively
182 '("src/llvm-project"
183 "vendor/openssl-src/openssl"
184 "vendor/tikv-jemalloc-sys/jemalloc"))
185 ;; Remove vendored dynamically linked libraries.
186 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
187 (delete-file "vendor/vte/vim10m_match")
188 (delete-file "vendor/vte/vim10m_table")
189 ;; Also remove the bundled (mostly Windows) libraries.
190 ;; find vendor -not -type d -exec file {} \+ | grep PE32
191 (for-each delete-file
192 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
193 ;; Adjust some sources for llvm-13, see llvm commit
194 ;; acce401068e78a8c5dc9e06802111ffad3da763f
195 (substitute* (find-files "." "powerpc64le_unknown_linux_gnu.rs")
196 (("e-m:e-i64:64-n32:64-v256:256:256-v512:512:512")
197 "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512"))))))
198 (outputs '("out" "cargo"))
199 (properties '((hidden? . #t)
200 (timeout . 129600) ;36 hours
201 (max-silent-time . 18000))) ;5 hours (for armel)
202 (build-system gnu-build-system)
203 (inputs
204 (list bash-minimal
205 llvm-13
206 openssl-1.1
207 zlib))
208 (native-inputs
209 `(("pkg-config" ,pkg-config)
210 ("mrustc-source" ,%mrustc-source)))
211 (arguments
212 `(#:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
213 #:modules ((guix build cargo-utils)
214 (guix build utils)
215 (guix build gnu-build-system))
216 #:test-target "test"
217 ;; Rust's own .so library files are not found in any RUNPATH, but
218 ;; that doesn't seem to cause issues.
219 #:validate-runpath? #f
220 #:make-flags
221 ,#~(let ((source #$(package-source this-package)))
222 (list (string-append "RUSTC_TARGET="
223 #$(platform-rust-target
224 (lookup-platform-by-target-or-system
225 (or (%current-target-system)
226 (%current-system)))))
227 (string-append "RUSTC_VERSION=" #$version)
228 (string-append "MRUSTC_TARGET_VER="
229 #$(version-major+minor version))
230 (string-append "RUSTC_SRC_TARBALL=" source)
231 "OUTDIR_SUF=")) ;do not add version suffix to output dir
232 #:phases
233 (modify-phases %standard-phases
234 (replace 'unpack
235 (lambda* (#:key source inputs #:allow-other-keys)
236 ((assoc-ref %standard-phases 'unpack)
237 #:source (assoc-ref inputs "mrustc-source"))))
238 (add-after 'unpack 'patch-makefiles
239 ;; This disables building the (unbundled) LLVM.
240 (lambda* (#:key inputs #:allow-other-keys)
241 (substitute* '("minicargo.mk"
242 "run_rustc/Makefile")
243 ;; Use the system-provided LLVM.
244 (("LLVM_CONFIG [:|?]= .*")
245 (string-append "LLVM_CONFIG := "
246 (search-input-file inputs "/bin/llvm-config") "\n")))
247 (substitute* "Makefile"
248 ;; Patch date and git obtained version information.
249 ((" -D VERSION_GIT_FULLHASH=.*")
250 (string-append
251 " -D VERSION_GIT_FULLHASH=\\\"" ,%mrustc-commit "\\\""
252 " -D VERSION_GIT_BRANCH=\\\"master\\\""
253 " -D VERSION_GIT_SHORTHASH=\\\""
254 ,(string-take %mrustc-commit 7) "\\\""
255 " -D VERSION_BUILDTIME="
256 "\"\\\"Thu, 01 Jan 1970 00:00:01 +0000\\\"\""
257 " -D VERSION_GIT_ISDIRTY=0\n")))
258 (substitute* '("run_rustc/Makefile"
259 "run_rustc/rustc_proxy.sh")
260 ;; Patch the shebang of a generated wrapper for rustc
261 (("#!/bin/sh")
262 (string-append "#!" (which "sh"))))))
263 (add-before 'configure 'configure-cargo-home
264 (lambda _
265 (let ((cargo-home (string-append (getcwd) "/.cargo")))
266 (mkdir-p cargo-home)
267 (setenv "CARGO_HOME" cargo-home))))
268 (replace 'configure
269 (lambda _
270 (setenv "CC" "gcc")
271 (setenv "CXX" "g++")
272 ;; The Guix LLVM package installs only shared libraries.
273 (setenv "LLVM_LINK_SHARED" "1")
274 ;; rustc still insists on having 'cc' on PATH in some places
275 ;; (e.g. when building the 'test' library crate).
276 (mkdir-p "/tmp/bin")
277 (symlink (which "gcc") "/tmp/bin/cc")
278 (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
279 (delete 'patch-generated-file-shebangs)
280 (replace 'build
281 (lambda* (#:key make-flags parallel-build? #:allow-other-keys)
282 (let ((job-count (if parallel-build?
283 (parallel-job-count)
284 1)))
285 ;; Adapted from:
286 ;; https://github.com/dtolnay/bootstrap/blob/master/build-1.54.0.sh.
287 ;; Use PARLEVEL since both minicargo and mrustc use it
288 ;; to set the level of parallelism.
289 (setenv "PARLEVEL" (number->string job-count))
290 (display "Building mrustc...\n")
291 (apply invoke "make" make-flags)
292
293 ;; This doesn't seem to build anything, but it
294 ;; sets additional minicargo flags.
295 (display "Building RUSTCSRC...\n")
296 (apply invoke "make" "RUSTCSRC" make-flags)
297
298 ;; This probably doesn't need to be called explicitly.
299 (display "Building LIBS...\n")
300 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags)
301
302 ;; The psm crate FTBFS on ppc64le with gcc.
303 (display "Building rustc...\n")
304 (apply invoke "make" "-f" "minicargo.mk" "output/rustc"
305 make-flags)
306
307 (display "Building cargo...\n")
308 (apply invoke "make" "-f" "minicargo.mk" "output/cargo"
309 make-flags)
310
311 ;; This one isn't listed in the build script.
312 (display "Rebuilding stdlib with rustc...\n")
313 (apply invoke "make" "-C" "run_rustc" make-flags))))
314 (replace 'install
315 (lambda* (#:key inputs outputs #:allow-other-keys)
316 (let* ((out (assoc-ref outputs "out"))
317 (cargo (assoc-ref outputs "cargo"))
318 (bin (string-append out "/bin"))
319 (rustc (string-append bin "/rustc"))
320 (cargo-bin (string-append cargo "/bin"))
321 (lib (string-append out "/lib"))
322 (system-lib-prefix
323 (string-append lib "/rustlib/"
324 ,(platform-rust-target
325 (lookup-platform-by-target-or-system
326 (or (%current-target-system)
327 (%current-system)))) "/lib")))
328 (with-directory-excursion "run_rustc/output/prefix"
329 (mkdir-p (dirname rustc))
330 (copy-file "bin/rustc_binary" rustc)
331
332 (wrap-program rustc
333 `("LD_LIBRARY_PATH" = (,system-lib-prefix)))
334 (mkdir-p lib)
335 (copy-recursively "lib" lib)
336 (install-file "bin/cargo" cargo-bin))))))))
337 (synopsis "Compiler for the Rust programming language")
338 (description "Rust is a systems programming language that provides memory
339safety and thread safety guarantees.")
340 (home-page "https://github.com/thepowersgang/mrustc")
341
342 ;; The intermediate generated code is known to be inefficient and
343 ;; therefore the build process needs 8GB of RAM while building.
344 ;; It may support i686 soon:
345 ;; <https://github.com/thepowersgang/mrustc/issues/78>.
346 ;; List of systems where rust-bootstrap is explicitly known to build:
347 (supported-systems '("x86_64-linux" "aarch64-linux"
348 "riscv64-linux" "powerpc64le-linux"))
349
350 ;; Dual licensed.
351 (license (list license:asl2.0 license:expat))))
352
353(define-public rust-bootstrap-1.74
354 (package
355 (name "rust")
356 (version "1.74.0")
357 (source
358 (origin
359 (method url-fetch)
360 (uri (rust-uri version))
361 (sha256 (base32 "0j8hrwjjjjf7spy0hy7gami96swhfzr6kandfzzdri91qd5mhaw8"))
362 (modules '((guix build utils)))
363 (snippet
364 '(begin
365 (for-each delete-file-recursively
366 '("src/llvm-project"
367 "vendor/openssl-src/openssl"
368 "vendor/tikv-jemalloc-sys/jemalloc"))
369 ;; Remove vendored dynamically linked libraries.
370 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
371 ;; Also remove the bundled (mostly Windows) libraries.
372 (for-each delete-file
373 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
374 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
375 (substitute* "vendor/tempfile/Cargo.toml"
376 (("features = \\[\"fs\"" all)
377 (string-append all ", \"use-libc\"")))))
378 ;; Rust 1.70 adds the rustix library which depends on the vendored
379 ;; fd-lock crate. The fd-lock crate uses Outline assembly which expects
380 ;; a precompiled static library. Enabling the "cc" feature tells the
381 ;; build.rs script to compile the assembly files instead of searching
382 ;; for a precompiled library.
383 (patches (search-patches "rust-1.70-fix-rustix-build.patch"))))
384 (outputs '("out" "cargo"))
385 (properties '((hidden? . #t)
386 (timeout . 129600) ;36 hours
387 (max-silent-time . 18000))) ;5 hours (for riscv64)
388 (build-system gnu-build-system)
389 (inputs
390 (list bash-minimal
391 llvm-17
392 openssl
393 zlib))
394 (native-inputs
395 (list pkg-config %mrustc-source))
396 (arguments
397 (list
398 #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
399 #:modules '((guix build cargo-utils)
400 (guix build utils)
401 (guix build gnu-build-system))
402 #:test-target "test"
403 ;; Rust's own .so library files are not found in any RUNPATH, but
404 ;; that doesn't seem to cause issues.
405 #:validate-runpath? #f
406 #:make-flags
407 #~(let ((source #$(package-source this-package)))
408 (list (string-append "RUSTC_TARGET="
409 #$(platform-rust-target
410 (lookup-platform-by-target-or-system
411 (or (%current-target-system)
412 (%current-system)))))
413 (string-append "RUSTC_VERSION=" #$version)
414 (string-append "MRUSTC_TARGET_VER="
415 #$(version-major+minor version))
416 (string-append "RUSTC_SRC_TARBALL=" source)
417 "OUTDIR_SUF=")) ;do not add version suffix to output dir
418 #:phases
419 #~(modify-phases %standard-phases
420 (replace 'unpack
421 (lambda* (#:key source inputs #:allow-other-keys)
422 ((assoc-ref %standard-phases 'unpack)
423 #:source #$(this-package-native-input
424 (origin-file-name %mrustc-source)))))
425 (add-after 'unpack 'patch-makefiles
426 ;; This disables building the (unbundled) LLVM.
427 (lambda* (#:key inputs #:allow-other-keys)
428 (substitute* '("minicargo.mk"
429 "run_rustc/Makefile")
430 ;; Use the system-provided LLVM.
431 (("LLVM_CONFIG [:|?]= .*")
432 (string-append "LLVM_CONFIG := "
433 (search-input-file inputs "/bin/llvm-config") "\n")))
434 (substitute* "Makefile"
435 ;; Patch date and git obtained version information.
436 ((" -D VERSION_GIT_FULLHASH=.*")
437 (string-append
438 " -D VERSION_GIT_FULLHASH=\\\"" #$%mrustc-commit "\\\""
439 " -D VERSION_GIT_BRANCH=\\\"master\\\""
440 " -D VERSION_GIT_SHORTHASH=\\\""
441 #$(string-take %mrustc-commit 7) "\\\""
442 " -D VERSION_BUILDTIME="
443 "\"\\\"Thu, 01 Jan 1970 00:00:01 +0000\\\"\""
444 " -D VERSION_GIT_ISDIRTY=0\n")))
445 (substitute* '("run_rustc/Makefile"
446 "run_rustc/rustc_proxy.sh")
447 ;; Patch the shebang of a generated wrapper for rustc
448 (("#!/bin/sh")
449 (string-append "#!" (which "sh"))))))
450 (add-before 'configure 'configure-cargo-home
451 (lambda _
452 (let ((cargo-home (string-append (getcwd) "/.cargo")))
453 (mkdir-p cargo-home)
454 (setenv "CARGO_HOME" cargo-home))))
455 (replace 'configure
456 (lambda _
457 (setenv "CC" "gcc")
458 (setenv "CXX" "g++")
459 ;; The Guix LLVM package installs only shared libraries.
460 (setenv "LLVM_LINK_SHARED" "1")
461 ;; rustc still insists on having 'cc' on PATH in some places
462 ;; (e.g. when building the 'test' library crate).
463 (mkdir-p "/tmp/bin")
464 (symlink (which "gcc") "/tmp/bin/cc")
465 (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
466 (delete 'patch-generated-file-shebangs)
467 (replace 'build
468 (lambda* (#:key make-flags parallel-build? #:allow-other-keys)
469 (let ((job-count (if parallel-build?
470 (parallel-job-count)
471 1)))
472 ;; Adapted from:
473 ;; https://github.com/dtolnay/bootstrap/blob/master/build-1.54.0.sh.
474 ;; Use PARLEVEL since both minicargo and mrustc use it
475 ;; to set the level of parallelism.
476 (setenv "PARLEVEL" (number->string job-count))
477 (display "Building mrustc...\n")
478 (apply invoke "make" make-flags)
479
480 ;; This doesn't seem to build anything, but it
481 ;; sets additional minicargo flags.
482 (display "Building RUSTCSRC...\n")
483 (apply invoke "make" "RUSTCSRC" make-flags)
484
485 ;; This probably doesn't need to be called explicitly.
486 (display "Building LIBS...\n")
487 (apply invoke "make" "-f" "minicargo.mk" "LIBS" make-flags)
488
489 (display "Building rustc...\n")
490 (apply invoke "make" "-f" "minicargo.mk" "output/rustc"
491 make-flags)
492
493 (display "Building cargo...\n")
494 (apply invoke "make" "-f" "minicargo.mk" "output/cargo"
495 make-flags)
496
497 ;; This one isn't listed in the build script.
498 (display "Rebuilding stdlib with rustc...\n")
499 (apply invoke "make" "-C" "run_rustc" make-flags))))
500 (replace 'install
501 (lambda* (#:key inputs outputs #:allow-other-keys)
502 (let* ((out (assoc-ref outputs "out"))
503 (cargo (assoc-ref outputs "cargo"))
504 (bin (string-append out "/bin"))
505 (rustc (string-append bin "/rustc"))
506 (cargo-bin (string-append cargo "/bin"))
507 (lib (string-append out "/lib"))
508 (system-lib-prefix
509 (string-append lib "/rustlib/"
510 #$(platform-rust-target
511 (lookup-platform-by-target-or-system
512 (or (%current-target-system)
513 (%current-system)))) "/lib")))
514 (with-directory-excursion "run_rustc/output/prefix"
515 ;; The .rmeta files of the bootstrap compiler are not meant
516 ;; to be installed.
517 (for-each delete-file (find-files "." "\\.rmeta$"))
518
519 (mkdir-p (dirname rustc))
520 (copy-file "bin/rustc_binary" rustc)
521
522 (wrap-program rustc
523 `("LD_LIBRARY_PATH" = (,system-lib-prefix)))
524 (mkdir-p lib)
525 (copy-recursively "lib" lib)
526 (install-file "bin/cargo" cargo-bin))))))))
527 (synopsis "Compiler for the Rust programming language")
528 (description "Rust is a systems programming language that provides memory
529safety and thread safety guarantees.")
530 (home-page "https://github.com/thepowersgang/mrustc")
531
532 ;; List of systems where rust-bootstrap is explicitly known to build:
533 (supported-systems '("x86_64-linux"))
534
535 ;; Dual licensed.
536 (license (list license:asl2.0 license:expat))))
537
538(define-public rust-1.55
539 (package
540 (name "rust")
541 (version "1.55.0")
542 (source
543 (origin
544 (method url-fetch)
545 (uri (rust-uri version))
546 (sha256 (base32 "07l28f7grdmi65naq71pbmvdd61hwcpi40ry7kp7dy7m233rldxj"))
547 (modules '((guix build utils)))
548 (snippet
549 '(begin
550 (for-each delete-file-recursively
551 '("src/llvm-project"
552 "vendor/openssl-src/openssl"
553 "vendor/tikv-jemalloc-sys/jemalloc"))
554 ;; Remove vendored dynamically linked libraries.
555 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
556 (delete-file "vendor/vte/vim10m_match")
557 (delete-file "vendor/vte/vim10m_table")
558 ;; Also remove the bundled (mostly Windows) libraries.
559 ;; find vendor -not -type d -exec file {} \+ | grep PE32
560 (for-each delete-file
561 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
562 ;; Add support for riscv64-linux.
563 (substitute* "vendor/tikv-jemallocator/src/lib.rs"
564 ((" target_arch = \"s390x\"," all)
565 (string-append all "\n target_arch = \"riscv64\",")))))))
566 (outputs '("out" "cargo"))
567 (properties '((hidden? . #t)
568 (timeout . 72000) ;20 hours
569 (max-silent-time . 18000))) ;5 hours (for armel)
570 (build-system gnu-build-system)
571 (arguments
572 `(#:validate-runpath? #f
573 ;; Only the final Rust is tested, not the intermediate bootstrap ones,
574 ;; for performance and simplicity.
575 #:tests? #f
576 #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
577 #:modules ((guix build cargo-utils)
578 (guix build utils)
579 (guix build gnu-build-system)
580 (ice-9 match)
581 (srfi srfi-1))
582 #:phases
583 (modify-phases %standard-phases
584 (add-after 'unpack 'set-env
585 (lambda* (#:key inputs #:allow-other-keys)
586 (setenv "SHELL" (which "sh"))
587 (setenv "CONFIG_SHELL" (which "sh"))
588 (setenv "CC" (search-input-file inputs "/bin/gcc"))
589 ;; The Guix LLVM package installs only shared libraries.
590 (setenv "LLVM_LINK_SHARED" "1")))
591 (add-after 'unpack 'set-linker-locale-to-utf8
592 (lambda _
593 (substitute* (find-files "." "^linker.rs$")
594 (("linker.env\\(\"LC_ALL\", \"C\"\\);")
595 "linker.env(\"LC_ALL\", \"C.UTF-8\");"))))
596 (add-after 'unpack 'add-cc-shim-to-path
597 (lambda _
598 (mkdir-p "/tmp/bin")
599 (symlink (which "gcc") "/tmp/bin/cc")
600 (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
601 (replace 'configure
602 (lambda* (#:key inputs outputs #:allow-other-keys)
603 (let* ((out (assoc-ref outputs "out"))
604 (gcc (assoc-ref inputs "gcc"))
605 (python (assoc-ref inputs "python"))
606 (binutils (assoc-ref inputs "binutils"))
607 (rustc (assoc-ref inputs "rustc-bootstrap"))
608 (cargo (assoc-ref inputs "cargo-bootstrap"))
609 (llvm (assoc-ref inputs "llvm")))
610 (call-with-output-file "config.toml"
611 (lambda (port)
612 (display (string-append "
613[llvm]
614[build]
615cargo = \"" cargo "/bin/cargo" "\"
616rustc = \"" rustc "/bin/rustc" "\"
617docs = false
618python = \"" python "/bin/python" "\"
619vendor = true
620submodules = false
621[install]
622prefix = \"" out "\"
623sysconfdir = \"etc\"
624[rust]
625debug=false
626jemalloc=false
627default-linker = \"" gcc "/bin/gcc" "\"
628channel = \"stable\"
629rpath = true
630[target." ,(platform-rust-target (lookup-platform-by-system (%current-system))) "]
631llvm-config = \"" llvm "/bin/llvm-config" "\"
632cc = \"" gcc "/bin/gcc" "\"
633cxx = \"" gcc "/bin/g++" "\"
634ar = \"" binutils "/bin/ar" "\"
635[dist]
636") port))))))
637 (replace 'build
638 ;; The standard library source location moved in this release.
639 (lambda* (#:key parallel-build? #:allow-other-keys)
640 (let ((job-spec (string-append
641 "-j" (if parallel-build?
642 (number->string (parallel-job-count))
643 "1"))))
644 (invoke "./x.py" job-spec "build" "--stage=1"
645 "library/std"
646 "src/tools/cargo"))))
647 (replace 'install
648 (lambda* (#:key outputs #:allow-other-keys)
649 (let* ((out (assoc-ref outputs "out"))
650 (cargo-out (assoc-ref outputs "cargo"))
651 (build (string-append "build/"
652 ,(platform-rust-target
653 (lookup-platform-by-target-or-system
654 (or (%current-target-system)
655 (%current-system)))))))
656 ;; Manually do the installation instead of calling './x.py
657 ;; install', as that is slow and needlessly rebuilds some
658 ;; things.
659
660 ;; TODO: Try reverting to use "./x.py install rustc std cargo"
661 ;; for Rust 1.91 and newer, which should no longer rebuild
662 ;; things unnecessarily.
663 (with-directory-excursion build
664 (install-file "stage1/bin/rustc" (string-append out "/bin"))
665 (install-file "stage1-tools-bin/cargo"
666 (string-append cargo-out "/bin"))
667 ;; Clean up some extraneous library files. The .rmeta files
668 ;; of the bootstrap compiler are not meant to be installed.
669 (for-each delete-file (find-files "stage1/lib" "\\.rmeta$"))
670 ;; This librustc_driver binary is internal and not supposed
671 ;; to be installed. It started causing issues with the build
672 ;; around Rust 1.89.
673 (for-each delete-file
674 (find-files "stage1/lib/rustlib"
675 "^librustc_driver.*\\.so$"))
676 (copy-recursively "stage1/lib" (string-append out "/lib"))))))
677 (add-after 'install 'delete-install-logs
678 (lambda* (#:key outputs #:allow-other-keys)
679 (for-each (lambda (f)
680 (false-if-exception (delete-file f)))
681 (append-map (lambda (output)
682 (find-files (string-append
683 output "/lib/rustlib")
684 "(^install.log$|^manifest-)"))
685 (map cdr outputs)))))
686 (add-after 'install 'wrap-rustc
687 (lambda* (#:key inputs outputs #:allow-other-keys)
688 (let ((out (assoc-ref outputs "out"))
689 (libc (assoc-ref inputs "libc"))
690 (ld-wrapper (assoc-ref inputs "ld-wrapper")))
691 ;; Let gcc find ld and libc startup files.
692 (wrap-program (string-append out "/bin/rustc")
693 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
694 `("LIBRARY_PATH" ":"
695 suffix (,(string-append libc "/lib"))))))))))
696 (native-inputs
697 `(("pkg-config" ,pkg-config)
698 ("python" ,python-minimal-wrapper)
699 ("python-setuptools" ,python-setuptools-bootstrap)
700 ("rustc-bootstrap" ,rust-bootstrap-1.54)
701 ("cargo-bootstrap" ,rust-bootstrap-1.54 "cargo")))
702 (inputs
703 `(("bash" ,bash-minimal)
704 ("llvm" ,llvm-13)
705 ("openssl" ,openssl)))
706 ;; rustc invokes gcc, so we need to set its search paths accordingly.
707 (native-search-paths
708 %gcc-search-paths)
709 ;; Limit this to systems where the final rust compiler builds successfully.
710 (supported-systems '("x86_64-linux" "aarch64-linux" "riscv64-linux"))
711 (synopsis "Compiler for the Rust programming language")
712 (description "Rust is a systems programming language that provides memory
713safety and thread safety guarantees.")
714 (home-page "https://www.rust-lang.org")
715 ;; Dual licensed.
716 (license (list license:asl2.0 license:expat))))
717
718(define-public rust-1.56
719 (let ((base-rust (rust-bootstrapped-package
720 rust-1.55 "1.56.1"
721 "04cmqx7nn63hzz7z27b2b0dj2qx18rck9ifvip43s6dampx8v2f3")))
722 (package
723 (inherit base-rust)
724 (arguments
725 (substitute-keyword-arguments
726 (strip-keyword-arguments '(#:validate-runpath?)
727 (package-arguments base-rust))
728 ((#:phases phases)
729 `(modify-phases ,phases
730 (delete 'add-cc-shim-to-path)
731 (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums
732 (lambda _
733 (substitute* "Cargo.lock"
734 (("(checksum = )\".*\"" all name)
735 (string-append name "\"" ,%cargo-reference-hash "\"")))
736 (generate-all-checksums "vendor"))))))))))
737
738(define-public rust-1.57
739 (rust-bootstrapped-package
740 ;; Verified that it *doesn't* build with 1.55. e.g.:
741 ;; * feature `edition2021` is required
742 rust-1.56 "1.57.0" "06jw8ka2p3kls8p0gd4p0chhhb1ia1mlvj96zn78n7qvp71zjiim"))
743
744(define-public rust-1.58
745 (rust-bootstrapped-package
746 ;; Verified that it *doesn't* build with 1.56. e.g.:
747 ;; * error: attributes starting with `rustc` are reserved for use by the
748 ;; `rustc` compiler
749 ;; * error: cannot find attribute `rustc_do_not_const_check` in this scope
750 ;; * error[E0522]: definition of an unknown language item:
751 ;; `const_eval_select_ct`
752 rust-1.57 "1.58.1" "1iq7kj16qfpkx8gvw50d8rf7glbm6s0pj2y1qkrz7mi56vfsyfd8"))
753
754(define-public rust-1.59
755 (let ((base-rust
756 (rust-bootstrapped-package
757 ;; Verified that it *doesn't* build with 1.57. e.g.:
758 ;; * error: `doc(primitive)` should never have been stable
759 ;; * error[E0522]: definition of an unknown language item:
760 ;; `generator_return`
761 ;; * error[E0206]: the trait `Copy` may not be implemented for this type
762 rust-1.58 "1.59.0" "1yc5bwcbmbwyvpfq7zvra78l0r8y3lbv60kbr62fzz2vx2pfxj57")))
763 (package
764 (inherit base-rust)
765 (arguments
766 (if (target-riscv64?)
767 (substitute-keyword-arguments (package-arguments base-rust)
768 ((#:phases phases)
769 `(modify-phases ,phases
770 (add-after 'unpack 'revert-riscv-pause-instruction
771 (lambda _
772 ;; This fails with:
773 ;; error: unknown directive, referring to '.insn'.
774 ;; This is due to building with llvm < 14.
775 ;; https://github.com/rust-lang/stdarch/issues/1291
776 ;; Partial roll-back from this commit:
777 ;; https://github.com/rust-lang/stdarch/pull/1271
778 (substitute*
779 "library/stdarch/crates/core_arch/src/riscv_shared/mod.rs"
780 (("\\.insn i 0x0F, 0, x0, x0, 0x010") ".word 0x0100000F")))))))
781 (package-arguments base-rust))))))
782
783(define-public rust-1.60
784 (rust-bootstrapped-package
785 ;; Verified that it *doesn't* build with 1.58. e.g.:
786 ;; * error: unknown codegen option: `symbol-mangling-version`
787 rust-1.59 "1.60.0" "1drqr0a26x1rb2w3kj0i6abhgbs3jx5qqkrcwbwdlx7n3inq5ji0"))
788
789(define-public rust-1.61
790 (let ((base-rust
791 (rust-bootstrapped-package
792 rust-1.60 "1.61.0" "1vfs05hkf9ilk19b2vahqn8l6k17pl9nc1ky9kgspaascx8l62xd")))
793 (package
794 (inherit base-rust)
795 (source
796 (origin
797 (inherit (package-source base-rust))
798 (snippet
799 '(begin
800 (for-each delete-file-recursively
801 '("src/llvm-project"
802 "vendor/openssl-src/openssl"
803 "vendor/tikv-jemalloc-sys/jemalloc"))
804 ;; Remove vendored dynamically linked libraries.
805 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
806 (delete-file "vendor/vte/vim10m_match")
807 (delete-file "vendor/vte/vim10m_table")
808 ;; Also remove the bundled (mostly Windows) libraries.
809 (for-each delete-file
810 (find-files "vendor" "\\.(a|dll|exe|lib)$")))))))))
811
812(define-public rust-1.62
813 (rust-bootstrapped-package
814 rust-1.61 "1.62.1" "0gqkg34ic77dcvsz69qbdng6g3zfhl6hnhx7ha1mjkyrzipvxb3j"))
815
816(define-public rust-1.63
817 (rust-bootstrapped-package
818 rust-1.62 "1.63.0" "1l4rrbzhxv88pnfq94nbyb9m6lfnjwixma3mwjkmvvs2aqlq158z"))
819
820(define-public rust-1.64
821 (let ((base-rust
822 (rust-bootstrapped-package
823 rust-1.63 "1.64.0" "018j720b2n12slp4xk64jc6shkncd46d621qdyzh2a8s3r49zkdk")))
824 (package
825 (inherit base-rust)
826 (source
827 (origin
828 (inherit (package-source base-rust))
829 (snippet
830 '(begin
831 (for-each delete-file-recursively
832 '("src/llvm-project"
833 "vendor/openssl-src/openssl"
834 "vendor/tikv-jemalloc-sys/jemalloc"))
835 ;; ERROR: could not find native static library
836 ;; `rustix_outline_powerpc64`, perhaps an -L flag is missing?
837 ;; Adjust rustix to always build with cc.
838 (substitute* "src/bootstrap/Cargo.lock"
839 (("\"errno\",") "\"cc\",\n \"errno\","))
840 ;; Add a dependency on the the 'cc' feature of rustix.
841 (substitute* "vendor/fd-lock/Cargo.toml"
842 (("\"fs\"") "\"fs\", \"cc\""))
843 ;; Remove vendored dynamically linked libraries.
844 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
845 (delete-file "vendor/vte/vim10m_match")
846 (delete-file "vendor/vte/vim10m_table")
847 ;; Also remove the bundled (mostly Windows) libraries.
848 (for-each delete-file
849 (find-files "vendor" "\\.(a|dll|exe|lib)$"))))
850 (patches (search-patches "rust-1.64-fix-riscv64-bootstrap.patch"))
851 (patch-flags '("-p1" "--reverse"))))
852 (arguments
853 (substitute-keyword-arguments (package-arguments base-rust)
854 ((#:phases phases)
855 `(modify-phases ,phases
856 (replace 'patch-cargo-checksums
857 (lambda _
858 (substitute* '("Cargo.lock"
859 "src/bootstrap/Cargo.lock"
860 "src/tools/rust-analyzer/Cargo.lock")
861 (("(checksum = )\".*\"" all name)
862 (string-append name "\"" ,%cargo-reference-hash "\"")))
863 (generate-all-checksums "vendor"))))))))))
864
865(define-public rust-1.65
866 (let ((base-rust
867 (rust-bootstrapped-package
868 rust-1.64 "1.65.0" "0f005kc0vl7qyy298f443i78ibz71hmmh820726bzskpyrkvna2q")))
869 (package
870 (inherit base-rust)
871 (source
872 (origin
873 (inherit (package-source base-rust))
874 (patches '())
875 (patch-flags '("-p1")))))))
876
877(define-public rust-1.66
878 (rust-bootstrapped-package
879 rust-1.65 "1.66.1" "1fjr94gsicsxd2ypz4zm8aad1zdbiccr7qjfbmq8f8f7jhx96g2v"))
880
881(define-public rust-1.67
882 (let ((base-rust
883 (rust-bootstrapped-package
884 rust-1.66 "1.67.1" "0vpzv6rm3w1wbni17ryvcw83k5klhghklylfdza3nnp8blz3sj26")))
885 (package
886 (inherit base-rust)
887 (source
888 (origin
889 (inherit (package-source base-rust))
890 (snippet
891 '(begin
892 (for-each delete-file-recursively
893 '("src/llvm-project"
894 "vendor/openssl-src/openssl"
895 "vendor/tikv-jemalloc-sys/jemalloc"))
896 ;; Adjust rustix to always build with cc.
897 (substitute* '("Cargo.lock"
898 "src/bootstrap/Cargo.lock")
899 (("\"errno\",") "\"cc\",\n \"errno\","))
900 ;; Add a dependency on the the 'cc' feature of rustix.
901 (substitute* "vendor/fd-lock/Cargo.toml"
902 (("\"fs\"") "\"fs\", \"cc\""))
903 (substitute* "vendor/is-terminal/Cargo.toml"
904 (("\"termios\"") "\"termios\", \"cc\""))
905 ;; Remove vendored dynamically linked libraries.
906 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
907 (delete-file "vendor/vte/vim10m_match")
908 (delete-file "vendor/vte/vim10m_table")
909 ;; Also remove the bundled (mostly Windows) libraries.
910 (for-each delete-file
911 (find-files "vendor" "\\.(a|dll|exe|lib)$"))))))
912 (inputs (modify-inputs inputs
913 (replace "llvm" llvm-15))))))
914
915(define-public rust-1.68
916 (rust-bootstrapped-package
917 rust-1.67 "1.68.2" "15ifyd5jj8rd979dkakp887hgmhndr68pqaqvd2hqkfdywirqcwk"))
918
919(define-public rust-1.69
920 (let ((base-rust
921 (rust-bootstrapped-package
922 rust-1.68 "1.69.0"
923 "03zn7kx5bi5mdfsqfccj4h8gd6abm7spj0kjsfxwlv5dcwc9f1gv")))
924 (package
925 (inherit base-rust)
926 (source
927 (origin
928 (inherit (package-source base-rust))
929 (snippet
930 '(begin
931 (for-each delete-file-recursively
932 '("src/llvm-project"
933 "vendor/openssl-src/openssl"
934 "vendor/tikv-jemalloc-sys/jemalloc"))
935 ;; Adjust rustix to always build with cc.
936 (substitute* '("Cargo.lock"
937 "src/bootstrap/Cargo.lock")
938 (("\"errno\",") "\"cc\",\n \"errno\","))
939 ;; Add a dependency on the the 'cc' feature of rustix.
940 (substitute* "vendor/fd-lock/Cargo.toml"
941 (("\"fs\"") "\"fs\", \"cc\""))
942 (substitute* "vendor/is-terminal/Cargo.toml"
943 (("\"termios\"") "\"termios\", \"cc\""))
944 ;; Also remove the bundled (mostly Windows) libraries.
945 (for-each delete-file
946 (find-files "vendor" "\\.(a|dll|exe|lib)$")))))))))
947
948(define-public rust-1.70
949 (let ((base-rust
950 (rust-bootstrapped-package
951 rust-1.69 "1.70.0"
952 "0z6j7d0ni0rmfznv0w3mrf882m11kyh51g2bxkj40l3s1c0axgxj")))
953 (package
954 (inherit base-rust)
955 (source
956 (origin
957 (inherit (package-source base-rust))
958 (snippet
959 '(begin
960 (for-each delete-file-recursively
961 '("src/llvm-project"
962 "vendor/openssl-src/openssl"
963 "vendor/tikv-jemalloc-sys/jemalloc"))
964 ;; Adjust rustix to always build with cc.
965 (substitute* "Cargo.lock"
966 (("\"errno\",") "\"cc\",\n \"errno\","))
967 ;; Add a dependency on the the 'cc' feature of rustix.
968 (substitute* '("vendor/is-terminal/Cargo.toml"
969 "vendor/is-terminal-0.4.4/Cargo.toml")
970 (("\"termios\"") "\"termios\", \"cc\""))
971 ;; Also remove the bundled (mostly Windows) libraries.
972 (for-each delete-file
973 (find-files "vendor" "\\.(a|dll|exe|lib)$"))))
974 ;; Rust 1.70 adds the rustix library which depends on the vendored
975 ;; fd-lock crate. The fd-lock crate uses Outline assembly which expects
976 ;; a precompiled static library. Enabling the "cc" feature tells the
977 ;; build.rs script to compile the assembly files instead of searching
978 ;; for a precompiled library.
979 (patches (search-patches "rust-1.70-fix-rustix-build.patch")))))))
980
981(define-public rust-1.71
982 (let ((base-rust
983 (rust-bootstrapped-package
984 rust-1.70 "1.71.1" "0bj79syjap1kgpg9pc0r4jxc0zkxwm6phjf3digsfafms580vabg")))
985 (package
986 (inherit base-rust)
987 (source
988 (origin
989 (inherit (package-source base-rust))
990 (snippet
991 '(begin
992 (for-each delete-file-recursively
993 '("src/llvm-project"
994 "vendor/openssl-src/openssl"
995 "vendor/tikv-jemalloc-sys/jemalloc"))
996 ;; Adjust rustix to always build with cc.
997 (substitute* '("Cargo.lock"
998 "src/tools/cargo/Cargo.lock")
999 (("\"errno\",") "\"cc\",\n \"errno\","))
1000 ;; Add a dependency on the the 'cc' feature of rustix.
1001 (substitute* '("vendor/is-terminal/Cargo.toml"
1002 "vendor/is-terminal-0.4.6/Cargo.toml")
1003 (("\"termios\"") "\"termios\", \"cc\""))
1004 ;; Also remove the bundled (mostly Windows) libraries.
1005 (for-each delete-file
1006 (find-files "vendor" "\\.(a|dll|exe|lib)$"))))))
1007 (arguments
1008 (substitute-keyword-arguments (package-arguments base-rust)
1009 ((#:phases phases)
1010 `(modify-phases ,phases
1011 (replace 'patch-cargo-checksums
1012 (lambda _
1013 (substitute* (cons* "Cargo.lock"
1014 "src/bootstrap/Cargo.lock"
1015 (find-files "src/tools" "Cargo.lock"))
1016 (("(checksum = )\".*\"" all name)
1017 (string-append name "\"" ,%cargo-reference-hash "\"")))
1018 (generate-all-checksums "vendor"))))))))))
1019
1020(define-public rust-1.72
1021 (let ((base-rust
1022 (rust-bootstrapped-package
1023 rust-1.71 "1.72.1" "15gqd1jzhnc16a7gjmav4x1v83jjbzyjh1gvcdfvpkajd9gq8j3z")))
1024 (package
1025 (inherit base-rust)
1026 (source
1027 (origin
1028 (inherit (package-source base-rust))
1029 (snippet
1030 '(begin
1031 (for-each delete-file-recursively
1032 '("src/llvm-project"
1033 "vendor/openssl-src/openssl"
1034 "vendor/tikv-jemalloc-sys/jemalloc"))
1035 ;; Remove vendored dynamically linked libraries.
1036 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1037 ;; Also remove the bundled (mostly Windows) libraries.
1038 (for-each delete-file
1039 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1040 ;; Adjust some crates to explicitly use rustix with the libc backend.
1041 (substitute* '("vendor/is-terminal/Cargo.toml"
1042 "vendor/is-terminal-0.4.7/Cargo.toml")
1043 (("\"termios\"") "\"termios\", \"use-libc\""))
1044 (substitute* "compiler/rustc_driver/Cargo.toml"
1045 (("rustix = \"=0.37.11\"")
1046 (string-append "rustix = { version = \"=0.37.11\","
1047 " features = [\"use-libc\"] }"))))))))))
1048
1049(define-public rust-1.73
1050 (let ((base-rust (rust-bootstrapped-package rust-1.72 "1.73.0"
1051 "0fmvn7vg3qg9xprgfwv10g3ygy8i4j4bkcxcr1xdy89d3xnjxmln")))
1052 (package
1053 (inherit base-rust)
1054 (source
1055 (origin
1056 (inherit (package-source base-rust))
1057 (snippet
1058 '(begin
1059 (for-each delete-file-recursively
1060 '("src/llvm-project"
1061 "vendor/openssl-src/openssl"
1062 "vendor/tikv-jemalloc-sys/jemalloc"))
1063 ;; Remove vendored dynamically linked libraries.
1064 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1065 ;; Also remove the bundled (mostly Windows) libraries.
1066 (for-each delete-file
1067 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1068 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1069 (substitute* "vendor/tempfile-3.6.0/Cargo.toml"
1070 (("features = \\[\"fs\"" all)
1071 (string-append all ", \"use-libc\""))))))))))
1072
1073(define-public rust-1.74
1074 (let ((base-rust (rust-bootstrapped-package rust-1.73 "1.74.1"
1075 "07930r17dkj3dnsrmilywb6p9i2g2jx56ndfpa2wh8crzhi3xnv7")))
1076 (package
1077 (inherit base-rust)
1078 (source
1079 (origin
1080 (inherit (package-source base-rust))
1081 (snippet
1082 '(begin
1083 (for-each delete-file-recursively
1084 '("src/llvm-project"
1085 "vendor/openssl-src/openssl"
1086 "vendor/tikv-jemalloc-sys/jemalloc"))
1087 ;; Remove vendored dynamically linked libraries.
1088 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1089 ;; Also remove the bundled (mostly Windows) libraries.
1090 (for-each delete-file
1091 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1092 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1093 (substitute* "vendor/tempfile/Cargo.toml"
1094 (("features = \\[\"fs\"" all)
1095 (string-append all ", \"use-libc\"")))))))
1096 (arguments
1097 (if (target-riscv64?)
1098 (substitute-keyword-arguments (package-arguments base-rust)
1099 ((#:phases phases)
1100 `(modify-phases ,phases
1101 ;; This phase is no longer needed.
1102 (delete 'revert-riscv-pause-instruction))))
1103 (package-arguments base-rust))))))
1104
1105(define-public rust-1.75
1106 (let ((base-rust (rust-bootstrapped-package
1107 rust-1.74 "1.75.0"
1108 "1260mf3066ki6y55pvr35lnf54am6z96a3ap3hniwd4xpi2rywsv")))
1109 (package
1110 (inherit base-rust)
1111 (source
1112 (origin
1113 (inherit (package-source base-rust))
1114 (patches '())))
1115 (arguments
1116 (if (supported-package? rust-bootstrap-1.74)
1117 (substitute-keyword-arguments (package-arguments base-rust)
1118 ((#:phases phases)
1119 `(modify-phases ,phases
1120 (add-after 'unpack 'add-cc-shim-to-path
1121 (lambda _
1122 (mkdir-p "/tmp/bin")
1123 (symlink (which "gcc") "/tmp/bin/cc")
1124 (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
1125 (replace 'install
1126 (lambda* (#:key outputs #:allow-other-keys)
1127 (let* ((out (assoc-ref outputs "out"))
1128 (cargo-out (assoc-ref outputs "cargo"))
1129 (build (string-append "build/"
1130 ,(platform-rust-target
1131 (lookup-platform-by-target-or-system
1132 (or (%current-target-system)
1133 (%current-system)))))))
1134 ;; Manually do the installation instead of calling './x.py
1135 ;; install', as that is slow and needlessly rebuilds some
1136 ;; things.
1137
1138 ;; TODO: Try reverting to use "./x.py install rustc std cargo"
1139 ;; for Rust 1.91 and newer, which should no longer rebuild
1140 ;; things unnecessarily.
1141 (with-directory-excursion build
1142 (install-file "stage1/bin/rustc" (string-append out "/bin"))
1143 (install-file "stage1-tools-bin/cargo"
1144 (string-append cargo-out "/bin"))
1145 ;; Clean up some extraneous library files. The .rmeta files
1146 ;; of the bootstrap compiler are not meant to be installed.
1147 (for-each delete-file (find-files "stage1/lib" "\\.rmeta$"))
1148 ;; This librustc_driver binary is internal and not supposed
1149 ;; to be installed. It started causing issues with the build
1150 ;; around Rust 1.89.
1151 (for-each delete-file
1152 (find-files "stage1/lib/rustlib"
1153 "^librustc_driver.*\\.so$"))
1154 (copy-recursively "stage1/lib" (string-append out "/lib")))))))))
1155 (package-arguments base-rust)))
1156 (native-inputs
1157 (if (supported-package? rust-bootstrap-1.74)
1158 (modify-inputs native-inputs
1159 (replace "cargo-bootstrap" (list rust-bootstrap-1.74 "cargo"))
1160 (replace "rustc-bootstrap" rust-bootstrap-1.74))
1161 (package-native-inputs base-rust)))
1162 (inputs (modify-inputs inputs
1163 (replace "llvm" llvm-17))))))
1164
1165(define-public rust-1.76
1166 (let ((base-rust (rust-bootstrapped-package rust-1.75 "1.76.0"
1167 "08f06shp6l72qrv5fwg1is7yzr6kwj8av0l9h5k243bz781zyp4y")))
1168 (package
1169 (inherit base-rust)
1170 (arguments
1171 (substitute-keyword-arguments (package-arguments base-rust)
1172 ((#:phases phases)
1173 `(modify-phases ,phases
1174 (delete 'add-cc-shim-to-path))))))))
1175
1176(define-public rust-1.77
1177 (let ((base-rust (rust-bootstrapped-package rust-1.76 "1.77.1"
1178 "18d4ncdzp0nfimmw029xdf7vv1hgh82v30mjnnixnllzar66w47f")))
1179 (package
1180 (inherit base-rust)
1181 (arguments
1182 (substitute-keyword-arguments (package-arguments base-rust)
1183 ((#:phases phases)
1184 `(modify-phases ,phases
1185 (add-after 'configure 'no-optimized-compiler-builtins
1186 (lambda _
1187 ;; Pre-1.77, the behavior was equivalent to this flag being
1188 ;; "false" if the llvm-project submodule wasn't checked out.
1189 ;;
1190 ;; Now there's an explicit check, so the build fails if we don't
1191 ;; manually disable this (given that we don't have the submodule checked out).
1192 ;; Thus making the build behave the same as it did in 1.76 and earlier.
1193 ;;
1194 ;; TODO - make the build system depend on system llvm for this, so we
1195 ;; can get the performance benefits of setting this to true?
1196 (substitute* "config.toml"
1197 (("\\[build\\]")
1198 "[build]\noptimized-compiler-builtins = false")))))))))))
1199
1200(define-public rust-1.78
1201 (let ((base-rust (rust-bootstrapped-package rust-1.77 "1.78.0"
1202 "1afmj5g3bz7439w4i8zjhd68zvh0gqg7ymr8h5rz49ybllilhm7z")))
1203 (package
1204 (inherit base-rust)
1205 (source
1206 (origin
1207 (inherit (package-source base-rust))
1208 ;; see https://github.com/rust-lang/rust/pull/125844
1209 (patches (search-patches "rust-1.78-unwinding-fix.patch")))))))
1210
1211(define-public rust-1.79
1212 (let ((base-rust (rust-bootstrapped-package rust-1.78 "1.79.0"
1213 "1h282jb1yxc69999w4nhvqb08rw2jy32i9njdjqrz78zglycybhp")))
1214 (package
1215 (inherit base-rust)
1216 (source
1217 (origin
1218 (inherit (package-source base-rust))
1219 (snippet
1220 '(begin
1221 (for-each delete-file-recursively
1222 '("src/llvm-project"
1223 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1224 "vendor/openssl-src-111.28.1+1.1.1w/openssl"
1225 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"))
1226 ;; Remove vendored dynamically linked libraries.
1227 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1228 ;; Also remove the bundled (mostly Windows) libraries.
1229 (for-each delete-file
1230 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1231 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1232 (substitute* '("vendor/tempfile-3.7.1/Cargo.toml"
1233 "vendor/tempfile-3.10.1/Cargo.toml")
1234 (("features = \\[\"fs\"" all)
1235 (string-append all ", \"use-libc\""))))))))))
1236
1237(define-public rust-1.80
1238 (let ((base-rust (rust-bootstrapped-package rust-1.79 "1.80.1"
1239 "1i1dbpwnv6ak244lapsxvd26w6sbas9g4l6crc8bip2275j8y2rc")))
1240 (package
1241 (inherit base-rust)
1242 (source
1243 (origin
1244 (inherit (package-source base-rust))
1245 (snippet
1246 '(begin
1247 (for-each delete-file-recursively
1248 '("src/llvm-project"
1249 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1250 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1251 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1252 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"))
1253 ;; Remove vendored dynamically linked libraries.
1254 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1255 ;; Also remove the bundled (mostly Windows) libraries.
1256 (for-each delete-file
1257 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1258 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1259 (substitute* '("vendor/tempfile-3.7.1/Cargo.toml"
1260 "vendor/tempfile-3.10.1/Cargo.toml")
1261 (("features = \\[\"fs\"" all)
1262 (string-append all ", \"use-libc\""))))))))))
1263
1264(define-public rust-1.81
1265 (let ((base-rust (rust-bootstrapped-package rust-1.80 "1.81.0"
1266 "19yggj1qivdhf68gx2652cfi7nxjkdgy39wh7h6facpzppz4h947")))
1267 (package
1268 (inherit base-rust)
1269 (source
1270 (origin
1271 (inherit (package-source base-rust))
1272 ;; see https://github.com/rust-lang/rust/issues/129268#issuecomment-2430133779
1273 (patches (search-patches "rust-1.81-fix-riscv64-bootstrap.patch")))))))
1274
1275(define-public rust-1.82
1276 (let ((base-rust (rust-bootstrapped-package rust-1.81 "1.82.0"
1277 "0ajiryki2aqsg3ydx3nfhrb5i1mmxvasfszs9qblw66skr8g8lvw")))
1278 (package
1279 (inherit base-rust)
1280 (source
1281 (origin
1282 (inherit (package-source base-rust))
1283 (patches '())))
1284 (arguments
1285 (substitute-keyword-arguments (package-arguments base-rust)
1286 ((#:phases phases)
1287 `(modify-phases ,phases
1288 (replace 'patch-cargo-checksums
1289 (lambda _
1290 (substitute* (cons* "Cargo.lock"
1291 "src/bootstrap/Cargo.lock"
1292 "library/Cargo.lock"
1293 (filter
1294 ;; Don't mess with the lock files in the
1295 ;; Cargo testsuite; it messes up the tests.
1296 (lambda (path)
1297 (not (string-contains
1298 path "cargo/tests/testsuite")))
1299 (find-files "src/tools" "Cargo.lock")))
1300 (("(checksum = )\".*\"" all name)
1301 (string-append name "\"" ,%cargo-reference-hash "\"")))
1302 (generate-all-checksums "vendor"))))))))))
1303
1304(define-public rust-1.83
1305 (let ((base-rust (rust-bootstrapped-package rust-1.82 "1.83.0"
1306 "0vhwhk4cbyppnz0lcazfjyddyz811fgvadfxswldicpashxpfbbj")))
1307 (package
1308 (inherit base-rust)
1309 (source
1310 (origin
1311 (inherit (package-source base-rust))
1312 (snippet
1313 '(begin
1314 (for-each delete-file-recursively
1315 '("src/gcc"
1316 "src/llvm-project"
1317 "vendor/jemalloc-sys-0.3.2"
1318 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1319 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1320 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1321 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"))
1322 ;; Remove vendored dynamically linked libraries.
1323 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1324 ;; Also remove the bundled (mostly Windows) libraries.
1325 (for-each delete-file
1326 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1327 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1328 (substitute* '("vendor/tempfile-3.10.1/Cargo.toml"
1329 "vendor/tempfile-3.13.0/Cargo.toml")
1330 (("features = \\[\"fs\"" all)
1331 (string-append all ", \"use-libc\"")))))))
1332 (arguments
1333 (substitute-keyword-arguments (package-arguments base-rust)
1334 ((#:phases phases)
1335 `(modify-phases ,phases
1336 (add-after 'configure 'use-system-llvm
1337 (lambda _
1338 (substitute* "config.toml"
1339 (("\\[llvm\\]") "[llvm]\ndownload-ci-llvm = false")
1340 (("\\[rust\\]") "[rust]\ndownload-rustc = false"))))))))
1341 ;; Need llvm >= 18.0
1342 (inputs (modify-inputs inputs
1343 (replace "llvm" llvm-19))))))
1344
1345(define-public rust-1.84
1346 (rust-bootstrapped-package rust-1.83 "1.84.1"
1347 "0xdk3g1xq33fy4m7q6l38ba9ydxbanccyb0vczvlk998jvababsy"))
1348
1349(define-public rust-1.85
1350 (let ((base-rust
1351 (rust-bootstrapped-package rust-1.84 "1.85.1"
1352 "12i3jkxrc2bbd2d423q7krwkbc39wlwkjacsimx7b61m1359aa8g")))
1353 (package
1354 (inherit base-rust)
1355 (source
1356 (origin
1357 (inherit (package-source base-rust))
1358 (snippet
1359 '(begin
1360 (for-each delete-file-recursively
1361 '("src/llvm-project"
1362 "vendor/jemalloc-sys-0.3.2"
1363 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1364 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1365 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1366 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1367 ;; Remove vendored dynamically linked libraries.
1368 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1369 ;; Also remove the bundled (mostly Windows) libraries.
1370 (for-each delete-file
1371 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1372 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1373 (substitute* '("vendor/tempfile-3.10.1/Cargo.toml"
1374 "vendor/tempfile-3.14.0/Cargo.toml")
1375 (("features = \\[\"fs\"" all)
1376 (string-append all ", \"use-libc\""))))))))))
1377
1378(define-public rust-1.86
1379 (let ((base-rust
1380 (rust-bootstrapped-package
1381 rust-1.85 "1.86.0"
1382 "107d3vbmwhn4b71gzr1kv31jwwyld7dxj9yj8jh00ygndll2fah2")))
1383 (package
1384 (inherit base-rust)
1385 (source
1386 (origin
1387 (inherit (package-source base-rust))
1388 (snippet
1389 '(begin
1390 (for-each delete-file-recursively
1391 '("src/llvm-project"
1392 "vendor/jemalloc-sys-0.3.2"
1393 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1394 "vendor/openssl-src-111.17.0+1.1.1m/openssl"
1395 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1396 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1397 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1398 ;; Remove vendored dynamically linked libraries.
1399 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1400 ;; Also remove the bundled (mostly Windows) libraries.
1401 (for-each delete-file
1402 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1403 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1404 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1405 "vendor/tempfile-3.15.0/Cargo.toml"
1406 "vendor/tempfile-3.16.0/Cargo.toml")
1407 (("features = \\[\"fs\"" all)
1408 (string-append all ", \"use-libc\"")))))))
1409 (arguments
1410 (substitute-keyword-arguments (package-arguments base-rust)
1411 ((#:phases phases)
1412 `(modify-phases ,phases
1413 (add-after 'use-system-llvm 'disable-lld-wrapper
1414 (lambda _
1415 (substitute* "config.toml"
1416 (("\\[rust\\]") "[rust]\nlld = false")))))))))))
1417
1418(define-public rust-1.87
1419 (let ((base-rust
1420 (rust-bootstrapped-package rust-1.86 "1.87.0"
1421 "0xlfzl24qhs4vlwn7d2hd2zkg6k2y1lgq03rx2j2sndy57yvk6ql")))
1422 (package
1423 (inherit base-rust)
1424 (source
1425 (origin
1426 (inherit (package-source base-rust))
1427 (snippet
1428 '(begin
1429 (for-each delete-file-recursively
1430 '("src/llvm-project"
1431 "vendor/jemalloc-sys-0.3.2"
1432 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1433 "vendor/openssl-src-111.17.0+1.1.1m/openssl"
1434 "vendor/openssl-src-300.4.2+3.4.1/openssl"
1435 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1436 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1437 ;; Remove vendored dynamically linked libraries.
1438 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1439 ;; Also remove the bundled (mostly Windows) libraries.
1440 (for-each delete-file
1441 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1442 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1443 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1444 "vendor/tempfile-3.15.0/Cargo.toml"
1445 "vendor/tempfile-3.17.1/Cargo.toml")
1446 (("features = \\[\"fs\"" all)
1447 (string-append all ", \"use-libc\"")))))))
1448 (arguments
1449 (substitute-keyword-arguments (package-arguments base-rust)
1450 ((#:phases phases)
1451 `(modify-phases ,phases
1452 (replace 'build
1453 ;; Just building stage 1 no longer builds cargo.
1454
1455 ;; TODO: Try reverting to use "./x.py install rustc std cargo"
1456 ;; when Rust 1.91 comes out, which should no longer rebuild
1457 ;; things unnecessarily. If this works, the 'post-install'
1458 ;; phase carried from earlier should no longer be necessary.
1459 (lambda* (#:key parallel-build? #:allow-other-keys)
1460 (let ((job-spec (string-append
1461 "-j" (if parallel-build?
1462 (number->string (parallel-job-count))
1463 "1"))))
1464 (invoke "./x.py" job-spec "build" "--stage=2"
1465 "library/std"
1466 "src/tools/cargo")))))))))))
1467
1468(define-public rust-1.88
1469 (let ((base-rust
1470 (rust-bootstrapped-package
1471 rust-1.87 "1.88.0"
1472 "1gngrxjfqiyybyamzn8s4rfbhk7jss1vrmnijg8y72l46i2595rs")))
1473 (package
1474 (inherit base-rust)
1475 (source
1476 (origin
1477 (inherit (package-source base-rust))
1478 (snippet
1479 '(begin
1480 (for-each delete-file-recursively
1481 '("src/llvm-project"
1482 "vendor/jemalloc-sys-0.3.2"
1483 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1484 "vendor/openssl-src-111.17.0+1.1.1m/openssl"
1485 "vendor/openssl-src-300.4.2+3.4.1/openssl"
1486 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1487 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1488 ;; Remove vendored dynamically linked libraries.
1489 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1490 ;; Also remove the bundled (mostly Windows) libraries.
1491 (for-each delete-file
1492 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1493 ;; Adjust vendored dependency to explicitly use rustix with libc backend.
1494 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1495 "vendor/tempfile-3.17.1/Cargo.toml"
1496 "vendor/tempfile-3.19.0/Cargo.toml"
1497 "vendor/tempfile-3.19.1/Cargo.toml")
1498 (("features = \\[\"fs\"" all)
1499 (string-append all ", \"use-libc\""))))))))))
1500
1501(define-public rust-1.89
1502 (let ((base-rust
1503 (rust-bootstrapped-package
1504 rust-1.88 "1.89.0"
1505 "0395ax8d138ch65fzm1y9xf2s4661am5k3yj3cav16fx83sgjxi5")))
1506 (package
1507 (inherit base-rust)
1508 (source
1509 (origin
1510 (inherit (package-source base-rust))
1511 (snippet
1512 '(begin
1513 (for-each delete-file-recursively
1514 '("src/llvm-project"
1515 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1516 "vendor/curl-sys-0.4.80+curl-8.12.1/curl"
1517 "vendor/curl-sys-0.4.82+curl-8.14.1/curl"
1518 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1519 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1520 "vendor/libffi-sys-3.3.1/libffi"
1521 "vendor/libz-sys-1.1.21/src/zlib"
1522 "vendor/libz-sys-1.1.22/src/zlib"
1523 "vendor/libmimalloc-sys-0.1.42/c_src/mimalloc"
1524 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1525 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1526 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1527 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-\
1528ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1529 ;; Remove vendored dynamically linked libraries.
1530 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1531 ;; Also remove the bundled (mostly Windows) libraries.
1532 (for-each delete-file
1533 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1534 ;; Use the packaged nghttp2.
1535 (for-each
1536 (lambda (ver)
1537 (let ((vendored-dir
1538 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1539 (build-rs
1540 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1541 (delete-file-recursively vendored-dir)
1542 (delete-file build-rs)
1543 (call-with-output-file build-rs
1544 (lambda (port)
1545 (format port "fn main() {~@
1546 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1547 }~%")))))
1548 '("0.1.11+1.64.0"))
1549 ;; Adjust vendored dependency to explicitly use rustix with libc
1550 ;; backend.
1551 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1552 "vendor/tempfile-3.16.0/Cargo.toml"
1553 "vendor/tempfile-3.19.0/Cargo.toml"
1554 "vendor/tempfile-3.19.1/Cargo.toml"
1555 "vendor/tempfile-3.20.0/Cargo.toml")
1556 (("features = \\[\"fs\"" all)
1557 (string-append all ", \"use-libc\"")))))))
1558 (inputs
1559 (modify-inputs inputs
1560 (prepend curl `(,nghttp2 "lib") libffi))))))
1561
1562(define-public rust-1.90
1563 (let ((base-rust
1564 (rust-bootstrapped-package
1565 rust-1.89 "1.90.0"
1566 "0zlv3ybd8za07brxwj4n03cma1snnpvbqj0h0wg3bmafpaf9z6kr")))
1567 (package
1568 (inherit base-rust)
1569 (source
1570 (origin
1571 (inherit (package-source base-rust))
1572 (snippet
1573 '(begin
1574 (for-each delete-file-recursively
1575 '("src/llvm-project"
1576 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1577 "vendor/curl-sys-0.4.82+curl-8.14.1/curl"
1578 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1579 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1580 "vendor/libffi-sys-3.3.2/libffi"
1581 "vendor/libz-sys-1.1.21/src/zlib"
1582 "vendor/libz-sys-1.1.22/src/zlib"
1583 "vendor/libmimalloc-sys-0.1.42/c_src/mimalloc"
1584 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1585 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1586 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1587 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-\
1588ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1589 ;; Remove vendored dynamically linked libraries.
1590 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1591 ;; Also remove the bundled (mostly Windows) libraries.
1592 (for-each delete-file
1593 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1594 ;; Use the packaged nghttp2.
1595 (for-each
1596 (lambda (ver)
1597 (let ((vendored-dir
1598 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1599 (build-rs
1600 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1601 (delete-file-recursively vendored-dir)
1602 (delete-file build-rs)
1603 (call-with-output-file build-rs
1604 (lambda (port)
1605 (format port "fn main() {~@
1606 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1607 }~%")))))
1608 '("0.1.11+1.64.0"))
1609 ;; Adjust vendored dependency to explicitly use rustix with libc
1610 ;; backend.
1611 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1612 "vendor/tempfile-3.16.0/Cargo.toml"
1613 "vendor/tempfile-3.19.0/Cargo.toml"
1614 "vendor/tempfile-3.19.1/Cargo.toml"
1615 "vendor/tempfile-3.20.0/Cargo.toml")
1616 (("features = \\[\"fs\"" all)
1617 (string-append all ", \"use-libc\"")))))))
1618 (inputs
1619 (modify-inputs inputs
1620 (replace "llvm" llvm-21))))))
1621
1622(define-public rust-1.91
1623 (let ((base-rust
1624 (rust-bootstrapped-package
1625 rust-1.90 "1.91.0"
1626 "12iysk87bmhlcdcbr939y8cdfcx0an4z9ixjlbq16c3ma60m4zrj")))
1627 (package
1628 (inherit base-rust)
1629 (source
1630 (origin
1631 (inherit (package-source base-rust))
1632 (snippet
1633 '(begin
1634 (for-each delete-file-recursively
1635 '("src/llvm-project"
1636 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1637 "vendor/curl-sys-0.4.83+curl-8.15.0/curl"
1638 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1639 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1640 "vendor/libffi-sys-3.3.2/libffi"
1641 "vendor/libz-sys-1.1.21/src/zlib"
1642 "vendor/libz-sys-1.1.22/src/zlib"
1643 "vendor/libmimalloc-sys-0.1.42/c_src/mimalloc"
1644 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1645 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1646 "vendor/openssl-src-300.5.2+3.5.2/openssl"
1647 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1648 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-\
1649ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1650 ;; Remove vendored dynamically linked libraries.
1651 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1652 ;; Also remove the bundled (mostly Windows) libraries.
1653 (for-each delete-file
1654 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1655 ;; Use the packaged nghttp2.
1656 (for-each
1657 (lambda (ver)
1658 (let ((vendored-dir
1659 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1660 (build-rs
1661 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1662 (delete-file-recursively vendored-dir)
1663 (delete-file build-rs)
1664 (call-with-output-file build-rs
1665 (lambda (port)
1666 (format port "fn main() {~@
1667 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1668 }~%")))))
1669 '("0.1.11+1.64.0"))
1670 ;; Adjust vendored dependency to explicitly use rustix with libc
1671 ;; backend.
1672 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1673 "vendor/tempfile-3.16.0/Cargo.toml"
1674 "vendor/tempfile-3.19.1/Cargo.toml"
1675 "vendor/tempfile-3.20.0/Cargo.toml"
1676 "vendor/tempfile-3.21.0/Cargo.toml")
1677 (("features = \\[\"fs\"" all)
1678 (string-append all ", \"use-libc\"")))))))
1679 (arguments
1680 (substitute-keyword-arguments (package-arguments base-rust)
1681 ((#:phases phases)
1682 `(modify-phases ,phases
1683 ;; Adjust the stack size so we don't error out on some machines.
1684 #;
1685 (add-before 'build 'set-stack-size
1686 (lambda _
1687 (setenv "RUST_MIN_STACK" "16777216")))
1688 (replace 'install
1689 ;; Rust 1.91+ outputs to stage2 instead of stage1.
1690 ;; Cannot use './x.py install' as it runs generate-copyright
1691 ;; which fails due to patched cargo checksums.
1692 (lambda* (#:key outputs #:allow-other-keys)
1693 (let* ((out (assoc-ref outputs "out"))
1694 (cargo-out (assoc-ref outputs "cargo"))
1695 (build (string-append "build/"
1696 ,(platform-rust-target
1697 (lookup-platform-by-target-or-system
1698 (or (%current-target-system)
1699 (%current-system)))))))
1700 (with-directory-excursion build
1701 (install-file "stage2/bin/rustc"
1702 (string-append out "/bin"))
1703 (install-file "stage2-tools-bin/cargo"
1704 (string-append cargo-out "/bin"))
1705 (for-each delete-file
1706 (find-files "stage2/lib" "\\.rmeta$"))
1707 (for-each delete-file
1708 (find-files "stage2/lib/rustlib"
1709 "^librustc_driver.*\\.so$"))
1710 (copy-recursively "stage2/lib"
1711 (string-append out "/lib")))))))))))))
1712
1713(define-public rust-1.92
1714 (let ((base-rust
1715 (rust-bootstrapped-package
1716 rust-1.91 "1.92.0"
1717 "1f6305lkp4vwj132fq232mfxdcxg0d5vymc2fpf5y9vybjkjq3cy")))
1718 (package
1719 (inherit base-rust)
1720 (source
1721 (origin
1722 (inherit (package-source base-rust))
1723 (snippet
1724 '(begin
1725 (for-each delete-file-recursively
1726 '("src/llvm-project"
1727 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1728 "vendor/curl-sys-0.4.83+curl-8.15.0/curl"
1729 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1730 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1731 "vendor/libffi-sys-4.0.0/libffi"
1732 "vendor/libz-sys-1.1.21/src/zlib"
1733 "vendor/libz-sys-1.1.22/src/zlib"
1734 "vendor/libmimalloc-sys-0.1.44/c_src/mimalloc"
1735 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1736 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1737 "vendor/openssl-src-300.5.3+3.5.4/openssl"
1738 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1739 "vendor/tikv-jemalloc-sys-0.6.0+5.3.0-1-\
1740ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1741 ;; Remove vendored dynamically linked libraries.
1742 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1743 ;; Also remove the bundled (mostly Windows) libraries.
1744 (for-each delete-file
1745 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1746 ;; Use the packaged nghttp2.
1747 (for-each
1748 (lambda (ver)
1749 (let ((vendored-dir
1750 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1751 (build-rs
1752 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1753 (delete-file-recursively vendored-dir)
1754 (delete-file build-rs)
1755 (call-with-output-file build-rs
1756 (lambda (port)
1757 (format port "fn main() {~@
1758 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1759 }~%")))))
1760 '("0.1.11+1.64.0"))
1761 ;; Adjust vendored dependency to explicitly use rustix with libc
1762 ;; backend.
1763 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1764 "vendor/tempfile-3.16.0/Cargo.toml"
1765 "vendor/tempfile-3.19.1/Cargo.toml"
1766 "vendor/tempfile-3.20.0/Cargo.toml"
1767 "vendor/tempfile-3.21.0/Cargo.toml"
1768 "vendor/tempfile-3.23.0/Cargo.toml")
1769 (("features = \\[\"fs\"" all)
1770 (string-append all ", \"use-libc\""))))))))))
1771
1772(define-public rust-1.93
1773 (let ((base-rust
1774 (rust-bootstrapped-package
1775 rust-1.92 "1.93.0"
1776 "01d7a1mvyvqmq9khyw5cbnwyngzgb4pxpdwhqgzl669j7kc2n4b9")))
1777 (package
1778 (inherit base-rust)
1779 (source
1780 (origin
1781 (inherit (package-source base-rust))
1782 (snippet
1783 '(begin
1784 (for-each delete-file-recursively
1785 '("src/llvm-project"
1786 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1787 "vendor/curl-sys-0.4.83+curl-8.15.0/curl"
1788 "vendor/curl-sys-0.4.84+curl-8.17.0/curl"
1789 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1790 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1791 "vendor/libffi-sys-4.0.0/libffi"
1792 "vendor/libz-sys-1.1.21/src/zlib"
1793 "vendor/libz-sys-1.1.23/src/zlib"
1794 "vendor/libmimalloc-sys-0.1.44/c_src/mimalloc"
1795 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1796 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1797 "vendor/openssl-src-300.5.4+3.5.4/openssl"
1798 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1799 "vendor/tikv-jemalloc-sys-0.6.1+5.3.0-1-\
1800ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1801 ;; Remove vendored dynamically linked libraries.
1802 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1803 ;; Also remove the bundled (mostly Windows) libraries.
1804 (for-each delete-file
1805 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1806 ;; Use the packaged nghttp2.
1807 (for-each
1808 (lambda (ver)
1809 (let ((vendored-dir
1810 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1811 (build-rs
1812 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1813 (delete-file-recursively vendored-dir)
1814 (delete-file build-rs)
1815 (call-with-output-file build-rs
1816 (lambda (port)
1817 (format port "fn main() {~@
1818 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1819 }~%")))))
1820 '("0.1.11+1.64.0"))
1821 ;; Adjust vendored dependency to explicitly use rustix with libc
1822 ;; backend.
1823 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1824 "vendor/tempfile-3.16.0/Cargo.toml"
1825 "vendor/tempfile-3.19.1/Cargo.toml"
1826 "vendor/tempfile-3.20.0/Cargo.toml"
1827 "vendor/tempfile-3.21.0/Cargo.toml"
1828 "vendor/tempfile-3.23.0/Cargo.toml")
1829 (("features = \\[\"fs\"" all)
1830 (string-append all ", \"use-libc\""))))))))))
1831
1832(define-public rust-1.94
1833 (let ((base-rust
1834 (rust-bootstrapped-package
1835 rust-1.93 "1.94.1"
1836 "056mbblkhn5ig62v09r6938qmnb09ygy32n62vvwvqqjbxi2l52c")))
1837 (package
1838 (inherit base-rust)
1839 (source
1840 (origin
1841 (inherit (package-source base-rust))
1842 (patches (search-patches
1843 "rust-1.94-clippy-fix-proc-macros-aux-race.patch"))
1844 (snippet
1845 '(begin
1846 (for-each delete-file-recursively
1847 '("src/llvm-project"
1848 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1849 "vendor/curl-sys-0.4.84+curl-8.17.0/curl"
1850 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1851 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1852 "vendor/libffi-sys-4.1.0/libffi"
1853 "vendor/libz-sys-1.1.21/src/zlib"
1854 "vendor/libz-sys-1.1.23/src/zlib"
1855 "vendor/libmimalloc-sys-0.1.44/c_src/mimalloc"
1856 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1857 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1858 "vendor/openssl-src-300.5.4+3.5.4/openssl"
1859 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1860 "vendor/tikv-jemalloc-sys-0.6.1+5.3.0-1-\
1861ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1862 ;; Remove vendored dynamically linked libraries.
1863 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1864 ;; Also remove the bundled (mostly Windows) libraries.
1865 (for-each delete-file
1866 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1867 ;; Use the packaged nghttp2.
1868 (for-each
1869 (lambda (ver)
1870 (let ((vendored-dir
1871 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1872 (build-rs
1873 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1874 (delete-file-recursively vendored-dir)
1875 (delete-file build-rs)
1876 (call-with-output-file build-rs
1877 (lambda (port)
1878 (format port "fn main() {~@
1879 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1880 }~%")))))
1881 '("0.1.11+1.64.0"))
1882 ;; Adjust vendored dependency to explicitly use rustix with libc
1883 ;; backend.
1884 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1885 "vendor/tempfile-3.16.0/Cargo.toml"
1886 "vendor/tempfile-3.19.1/Cargo.toml"
1887 "vendor/tempfile-3.20.0/Cargo.toml"
1888 "vendor/tempfile-3.21.0/Cargo.toml"
1889 "vendor/tempfile-3.23.0/Cargo.toml"
1890 "vendor/tempfile-3.24.0/Cargo.toml")
1891 (("features = \\[\"fs\"" all)
1892 (string-append all ", \"use-libc\"")))))))
1893 (arguments
1894 (substitute-keyword-arguments (package-arguments base-rust)
1895 ((#:phases phases)
1896 `(modify-phases ,phases
1897 (replace 'install
1898 ;; Cannot use './x.py install' as it runs generate-copyright
1899 ;; which fails due to patched cargo checksums.
1900 ;; In this version we don't delete the .rmeta files; they are
1901 ;; now needed in order to build the next rust version.
1902 (lambda* (#:key outputs #:allow-other-keys)
1903 (let* ((out (assoc-ref outputs "out"))
1904 (cargo-out (assoc-ref outputs "cargo"))
1905 (build (string-append "build/"
1906 ,(platform-rust-target
1907 (lookup-platform-by-target-or-system
1908 (or (%current-target-system)
1909 (%current-system)))))))
1910 (with-directory-excursion build
1911 (install-file "stage2/bin/rustc"
1912 (string-append out "/bin"))
1913 (install-file "stage2-tools-bin/cargo"
1914 (string-append cargo-out "/bin"))
1915 (for-each delete-file
1916 (find-files "stage2/lib/rustlib"
1917 "^librustc_driver.*\\.so$"))
1918 (copy-recursively "stage2/lib"
1919 (string-append out "/lib")))))))))))))
1920
1921(define-public rust-1.95
1922 (let ((base-rust
1923 (rust-bootstrapped-package
1924 rust-1.94 "1.95.0"
1925 "05d53hj717ildhvm3rln7821r08nzbbfk72nqcvpb5j67sl856za")))
1926 (package
1927 (inherit base-rust)
1928 (source
1929 (origin
1930 (inherit (package-source base-rust))
1931 (snippet
1932 '(begin
1933 (for-each delete-file-recursively
1934 '("src/llvm-project"
1935 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1936 "vendor/curl-sys-0.4.83+curl-8.15.0/curl"
1937 "vendor/curl-sys-0.4.84+curl-8.17.0/curl"
1938 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
1939 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1940 "vendor/libffi-sys-4.1.0/libffi"
1941 "vendor/libmimalloc-sys-0.1.44/c_src/mimalloc"
1942 "vendor/libz-sys-1.1.21/src/zlib"
1943 "vendor/libz-sys-1.1.23/src/zlib"
1944 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
1945 "vendor/openssl-src-300.5.0+3.5.0/openssl"
1946 "vendor/openssl-src-300.5.4+3.5.4/openssl"
1947 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
1948 "vendor/tikv-jemalloc-sys-0.6.1+5.3.0-1-\
1949ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
1950 ;; Remove vendored dynamically linked libraries.
1951 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
1952 ;; Also remove the bundled (mostly Windows) libraries.
1953 (for-each delete-file
1954 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
1955 ;; Use the packaged nghttp2.
1956 (for-each
1957 (lambda (ver)
1958 (let ((vendored-dir
1959 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
1960 (build-rs
1961 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
1962 (delete-file-recursively vendored-dir)
1963 (delete-file build-rs)
1964 (call-with-output-file build-rs
1965 (lambda (port)
1966 (format port "fn main() {~@
1967 println!(\"cargo:rustc-link-lib=nghttp2\");~@
1968 }~%")))))
1969 '("0.1.11+1.64.0"))
1970 ;; Adjust vendored dependency to explicitly use rustix with libc
1971 ;; backend.
1972 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
1973 "vendor/tempfile-3.16.0/Cargo.toml"
1974 "vendor/tempfile-3.19.1/Cargo.toml"
1975 "vendor/tempfile-3.20.0/Cargo.toml"
1976 "vendor/tempfile-3.21.0/Cargo.toml"
1977 "vendor/tempfile-3.23.0/Cargo.toml"
1978 "vendor/tempfile-3.24.0/Cargo.toml")
1979 (("features = \\[\"fs\"" all)
1980 (string-append all ", \"use-libc\""))))))))))
1981
1982(define-public rust-1.96
1983 (let ((base-rust
1984 (rust-bootstrapped-package
1985 rust-1.95 "1.96.0"
1986 "0i1v0i878zviwxz3hr18dxq7dqv4ggbykns0r3x8m55jafqrw2p9")))
1987 (package
1988 (inherit base-rust)
1989 (source
1990 (origin
1991 (inherit (package-source base-rust))
1992 (snippet
1993 '(begin
1994 (for-each delete-file-recursively
1995 '("src/llvm-project"
1996 "vendor/curl-sys-0.4.79+curl-8.12.0/curl"
1997 "vendor/curl-sys-0.4.84+curl-8.17.0/curl"
1998 "vendor/curl-sys-0.4.87+curl-8.19.0/curl"
1999 "vendor/jemalloc-sys-0.5.3+5.3.0-patched/jemalloc"
2000 "vendor/jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
2001 "vendor/libffi-sys-4.1.0/libffi"
2002 "vendor/libmimalloc-sys-0.1.44/c_src/mimalloc"
2003 "vendor/libz-sys-1.1.21/src/zlib"
2004 "vendor/libz-sys-1.1.23/src/zlib"
2005 "vendor/libz-sys-1.1.24/src/zlib"
2006 "vendor/openssl-src-111.28.2+1.1.1w/openssl"
2007 "vendor/openssl-src-300.5.0+3.5.0/openssl"
2008 "vendor/openssl-src-300.5.4+3.5.4/openssl"
2009 "vendor/tikv-jemalloc-sys-0.5.4+5.3.0-patched/jemalloc"
2010 "vendor/tikv-jemalloc-sys-0.6.1+5.3.0-1-\
2011ge13ca993e8ccb9ba9847cc330696e02839f328f7/jemalloc"))
2012 ;; Remove vendored dynamically linked libraries.
2013 ;; find . -not -type d -executable -exec file {} \+ | grep ELF
2014 ;; Also remove the bundled (mostly Windows) libraries.
2015 (for-each delete-file
2016 (find-files "vendor" "\\.(a|dll|exe|lib)$"))
2017 ;; Use the packaged nghttp2.
2018 (for-each
2019 (lambda (ver)
2020 (let ((vendored-dir
2021 (format #f "vendor/libnghttp2-sys-~a/nghttp2" ver))
2022 (build-rs
2023 (format #f "vendor/libnghttp2-sys-~a/build.rs" ver)))
2024 (delete-file-recursively vendored-dir)
2025 (delete-file build-rs)
2026 (call-with-output-file build-rs
2027 (lambda (port)
2028 (format port "fn main() {~@
2029 println!(\"cargo:rustc-link-lib=nghttp2\");~@
2030 }~%")))))
2031 '("0.1.11+1.64.0"
2032 "0.1.13+1.68.1"))
2033 ;; Adjust vendored dependency to explicitly use rustix with libc
2034 ;; backend.
2035 (substitute* '("vendor/tempfile-3.14.0/Cargo.toml"
2036 "vendor/tempfile-3.16.0/Cargo.toml"
2037 "vendor/tempfile-3.19.1/Cargo.toml"
2038 "vendor/tempfile-3.20.0/Cargo.toml"
2039 "vendor/tempfile-3.21.0/Cargo.toml"
2040 "vendor/tempfile-3.23.0/Cargo.toml"
2041 "vendor/tempfile-3.27.0/Cargo.toml")
2042 (("features = \\[\"fs\"" all)
2043 (string-append all ", \"use-libc\""))))))))))
2044
2045(define (make-ignore-test-list strs)
2046 "Function to make creating a list to ignore tests a bit easier."
2047 (map (lambda (str)
2048 `((,str) (string-append "#[ignore]\n" ,str)))
2049 strs))
2050
2051;;; Note: Only the latest version of Rust is supported and tested. The
2052;;; intermediate rusts are built for bootstrapping purposes and should not
2053;;; be relied upon. This is to ease maintenance and reduce the time
2054;;; required to build the full Rust bootstrap chain.
2055;;;
2056;;; Here we take the latest included Rust, make it public, and re-enable tests
2057;;; and extra components such as rustfmt.
2058(define-public rust
2059 (let ((base-rust rust-1.93))
2060 (package
2061 (inherit base-rust)
2062 (properties (append
2063 (alist-delete 'hidden? (package-properties base-rust))
2064 ;; Keep in sync with the llvm used to build rust.
2065 (clang-compiler-cpu-architectures "21")))
2066 (outputs (cons* "rust-src" "tools" (package-outputs base-rust)))
2067 (arguments
2068 (substitute-keyword-arguments
2069 (strip-keyword-arguments '(#:tests?)
2070 (package-arguments base-rust))
2071 ((#:disallowed-references _ '())
2072 (list (this-package-native-input "rustc-bootstrap")
2073 ;; Refer to cargo-bootstrap as #$rustc-bootstrap:cargo.
2074 (gexp-input (this-package-native-input "rustc-bootstrap")
2075 "cargo")))
2076 ((#:modules modules)
2077 (cons '(srfi srfi-26) modules))
2078 ((#:phases phases)
2079 `(modify-phases ,phases
2080 (add-after 'unpack 'disable-tests-requiring-git
2081 (lambda _
2082 (substitute* "src/tools/cargo/tests/testsuite/publish_lockfile.rs"
2083 ,@(make-ignore-test-list
2084 '("fn note_resolve_changes")))))
2085 (add-after 'unpack 'disable-tests-using-cargo-publish
2086 (lambda _
2087 (substitute* "src/tools/cargo/tests/testsuite/install.rs"
2088 ,@(make-ignore-test-list
2089 '("fn failed_install_retains_temp_directory")))))
2090 ,@(if (target-riscv64?)
2091 ;; Keep this phase separate so it can be adjusted without needing
2092 ;; to adjust the skipped tests on other architectures.
2093 `((add-after 'unpack 'disable-tests-broken-on-riscv64
2094 (lambda _
2095 (with-directory-excursion "src/tools/cargo/tests/testsuite"
2096 (substitute* "build.rs"
2097 ,@(make-ignore-test-list
2098 '("fn uplift_dwp_of_bin_on_linux")))
2099 (substitute* "cache_lock.rs"
2100 ,@(make-ignore-test-list
2101 '("fn multiple_shared"
2102 "fn multiple_download"
2103 "fn download_then_mutate"
2104 "fn mutate_err_is_atomic")))
2105 (substitute* "global_cache_tracker.rs"
2106 ,@(make-ignore-test-list
2107 '("fn package_cache_lock_during_build"))))
2108 (with-directory-excursion "src/tools/clippy/tests"
2109 ;; `"vectorcall"` is not a supported ABI for the current target
2110 (delete-file "ui/missing_const_for_fn/could_be_const.rs")
2111 (substitute* "missing-test-files.rs"
2112 ,@(make-ignore-test-list
2113 '("fn test_missing_tests")))))))
2114 `())
2115 (add-after 'unpack 'skip-unupdated-clippy-tests
2116 (lambda _
2117 (with-directory-excursion "src/tools/clippy/tests/ui"
2118 (delete-file "cognitive_complexity.rs")
2119 (delete-file "cognitive_complexity.stderr"))))
2120 (add-after 'unpack 'disable-tests-requiring-network-access
2121 (lambda _
2122 (substitute* "src/tools/cargo/tests/testsuite/git_auth.rs"
2123 ,@(make-ignore-test-list
2124 '("fn net_err_suggests_fetch_with_cli")))
2125 (substitute* "src/tools/cargo/tests/testsuite/package.rs"
2126 ,@(make-ignore-test-list
2127 '("fn publish_to_crates_io_warns")))))
2128 (add-after 'unpack 'patch-process-tests
2129 (lambda* (#:key inputs #:allow-other-keys)
2130 (let ((bash (assoc-ref inputs "bash")))
2131 (with-directory-excursion "library/std/src"
2132 (substitute* "process/tests.rs"
2133 (("\"/bin/sh\"")
2134 (string-append "\"" bash "/bin/sh\"")))
2135 ;; The three tests which are known to fail upstream on QEMU
2136 ;; emulation on aarch64 and riscv64 also fail on x86_64 in
2137 ;; Guix's build system. Skip them on all builds.
2138 (substitute* "sys/process/unix/common/tests.rs"
2139 ;; We can't use make-ignore-test-list because we will get
2140 ;; build errors due to the double [ignore] block.
2141 (("target_arch = \"arm\"" arm)
2142 (string-append "target_os = \"linux\",\n"
2143 " " arm)))))))
2144 (add-after 'unpack 'disable-interrupt-tests
2145 (lambda _
2146 ;; This test hangs in the build container; disable it.
2147 (substitute* "src/tools/cargo/tests/testsuite/freshness.rs"
2148 ,@(make-ignore-test-list
2149 '("fn linking_interrupted")))
2150 ;; Likewise for the ctrl_c_kills_everyone test.
2151 (substitute* "src/tools/cargo/tests/testsuite/death.rs"
2152 ,@(make-ignore-test-list
2153 '("fn ctrl_c_kills_everyone")))))
2154 (add-after 'unpack 'patch-cargo-test-compat-curl-8.18
2155 (lambda _
2156 ;; Fix compatibility with curl 8.18 and above:
2157 ;; https://github.com/rust-lang/cargo/pull/16698
2158 ;; TODO: remove on Rust 1.96.
2159 (substitute* '("src/tools/cargo/tests/testsuite/artifact_dep.rs"
2160 "src/tools/cargo/tests/testsuite/vendor.rs")
2161 (("Couldn't") "Could[..]t"))))
2162 (add-after 'unpack 'adjust-rpath-values
2163 ;; This adds %output:out to rpath, allowing us to install utilities in
2164 ;; different outputs while reusing the shared libraries.
2165 (lambda* (#:key outputs #:allow-other-keys)
2166 (let ((out (assoc-ref outputs "out")))
2167 (substitute* "src/bootstrap/src/core/builder/cargo.rs"
2168 ((" = rpath.*" all)
2169 (string-append all
2170 " "
2171 "self.rustflags.arg(\"-Clink-args=-Wl,-rpath="
2172 out "/lib\");\n"))))))
2173 (add-after 'unpack 'unpack-profiler-rt
2174 ;; Copy compiler-rt sources to where libprofiler_builtins looks
2175 ;; for its vendored copy.
2176 (lambda* (#:key inputs #:allow-other-keys)
2177 (mkdir-p "src/llvm-project/compiler-rt")
2178 (copy-recursively
2179 (string-append (assoc-ref inputs "clang-source")
2180 "/compiler-rt")
2181 "src/llvm-project/compiler-rt")))
2182 (add-after 'unpack 'unpack-libunwind
2183 (lambda* (#:key inputs #:allow-other-keys)
2184 (mkdir-p "src/llvm-project/libunwind")
2185 (copy-recursively
2186 (string-append (assoc-ref inputs "clang-source")
2187 "/libunwind")
2188 "src/llvm-project/libunwind")))
2189 (replace 'patch-cargo-checksums
2190 (lambda _
2191 (substitute*
2192 (append '("Cargo.lock"
2193 "src/bootstrap/Cargo.lock")
2194 (find-files "compiler" "Cargo.lock")
2195 (find-files "library" "Cargo.lock")
2196 (find-files "src/doc" "Cargo.lock")
2197 (remove
2198 ;; Don't mess with the lock files in the Cargo
2199 ;; testsuite; it messes up the tests.
2200 (cut string-contains <>
2201 "cargo/tests/testsuite")
2202 (find-files "src/tools" "Cargo.lock")))
2203 (("(checksum = )\".*\"" all name)
2204 (string-append name "\"" ,%cargo-reference-hash "\"")))
2205 (generate-all-checksums "vendor")))
2206 (add-after 'configure 'enable-profiling
2207 (lambda _
2208 (substitute* "config.toml"
2209 (("^profiler =.*$") "")
2210 (("\\[build\\]") "\n[build]\nprofiler = true\n"))))
2211 (add-after 'configure 'add-gdb-to-config
2212 (lambda* (#:key inputs #:allow-other-keys)
2213 (let ((gdb (assoc-ref inputs "gdb")))
2214 (substitute* "config.toml"
2215 (("^python =.*" all)
2216 (string-append all
2217 "gdb = \"" gdb "/bin/gdb\"\n"))))))
2218 (replace 'build
2219 ;; Phase overridden to also build more tools.
2220 (lambda* (#:key parallel-build? #:allow-other-keys)
2221 (let ((job-spec (string-append
2222 "-j" (if parallel-build?
2223 (number->string (parallel-job-count))
2224 "1"))))
2225 (invoke "./x.py" job-spec "build"
2226 "library/std" ;rustc
2227 "src/tools/cargo"
2228 "src/tools/clippy"
2229 "src/tools/rust-analyzer"
2230 "src/tools/rustfmt"))))
2231 (replace 'check
2232 ;; Phase overridden to also test more tools.
2233 (lambda* (#:key tests? parallel-build? #:allow-other-keys)
2234 (when tests?
2235 (let ((job-spec (string-append
2236 "-j" (if parallel-build?
2237 (number->string (parallel-job-count))
2238 "1"))))
2239 (invoke "./x.py" job-spec "test" "-vv"
2240 "library/std"
2241 "src/tools/cargo"
2242 "src/tools/clippy"
2243 "src/tools/rust-analyzer"
2244 "src/tools/rustfmt")))))
2245 (replace 'install
2246 ;; Phase overridden to also install more tools.
2247 (lambda* (#:key outputs #:allow-other-keys)
2248 (invoke "./x.py" "install")
2249 (substitute* "config.toml"
2250 ;; Adjust the prefix to the 'cargo' output.
2251 (("prefix = \"[^\"]*\"")
2252 (format #f "prefix = ~s" (assoc-ref outputs "cargo"))))
2253 (invoke "./x.py" "install" "cargo")
2254 (substitute* "config.toml"
2255 ;; Adjust the prefix to the 'tools' output.
2256 (("prefix = \"[^\"]*\"")
2257 (format #f "prefix = ~s" (assoc-ref outputs "tools"))))
2258 (invoke "./x.py" "install" "clippy")
2259 (invoke "./x.py" "install" "rust-analyzer")
2260 (invoke "./x.py" "install" "rustfmt")))
2261 (add-before 'patch-cargo-checksums 'save-old-library-manifest
2262 (lambda _
2263 (copy-file "library/Cargo.lock" ".old-library-manifest")))
2264 (add-after 'install 'install-rust-src
2265 (lambda* (#:key outputs #:allow-other-keys)
2266 (let ((out (assoc-ref outputs "rust-src"))
2267 (dest "/lib/rustlib/src/rust"))
2268 (mkdir-p (string-append out dest))
2269 (copy-recursively "library" (string-append out dest "/library"))
2270 ;; rust-analyzer needs the original checksums; otherwise
2271 ;; it fails to cargo manifest in the stdlib, and then
2272 ;; analysis/inference involving stdlib structs doesn't work.
2273 ;;
2274 ;; For example, in the following trivial program:
2275 ;;
2276 ;; fn main() {
2277 ;; let x = Vec::<usize>::new();
2278 ;; }
2279 ;;
2280 ;; rust-analyzer since version 1.82 can't infer
2281 ;; the type of x unless the following line is present.
2282 (copy-file ".old-library-manifest"
2283 (string-append out dest "/library/Cargo.lock"))
2284 (copy-recursively "src" (string-append out dest "/src")))))
2285 (add-before 'install 'remove-uninstall-script
2286 (lambda _
2287 ;; Don't install the uninstall script. It has no use
2288 ;; on Guix and it retains a reference to the host's bash.
2289 (substitute* "src/tools/rust-installer/install-template.sh"
2290 (("install_uninstaller \"") "# install_uninstaller \""))))
2291 (add-after 'install-rust-src 'dont-reference-previous-cargo-version
2292 (lambda* (#:key outputs #:allow-other-keys)
2293 (with-directory-excursion
2294 (string-append (assoc-ref outputs "rust-src")
2295 "/lib/rustlib/src/rust/src/tools/")
2296 (substitute* (find-files "." "\\.rs$")
2297 (("#!.*/bin/cargo")
2298 (string-append "#!" (assoc-ref outputs "cargo")
2299 "/bin/cargo"))))))
2300 (add-after 'install-rust-src 'wrap-rust-analyzer
2301 (lambda* (#:key outputs #:allow-other-keys)
2302 (let ((bin (string-append (assoc-ref outputs "tools") "/bin")))
2303 (rename-file (string-append bin "/rust-analyzer")
2304 (string-append bin "/.rust-analyzer-real"))
2305 (call-with-output-file (string-append bin "/rust-analyzer")
2306 (lambda (port)
2307 (format port "#!~a
2308if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi;
2309exec -a \"$0\" \"~a\" \"$@\""
2310 (which "bash")
2311 (string-append (assoc-ref outputs "rust-src")
2312 "/lib/rustlib/src/rust/library")
2313 (string-append bin "/.rust-analyzer-real"))))
2314 (chmod (string-append bin "/rust-analyzer") #o755))))))))
2315 (native-inputs (cons*
2316 ;; Keep in sync with the llvm used to build rust.
2317 `("clang-source" ,(package-source clang-runtime-21))
2318 ;; Add test inputs.
2319 `("gdb" ,gdb/pinned)
2320 `("git-minimal" ,git-minimal/pinned)
2321 `("procps" ,procps)
2322 (package-native-inputs base-rust)))
2323 (native-search-paths
2324 (cons*
2325 ;; For HTTPS access, Cargo reads from a single-file certificate
2326 ;; specified with $CARGO_HTTP_CAINFO. See
2327 ;; https://doc.rust-lang.org/cargo/reference/environment-variables.html
2328 (search-path-specification
2329 (variable "CARGO_HTTP_CAINFO")
2330 (file-type 'regular)
2331 (separator #f) ;single entry
2332 (files '("etc/ssl/certs/ca-certificates.crt")))
2333 ;; Make the sources discoverable not just when wrapped.
2334 (search-path-specification
2335 (variable "RUST_SRC_PATH")
2336 (separator #f) ;single entry
2337 (files '("lib/rustlib/src/rust/library")))
2338 ;; rustc invokes gcc, so we need to set its search paths accordingly.
2339 %gcc-search-paths)))))
2340
2341(define*-public (make-rust-sysroot target)
2342 (make-rust-sysroot/implementation target rust))
2343
2344(define make-rust-sysroot/implementation
2345 (mlambda (target base-rust)
2346 (unless (platform-rust-target (lookup-platform-by-target target))
2347 (raise
2348 (condition
2349 (&package-unsupported-target-error
2350 (package base-rust)
2351 (target target)))))
2352
2353 (package
2354 (inherit base-rust)
2355 (name (string-append "rust-sysroot-for-" target))
2356 (outputs '("out"))
2357 (arguments
2358 (substitute-keyword-arguments (package-arguments base-rust)
2359 ((#:tests? _ #f) #f) ; This package for cross-building.
2360 ((#:phases phases)
2361 #~(modify-phases #$phases
2362 (add-after 'unpack 'unbundle-xz
2363 (lambda _
2364 (delete-file-recursively "vendor/lzma-sys-0.1.20/xz-5.2")
2365 ;; Remove the option of using the static library.
2366 ;; This is necessary for building the sysroot.
2367 (substitute* "vendor/lzma-sys-0.1.20/build.rs"
2368 (("!want_static && ") ""))))
2369 #$@(if (target-mingw? target)
2370 `((add-after 'set-env 'patch-for-mingw
2371 (lambda* (#:key inputs #:allow-other-keys)
2372 (let* ((arch ,(string-take target
2373 (string-index target #\-)))
2374 (mingw (assoc-ref inputs
2375 (string-append "mingw-w64-" arch
2376 "-winpthreads"))))
2377 (setenv "LIBRARY_PATH"
2378 (string-join
2379 (delete
2380 (string-append mingw "/lib")
2381 (string-split (getenv "LIBRARY_PATH") #\:))
2382 ":"))
2383 (setenv "CPLUS_INCLUDE_PATH"
2384 (string-join
2385 (delete
2386 (string-append mingw "/include")
2387 (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))
2388 ":"))))))
2389 `())
2390 (replace 'set-env
2391 (lambda* (#:key inputs #:allow-other-keys)
2392 (setenv "SHELL" (which "sh"))
2393 (setenv "CONFIG_SHELL" (which "sh"))
2394 (setenv "CC" (which "gcc"))
2395 ;; The Guix LLVM package installs only shared libraries.
2396 (setenv "LLVM_LINK_SHARED" "1")
2397
2398 (setenv "CROSS_LIBRARY_PATH" (getenv "LIBRARY_PATH"))
2399 (setenv "CROSS_CPLUS_INCLUDE_PATH" (getenv "CPLUS_INCLUDE_PATH"))
2400 (when (assoc-ref inputs (string-append "glibc-cross-" #$target))
2401 (setenv "LIBRARY_PATH"
2402 (string-join
2403 (delete
2404 (string-append
2405 (assoc-ref inputs
2406 (string-append "glibc-cross-" #$target))
2407 "/lib")
2408 (string-split (getenv "LIBRARY_PATH") #\:))
2409 ":"))
2410 (setenv "CPLUS_INCLUDE_PATH"
2411 (string-join
2412 (delete
2413 (string-append
2414 (assoc-ref inputs
2415 (string-append "glibc-cross-" #$target))
2416 "/include")
2417 (string-split (getenv "CPLUS_INCLUDE_PATH") #\:))
2418 ":")))))
2419 (replace 'configure
2420 (lambda* (#:key inputs outputs #:allow-other-keys)
2421 (let* ((out (assoc-ref outputs "out"))
2422 (target-cc
2423 (search-input-file
2424 inputs (string-append "/bin/" #$(cc-for-target target)))))
2425 (call-with-output-file "config.toml"
2426 (lambda (port)
2427 (display (string-append "
2428[llvm]
2429[build]
2430cargo = \"" (search-input-file inputs "/bin/cargo") "\"
2431rustc = \"" (search-input-file inputs "/bin/rustc") "\"
2432docs = false
2433python = \"" (which "python") "\"
2434vendor = true
2435submodules = false
2436target = [\"" #$(platform-rust-target (lookup-platform-by-target target)) "\"]
2437[install]
2438prefix = \"" out "\"
2439sysconfdir = \"etc\"
2440[rust]
2441debug = false
2442jemalloc = false
2443default-linker = \"" target-cc "\"
2444channel = \"stable\"
2445[target." #$(platform-rust-target (lookup-platform-by-system (%current-system))) "]
2446# These are all native tools
2447llvm-config = \"" (search-input-file inputs "/bin/llvm-config") "\"
2448linker = \"" (which "gcc") "\"
2449cc = \"" (which "gcc") "\"
2450cxx = \"" (which "g++") "\"
2451ar = \"" (which "ar") "\"
2452[target." #$(platform-rust-target (lookup-platform-by-target target)) "]
2453llvm-config = \"" (search-input-file inputs "/bin/llvm-config") "\"
2454linker = \"" target-cc "\"
2455cc = \"" target-cc "\"
2456cxx = \"" (search-input-file inputs (string-append "/bin/" #$(cxx-for-target target))) "\"
2457ar = \"" (search-input-file inputs (string-append "/bin/" #$(ar-for-target target))) "\"
2458[dist]
2459") port))))))
2460 (replace 'build
2461 ;; Phase overridden to build the necessary directories.
2462 (lambda* (#:key parallel-build? #:allow-other-keys)
2463 (let ((job-spec (string-append
2464 "-j" (if parallel-build?
2465 (number->string (parallel-job-count))
2466 "1"))))
2467 ;; This works for us with the --sysroot flag
2468 ;; and then we can build ONLY library/std
2469 (invoke "./x.py" job-spec "build" "library/std"))))
2470 (replace 'install
2471 (lambda _
2472 (invoke "./x.py" "install" "library/std")))
2473 (delete 'enable-profiling)
2474 (delete 'install-rust-src)
2475 (delete 'dont-reference-previous-cargo-version)
2476 (delete 'wrap-rust-analyzer)
2477 (delete 'wrap-rustc)))))
2478 (inputs
2479 (modify-inputs inputs
2480 (prepend xz))) ; for lzma-sys
2481 (propagated-inputs
2482 (if (target-mingw? target)
2483 (modify-inputs propagated-inputs
2484 (prepend
2485 (make-mingw-w64
2486 (string-take target (string-index target #\-))
2487 #:with-winpthreads? #t)))
2488 (package-propagated-inputs base-rust)))
2489 (native-inputs
2490 (modify-inputs native-inputs
2491 (prepend (cross-gcc target
2492 #:libc (cross-libc target)))
2493 (prepend (if (target-mingw? target)
2494 (make-mingw-w64
2495 (string-take target (string-index target #\-))
2496 #:with-winpthreads? #t)
2497 (cross-libc target)))
2498 (prepend (cross-binutils target))))
2499 (properties
2500 `((hidden? . #t) ,(package-properties base-rust))))))
2501
2502(define-public rust-sysroot-for-wasm32-unknown-unknown
2503 (package
2504 (inherit (make-rust-sysroot "i686-linux-gnu"))
2505 (name "rust-sysroot-for-wasm32-unknown-unknown")
2506 (arguments
2507 (substitute-keyword-arguments arguments
2508 ((#:phases phases)
2509 #~(modify-phases #$phases
2510 (replace 'set-env
2511 (lambda _
2512 (setenv "SHELL" (which "sh"))
2513 (setenv "CONFIG_SHELL" (which "sh"))
2514 (setenv "CC" (which "clang"))
2515 ;; The Guix LLVM package installs only shared libraries.
2516 (setenv "LLVM_LINK_SHARED" "1")))
2517 (replace 'configure
2518 (lambda* (#:key inputs outputs #:allow-other-keys)
2519 (call-with-output-file "config.toml"
2520 (lambda (port)
2521 (display (string-append "
2522[llvm]
2523[build]
2524cargo = \"" (search-input-file inputs "/bin/cargo") "\"
2525rustc = \"" (search-input-file inputs "/bin/rustc") "\"
2526docs = false
2527python = \"" (which "python") "\"
2528vendor = true
2529submodules = false
2530target = [\"wasm32-unknown-unknown\"]
2531[install]
2532prefix = \"" (assoc-ref outputs "out") "\"
2533sysconfdir = \"etc\"
2534[rust]
2535debug = false
2536jemalloc = false
2537default-linker = \"lld\"
2538channel = \"stable\"
2539[target." #$(platform-rust-target (lookup-platform-by-system (%current-system))) "]
2540# These are all native tools
2541llvm-config = \"" (search-input-file inputs "/bin/llvm-config") "\"
2542linker = \"" (which "gcc") "\"
2543cc = \"" (which "gcc") "\"
2544cxx = \"" (which "g++") "\"
2545ar = \"" (which "ar") "\"
2546[target.wasm32-unknown-unknown]
2547llvm-config = \"" (search-input-file inputs "/bin/llvm-config") "\"
2548linker = \"lld\"
2549cc = \"clang\"
2550cxx = \"clang++\"
2551ar = \"ar\"
2552[dist]
2553") port)))))))))
2554 ;; Use native-inputs of base rust.
2555 (native-inputs (package-native-inputs rust))))
2556
2557(define-public rust-analyzer
2558 (package
2559 (name "rust-analyzer")
2560 (version (package-version rust))
2561 (source #f)
2562 (build-system trivial-build-system)
2563 (arguments
2564 (list
2565 #:modules '((guix build utils))
2566 #:builder
2567 #~(begin
2568 (use-modules (guix build utils))
2569 (let ((rust (assoc-ref %build-inputs "rust")))
2570 (install-file (string-append rust "/bin/rust-analyzer")
2571 (string-append #$output "/bin"))
2572 (copy-recursively (string-append rust "/share")
2573 (string-append #$output "/share"))))))
2574 (inputs
2575 (list (list rust "tools")))
2576 (home-page "https://rust-analyzer.github.io/")
2577 (synopsis "Experimental Rust compiler front-end for IDEs")
2578 (description "Rust-analyzer is a modular compiler frontend for the Rust
2579language. It is a part of a larger rls-2.0 effort to create excellent IDE
2580support for Rust.")
2581 (license (list license:expat license:asl2.0))))