summaryrefslogtreecommitdiff
path: root/gnu/packages/rust.scm
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim@guixotic.coop>2025-10-16 23:35:46 +0900
committerAndreas Enge <andreas@enge.fr>2026-02-21 10:14:46 +0100
commit70a576aa87b1650c319570c92e958eba20914325 (patch)
treebca58ff39cf2eb950a1c233ac8d277b26e3d4471 /gnu/packages/rust.scm
parentf30998eeeb354eb4fd919eebd2b8942c9aa9e546 (diff)
gnu: rust: Delete extra files in install phase.
This fixes build failures in recent Rust 1.89 and later, and also reduces the output size of each Rust by about 10%. * gnu/packages/rust.scm (rust-bootstrap-1.54) [#:phases] {install}: Use with-directory-excursion. (rust-bootstrap-1.74): Do not install .rmeta files. (rust-1.55): [#:phases] {install}: Do not install .rmeta and rustlib/librustc_driver shared object files. (rust-1.75): Likewise. Change-Id: I718fc8e924b85867720fc2d343b41c8c4b7935b3
Diffstat (limited to 'gnu/packages/rust.scm')
-rw-r--r--gnu/packages/rust.scm103
1 files changed, 77 insertions, 26 deletions
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 9afb5502482..8d1375bbece 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -322,13 +322,15 @@
322 (lookup-platform-by-target-or-system 322 (lookup-platform-by-target-or-system
323 (or (%current-target-system) 323 (or (%current-target-system)
324 (%current-system)))) "/lib"))) 324 (%current-system)))) "/lib")))
325 (mkdir-p (dirname rustc)) 325 (with-directory-excursion "run_rustc/output/prefix"
326 (copy-file "run_rustc/output/prefix/bin/rustc_binary" rustc) 326 (mkdir-p (dirname rustc))
327 (wrap-program rustc 327 (copy-file "bin/rustc_binary" rustc)
328 `("LD_LIBRARY_PATH" = (,system-lib-prefix))) 328
329 (mkdir-p lib) 329 (wrap-program rustc
330 (copy-recursively "run_rustc/output/prefix/lib" lib) 330 `("LD_LIBRARY_PATH" = (,system-lib-prefix)))
331 (install-file "run_rustc/output/prefix/bin/cargo" cargo-bin))))))) 331 (mkdir-p lib)
332 (copy-recursively "lib" lib)
333 (install-file "bin/cargo" cargo-bin))))))))
332 (synopsis "Compiler for the Rust programming language") 334 (synopsis "Compiler for the Rust programming language")
333 (description "Rust is a systems programming language that provides memory 335 (description "Rust is a systems programming language that provides memory
334safety and thread safety guarantees.") 336safety and thread safety guarantees.")
@@ -506,13 +508,19 @@ safety and thread safety guarantees.")
506 (lookup-platform-by-target-or-system 508 (lookup-platform-by-target-or-system
507 (or (%current-target-system) 509 (or (%current-target-system)
508 (%current-system)))) "/lib"))) 510 (%current-system)))) "/lib")))
509 (mkdir-p (dirname rustc)) 511 (with-directory-excursion "run_rustc/output/prefix"
510 (copy-file "run_rustc/output/prefix/bin/rustc_binary" rustc) 512 ;; The .rmeta files of the bootstrap compiler are not meant
511 (wrap-program rustc 513 ;; to be installed.
512 `("LD_LIBRARY_PATH" = (,system-lib-prefix))) 514 (for-each delete-file (find-files "." "\\.rmeta$"))
513 (mkdir-p lib) 515
514 (copy-recursively "run_rustc/output/prefix/lib" lib) 516 (mkdir-p (dirname rustc))
515 (install-file "run_rustc/output/prefix/bin/cargo" cargo-bin))))))) 517 (copy-file "bin/rustc_binary" rustc)
518
519 (wrap-program rustc
520 `("LD_LIBRARY_PATH" = (,system-lib-prefix)))
521 (mkdir-p lib)
522 (copy-recursively "lib" lib)
523 (install-file "bin/cargo" cargo-bin))))))))
516 (synopsis "Compiler for the Rust programming language") 524 (synopsis "Compiler for the Rust programming language")
517 (description "Rust is a systems programming language that provides memory 525 (description "Rust is a systems programming language that provides memory
518safety and thread safety guarantees.") 526safety and thread safety guarantees.")
@@ -639,18 +647,30 @@ ar = \"" binutils "/bin/ar" "\"
639 (cargo-out (assoc-ref outputs "cargo")) 647 (cargo-out (assoc-ref outputs "cargo"))
640 (build (string-append "build/" 648 (build (string-append "build/"
641 ,(platform-rust-target 649 ,(platform-rust-target
642 (lookup-platform-by-target-or-system 650 (lookup-platform-by-target-or-system
643 (or (%current-target-system) 651 (or (%current-target-system)
644 (%current-system))))))) 652 (%current-system)))))))
645 ;; Manually do the installation instead of calling './x.py 653 ;; Manually do the installation instead of calling './x.py
646 ;; install', as that is slow and needlessly rebuilds some 654 ;; install', as that is slow and needlessly rebuilds some
647 ;; things. 655 ;; things.
648 (install-file (string-append build "/stage1/bin/rustc") 656
649 (string-append out "/bin")) 657 ;; TODO: Try reverting to use "./x.py install rustc std cargo"
650 (copy-recursively (string-append build "/stage1/lib") 658 ;; for Rust 1.91 and newer, which should no longer rebuild
651 (string-append out "/lib")) 659 ;; things unnecessarily.
652 (install-file (string-append build "/stage1-tools-bin/cargo") 660 (with-directory-excursion build
653 (string-append cargo-out "/bin"))))) 661 (install-file "stage1/bin/rustc" (string-append out "/bin"))
662 (install-file "stage1-tools-bin/cargo"
663 (string-append cargo-out "/bin"))
664 ;; Clean up some extraneous library files. The .rmeta files
665 ;; of the bootstrap compiler are not meant to be installed.
666 (for-each delete-file (find-files "stage1/lib" "\\.rmeta$"))
667 ;; This librustc_driver binary is internal and not supposed
668 ;; to be installed. It started causing issues with the build
669 ;; around Rust 1.89.
670 (for-each delete-file
671 (find-files "stage1/lib/rustlib"
672 "^librustc_driver.*\\.so$"))
673 (copy-recursively "stage1/lib" (string-append out "/lib"))))))
654 (add-after 'install 'delete-install-logs 674 (add-after 'install 'delete-install-logs
655 (lambda* (#:key outputs #:allow-other-keys) 675 (lambda* (#:key outputs #:allow-other-keys)
656 (for-each (lambda (f) 676 (for-each (lambda (f)
@@ -681,7 +701,7 @@ ar = \"" binutils "/bin/ar" "\"
681 ("openssl" ,openssl))) 701 ("openssl" ,openssl)))
682 ;; rustc invokes gcc, so we need to set its search paths accordingly. 702 ;; rustc invokes gcc, so we need to set its search paths accordingly.
683 (native-search-paths 703 (native-search-paths
684 %gcc-search-paths) 704 %gcc-search-paths)
685 ;; Limit this to systems where the final rust compiler builds successfully. 705 ;; Limit this to systems where the final rust compiler builds successfully.
686 (supported-systems '("x86_64-linux" "aarch64-linux" "riscv64-linux")) 706 (supported-systems '("x86_64-linux" "aarch64-linux" "riscv64-linux"))
687 (synopsis "Compiler for the Rust programming language") 707 (synopsis "Compiler for the Rust programming language")
@@ -1079,7 +1099,8 @@ safety and thread safety guarantees.")
1079 (package-arguments base-rust)))))) 1099 (package-arguments base-rust))))))
1080 1100
1081(define-public rust-1.75 1101(define-public rust-1.75
1082 (let ((base-rust (rust-bootstrapped-package rust-1.74 "1.75.0" 1102 (let ((base-rust (rust-bootstrapped-package
1103 rust-1.74 "1.75.0"
1083 "1260mf3066ki6y55pvr35lnf54am6z96a3ap3hniwd4xpi2rywsv"))) 1104 "1260mf3066ki6y55pvr35lnf54am6z96a3ap3hniwd4xpi2rywsv")))
1084 (package 1105 (package
1085 (inherit base-rust) 1106 (inherit base-rust)
@@ -1096,7 +1117,37 @@ safety and thread safety guarantees.")
1096 (lambda _ 1117 (lambda _
1097 (mkdir-p "/tmp/bin") 1118 (mkdir-p "/tmp/bin")
1098 (symlink (which "gcc") "/tmp/bin/cc") 1119 (symlink (which "gcc") "/tmp/bin/cc")
1099 (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))))) 1120 (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
1121 (replace 'install
1122 (lambda* (#:key outputs #:allow-other-keys)
1123 (let* ((out (assoc-ref outputs "out"))
1124 (cargo-out (assoc-ref outputs "cargo"))
1125 (build (string-append "build/"
1126 ,(platform-rust-target
1127 (lookup-platform-by-target-or-system
1128 (or (%current-target-system)
1129 (%current-system)))))))
1130 ;; Manually do the installation instead of calling './x.py
1131 ;; install', as that is slow and needlessly rebuilds some
1132 ;; things.
1133
1134 ;; TODO: Try reverting to use "./x.py install rustc std cargo"
1135 ;; for Rust 1.91 and newer, which should no longer rebuild
1136 ;; things unnecessarily.
1137 (with-directory-excursion build
1138 (install-file "stage1/bin/rustc" (string-append out "/bin"))
1139 (install-file "stage1-tools-bin/cargo"
1140 (string-append cargo-out "/bin"))
1141 ;; Clean up some extraneous library files. The .rmeta files
1142 ;; of the bootstrap compiler are not meant to be installed.
1143 (for-each delete-file (find-files "stage1/lib" "\\.rmeta$"))
1144 ;; This librustc_driver binary is internal and not supposed
1145 ;; to be installed. It started causing issues with the build
1146 ;; around Rust 1.89.
1147 (for-each delete-file
1148 (find-files "stage1/lib/rustlib"
1149 "^librustc_driver.*\\.so$"))
1150 (copy-recursively "stage1/lib" (string-append out "/lib")))))))))
1100 (package-arguments base-rust))) 1151 (package-arguments base-rust)))
1101 (native-inputs 1152 (native-inputs
1102 (if (supported-package? rust-bootstrap-1.74) 1153 (if (supported-package? rust-bootstrap-1.74)