gnu: rust-bootstrap: Clean-up code.

* gnu/packages/rust.scm (rust-bootstrap)[arguments]: Remove custom
'patch-reference-to-cc phase which didn't do any substitutions.  Join
two substitutions preventing downloading during the build.  Remove
unneeded variable in let statement.

Change-Id: Iff0262bdff3cb1257afeb83f33c40c54db02dc64
This commit is contained in:
Efraim Flashner 2024-01-11 08:15:09 +02:00
parent 4c60c6e412
commit e825a656eb
No known key found for this signature in database
GPG key ID: 41AAE7DCCA3D8351

View file

@ -212,14 +212,6 @@ (define-public rust-bootstrap
"OUTDIR_SUF=") ;do not add version suffix to output dir "OUTDIR_SUF=") ;do not add version suffix to output dir
#:phases #:phases
(modify-phases %standard-phases (modify-phases %standard-phases
(add-after 'unpack 'patch-reference-to-cc
;; This prevents errors like 'error: linker `cc` not found' when
;; "cc" is not found on PATH.
(lambda* (#:key inputs #:allow-other-keys)
(let ((gcc (assoc-ref inputs "gcc")))
(substitute* (find-files "." "^link.rs$")
(("\"cc\".as_ref")
(format #f "~s.as_ref" (string-append gcc "/bin/gcc")))))))
(add-after 'unpack 'setup-mrustc-sources (add-after 'unpack 'setup-mrustc-sources
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(copy-recursively (assoc-ref inputs "mrustc-source") "../mrustc") (copy-recursively (assoc-ref inputs "mrustc-source") "../mrustc")
@ -244,7 +236,9 @@ (define-public rust-bootstrap
(string-append "LLVM_CONFIG := " llvm "/bin/llvm-config\n"))) (string-append "LLVM_CONFIG := " llvm "/bin/llvm-config\n")))
(substitute* "minicargo.mk" (substitute* "minicargo.mk"
;; Do not try to fetch sources from the Internet. ;; Do not try to fetch sources from the Internet.
(("@curl.*") "")) (("@curl.*") "")
(("\\$\\(MINICARGO\\) \\$\\(RUSTC_SRC_DL\\)")
"$(MINICARGO)"))
(substitute* "Makefile" (substitute* "Makefile"
;; Patch date and git obtained version information. ;; Patch date and git obtained version information.
((" -D VERSION_GIT_FULLHASH=.*") ((" -D VERSION_GIT_FULLHASH=.*")
@ -256,10 +250,6 @@ (define-public rust-bootstrap
" -D VERSION_BUILDTIME=" " -D VERSION_BUILDTIME="
"\"\\\"Thu, 01 Jan 1970 00:00:01 +0000\\\"\"" "\"\\\"Thu, 01 Jan 1970 00:00:01 +0000\\\"\""
" -D VERSION_GIT_ISDIRTY=0\n"))) " -D VERSION_GIT_ISDIRTY=0\n")))
(substitute* "minicargo.mk"
;; Do not try to fetch sources from the Internet.
(("\\$\\(MINICARGO\\) \\$\\(RUSTC_SRC_DL\\)")
"$(MINICARGO)"))
(substitute* "run_rustc/Makefile" (substitute* "run_rustc/Makefile"
;; Patch the shebang of a generated wrapper for rustc ;; Patch the shebang of a generated wrapper for rustc
(("#!/bin/sh") (("#!/bin/sh")
@ -268,7 +258,7 @@ (define-public rust-bootstrap
(("#!/bin/sh") (("#!/bin/sh")
(string-append "#!" (which "sh")))))))) (string-append "#!" (which "sh"))))))))
(add-after 'patch-generated-file-shebangs 'patch-cargo-checksums (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums
(lambda* _ (lambda _
(substitute* "Cargo.lock" (substitute* "Cargo.lock"
(("(checksum = )\".*\"" all name) (("(checksum = )\".*\"" all name)
(string-append name "\"" ,%cargo-reference-hash "\""))) (string-append name "\"" ,%cargo-reference-hash "\"")))
@ -292,10 +282,9 @@ (define-public rust-bootstrap
(delete 'patch-generated-file-shebangs) (delete 'patch-generated-file-shebangs)
(replace 'build (replace 'build
(lambda* (#:key make-flags parallel-build? #:allow-other-keys) (lambda* (#:key make-flags parallel-build? #:allow-other-keys)
(let* ((src-root (getcwd)) (let ((job-count (if parallel-build?
(job-count (if parallel-build? (parallel-job-count)
(parallel-job-count) 1)))
1)))
;; Adapted from: ;; Adapted from:
;; https://github.com/dtolnay/bootstrap/blob/master/build-1.54.0.sh. ;; https://github.com/dtolnay/bootstrap/blob/master/build-1.54.0.sh.
(chdir "../mrustc") (chdir "../mrustc")