[bug#77616,3/6] gnu: rust-1.75: Inherit from rust-bootstrap.

Message ID CH3PR84MB3424B7D7A9B38B3ABE85749EC5AA2@CH3PR84MB3424.NAMPRD84.PROD.OUTLOOK.COM
State New
Headers
Series None |

Commit Message

Morgan Smith April 7, 2025, 8:07 p.m. UTC
  * gnu/packages/rust.scm (rust-1.75): Inherit from rust-bootstrap.
(rust-1.75): Remove variable.

Change-Id: I8474b703baebfcb7b1e5442a6593c22039997924
---
 gnu/packages/rust.scm | 227 ++++++++++++++++++++----------------------
 1 file changed, 109 insertions(+), 118 deletions(-)
  

Patch

diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 66703abc35..ccedfd2c74 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -341,87 +341,71 @@  (define-public rust-bootstrap
     ;; Dual licensed.
     (license (list license:asl2.0 license:expat))))
 
-(define-public rust-1.55
+(define-public rust-1.75
   (package
     (name "rust")
-    (version "1.55.0")
+    (version "1.75.0")
     (source
      (origin
-       (method url-fetch)
+       (inherit (package-source rust-bootstrap))
        (uri (rust-uri version))
-       (sha256 (base32 "07l28f7grdmi65naq71pbmvdd61hwcpi40ry7kp7dy7m233rldxj"))
-       (modules '((guix build utils)))
-       (snippet
-        '(begin
-           (for-each delete-file-recursively
-                     '("src/llvm-project"
-                       "vendor/openssl-src/openssl"
-                       "vendor/tikv-jemalloc-sys/jemalloc"))
-           ;; Remove vendored dynamically linked libraries.
-           ;; find . -not -type d -executable -exec file {} \+ | grep ELF
-           (delete-file "vendor/vte/vim10m_match")
-           (delete-file "vendor/vte/vim10m_table")
-           ;; Also remove the bundled (mostly Windows) libraries.
-           ;; find vendor -not -type d -exec file {} \+ | grep PE32
-           (for-each delete-file
-                     (find-files "vendor" "\\.(a|dll|exe|lib)$"))
-           ;; Add support for riscv64-linux.
-           (substitute* "vendor/tikv-jemallocator/src/lib.rs"
-             (("    target_arch = \"s390x\"," all)
-              (string-append all "\n    target_arch = \"riscv64\",")))))))
+       (sha256 (base32 "1260mf3066ki6y55pvr35lnf54am6z96a3ap3hniwd4xpi2rywsv"))
+       (patches '())))
     (outputs '("out" "cargo"))
     (properties '((hidden? . #t)
                   (timeout . 72000)           ;20 hours
                   (max-silent-time . 18000))) ;5 hours (for armel)
     (build-system gnu-build-system)
     (arguments
-     `(#:validate-runpath? #f
-       ;; Only the final Rust is tested, not the intermediate bootstrap ones,
-       ;; for performance and simplicity.
-       #:tests? #f
-       #:imported-modules ,%cargo-utils-modules ;for `generate-all-checksums'
-       #:modules ((guix build cargo-utils)
+     (list
+      #:disallowed-references (list rust-bootstrap)
+      #:validate-runpath? #f
+      ;; Only the final Rust is tested, not the intermediate bootstrap ones,
+      ;; for performance and simplicity.
+      #:tests? #f
+      #:imported-modules %cargo-utils-modules ;for `generate-all-checksums'
+      #:modules '((guix build cargo-utils)
                   (guix build utils)
                   (guix build gnu-build-system)
                   (ice-9 match)
                   (srfi srfi-1))
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'set-env
-           (lambda* (#:key inputs #:allow-other-keys)
-             (setenv "SHELL" (which "sh"))
-             (setenv "CONFIG_SHELL" (which "sh"))
-             (setenv "CC" (search-input-file inputs "/bin/gcc"))
-             ;; The Guix LLVM package installs only shared libraries.
-             (setenv "LLVM_LINK_SHARED" "1")))
-         (add-after 'unpack 'set-linker-locale-to-utf8
-           (lambda _
-             (substitute* (find-files "." "^linker.rs$")
-               (("linker.env\\(\"LC_ALL\", \"C\"\\);")
-                "linker.env(\"LC_ALL\", \"C.UTF-8\");"))))
-         (add-after 'unpack 'add-cc-shim-to-path
-           (lambda _
-             (mkdir-p "/tmp/bin")
-             (symlink (which "gcc") "/tmp/bin/cc")
-             (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
-         (replace 'configure
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (gcc (assoc-ref inputs "gcc"))
-                    (python (assoc-ref inputs "python"))
-                    (binutils (assoc-ref inputs "binutils"))
-                    (rustc (assoc-ref inputs "rustc-bootstrap"))
-                    (cargo (assoc-ref inputs "cargo-bootstrap"))
-                    (llvm (assoc-ref inputs "llvm")))
-               (call-with-output-file "config.toml"
-                 (lambda (port)
-                   (display (string-append "
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'set-env
+          (lambda* (#:key inputs #:allow-other-keys)
+            (setenv "SHELL" (which "sh"))
+            (setenv "CONFIG_SHELL" (which "sh"))
+            (setenv "CC" (search-input-file inputs "/bin/gcc"))
+            ;; The Guix LLVM package installs only shared libraries.
+            (setenv "LLVM_LINK_SHARED" "1")))
+        (add-after 'unpack 'set-linker-locale-to-utf8
+          (lambda _
+            (substitute* (find-files "." "^linker.rs$")
+              (("linker.env\\(\"LC_ALL\", \"C\"\\);")
+               "linker.env(\"LC_ALL\", \"C.UTF-8\");"))))
+        (add-after 'unpack 'add-cc-shim-to-path
+          (lambda _
+            (mkdir-p "/tmp/bin")
+            (symlink (which "gcc") "/tmp/bin/cc")
+            (setenv "PATH" (string-append "/tmp/bin:" (getenv "PATH")))))
+        (replace 'configure
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (gcc (assoc-ref inputs "gcc"))
+                   (python (search-input-file inputs "/bin/python"))
+                   (binutils (assoc-ref inputs "binutils"))
+                   (rustc (search-input-file inputs "/bin/rustc"))
+                   (cargo (search-input-file inputs "/bin/cargo"))
+                   (llvm (assoc-ref inputs "llvm")))
+              (call-with-output-file "config.toml"
+                (lambda (port)
+                  (display (string-append "
 [llvm]
 [build]
-cargo = \"" cargo "/bin/cargo" "\"
-rustc = \"" rustc "/bin/rustc" "\"
+cargo = \"" cargo "\"
+rustc = \"" rustc "\"
 docs = false
-python = \"" python "/bin/python" "\"
+python = \"" python "\"
 vendor = true
 submodules = false
 [install]
@@ -433,69 +417,76 @@  (define-public rust-1.55
 default-linker = \"" gcc "/bin/gcc" "\"
 channel = \"stable\"
 rpath = true
-[target." ,(platform-rust-target (lookup-platform-by-system (%current-system))) "]
+[target." #$(platform-rust-target (lookup-platform-by-system (%current-system))) "]
 llvm-config = \"" llvm "/bin/llvm-config" "\"
 cc = \"" gcc "/bin/gcc" "\"
 cxx = \"" gcc "/bin/g++" "\"
 ar = \"" binutils "/bin/ar" "\"
 [dist]
 ") port))))))
-         (replace 'build
-           ;; The standard library source location moved in this release.
-           (lambda* (#:key parallel-build? #:allow-other-keys)
-             (let ((job-spec (string-append
-                              "-j" (if parallel-build?
-                                       (number->string (parallel-job-count))
-                                       "1"))))
-               (invoke "./x.py" job-spec "build" "--stage=1"
-                       "library/std"
-                       "src/tools/cargo"))))
-         (replace 'install
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (cargo-out (assoc-ref outputs "cargo"))
-                    (build (string-append "build/"
-                                          ,(platform-rust-target
-                                             (lookup-platform-by-target-or-system
-                                               (or (%current-target-system)
-                                                   (%current-system)))))))
-               ;; Manually do the installation instead of calling './x.py
-               ;; install', as that is slow and needlessly rebuilds some
-               ;; things.
-               (install-file (string-append build "/stage1/bin/rustc")
-                             (string-append out "/bin"))
-               (copy-recursively (string-append build "/stage1/lib")
-                                 (string-append out "/lib"))
-               (install-file (string-append build "/stage1-tools-bin/cargo")
-                             (string-append cargo-out "/bin")))))
-         (add-after 'install 'delete-install-logs
-           (lambda* (#:key outputs #:allow-other-keys)
-             (for-each (lambda (f)
-                         (false-if-exception (delete-file f)))
-                       (append-map (lambda (output)
-                                     (find-files (string-append
-                                                  output "/lib/rustlib")
-                                                 "(^install.log$|^manifest-)"))
-                                   (map cdr outputs)))))
-         (add-after 'install 'wrap-rustc
-           (lambda* (#:key inputs outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out"))
-                   (libc (assoc-ref inputs "libc"))
-                   (ld-wrapper (assoc-ref inputs "ld-wrapper")))
-               ;; Let gcc find ld and libc startup files.
-               (wrap-program (string-append out "/bin/rustc")
-                 `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
-                 `("LIBRARY_PATH" ":"
-                   suffix (,(string-append libc "/lib"))))))))))
+        (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums
+          (lambda _
+            (substitute* (cons* "Cargo.lock"
+                                "src/bootstrap/Cargo.lock"
+                                (find-files "src/tools" "Cargo.lock"))
+              (("(checksum = )\".*\"" all name)
+               (string-append name "\"" #$%cargo-reference-hash "\"")))
+            (generate-all-checksums "vendor")))
+        (replace 'build
+          ;; The standard library source location moved in this release.
+          (lambda* (#:key parallel-build? #:allow-other-keys)
+            (let ((job-spec (string-append
+                             "-j" (if parallel-build?
+                                      (number->string (parallel-job-count))
+                                      "1"))))
+              (invoke "./x.py" job-spec "build" "--stage=1"
+                      "library/std"
+                      "src/tools/cargo"))))
+        (replace 'install
+          (lambda* (#:key outputs #:allow-other-keys)
+            (let* ((out (assoc-ref outputs "out"))
+                   (cargo-out (assoc-ref outputs "cargo"))
+                   (build (string-append "build/"
+                                         #$(platform-rust-target
+                                            (lookup-platform-by-target-or-system
+                                             (or (%current-target-system)
+                                                 (%current-system)))))))
+              ;; Manually do the installation instead of calling './x.py
+              ;; install', as that is slow and needlessly rebuilds some
+              ;; things.
+              (install-file (string-append build "/stage1/bin/rustc")
+                            (string-append out "/bin"))
+              (copy-recursively (string-append build "/stage1/lib")
+                                (string-append out "/lib"))
+              (install-file (string-append build "/stage1-tools-bin/cargo")
+                            (string-append cargo-out "/bin")))))
+        (add-after 'install 'delete-install-logs
+          (lambda* (#:key outputs #:allow-other-keys)
+            (for-each (lambda (f)
+                        (false-if-exception (delete-file f)))
+                      (append-map (lambda (output)
+                                    (find-files (string-append
+                                                 output "/lib/rustlib")
+                                                "(^install.log$|^manifest-)"))
+                                  (map cdr outputs)))))
+        (add-after 'install 'wrap-rustc
+          (lambda* (#:key inputs outputs #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out"))
+                  (libc (assoc-ref inputs "libc"))
+                  (ld-wrapper (assoc-ref inputs "ld-wrapper")))
+              ;; Let gcc find ld and libc startup files.
+              (wrap-program (string-append out "/bin/rustc")
+                `("PATH" ":" prefix (,(string-append ld-wrapper "/bin")))
+                `("LIBRARY_PATH" ":"
+                  suffix (,(string-append libc "/lib"))))))))))
     (native-inputs
-     `(("pkg-config" ,pkg-config)
-       ("python" ,python-minimal-wrapper)
-       ("rustc-bootstrap" ,rust-bootstrap)
-       ("cargo-bootstrap" ,rust-bootstrap "cargo")))
+     (list
+      pkg-config
+      python-minimal-wrapper
+      rust-bootstrap
+      `(,rust-bootstrap "cargo")))
     (inputs
-     `(("bash" ,bash-minimal)
-       ("llvm" ,llvm-13)
-       ("openssl" ,openssl)))
+     (list bash-minimal llvm-15 openssl))
     ;; rustc invokes gcc, so we need to set its search paths accordingly.
     (native-search-paths
       %gcc-search-paths)