From: Fries via Guix-patches via <guix-patches@gnu.org>
To: 64804@debbugs.gnu.org
Cc: Fries <fries1234@protonmail.com>
Subject: [bug#64804] [PATCH] gnu: rust: Update to Rust 1.71.0
Date: Sun, 23 Jul 2023 06:38:26 +0000 [thread overview]
Message-ID: <1bbbeed9c7c6e50464bee042e8dd06e9cd62c4c2.1690094273.git.fries1234@protonmail.com> (raw)
this one was quite a bit of effort but i seem like i actually got it
working!
the major changes that i've done is for Rust 1.70, i made a patch that
enables the cc feature flag so it would compile the outline asm files
instead of using included binary .a files which were removed by guix.
i also ignored a lot more tests for Rust 1.71, mainly gitoxide tests as
they require the network and the git binary and we don't have that in
the build.
also rustfmt requires rustc's shared libraries so i set the RUSTFLAGS
environment variable to add the "out" outputs lib folder to the RUNPATH
so the rustfmt binary works!
---
.../patches/rust-1.70-fix-rustix-build.patch | 20 +++
gnu/packages/rust.scm | 137 ++++++++++++++++--
2 files changed, 141 insertions(+), 16 deletions(-)
create mode 100644 gnu/packages/patches/rust-1.70-fix-rustix-build.patch
diff --git a/gnu/packages/patches/rust-1.70-fix-rustix-build.patch b/gnu/packages/patches/rust-1.70-fix-rustix-build.patch
new file mode 100644
index 0000000..a7e2003
--- /dev/null
+++ b/gnu/packages/patches/rust-1.70-fix-rustix-build.patch
@@ -0,0 +1,20 @@
+--- a/vendor/fd-lock/Cargo.toml 2023-05-31 14:44:48.000000000 -0700
++++ b/vendor/fd-lock/Cargo.toml 2023-07-14 21:19:34.637702319 -0700
+@@ -45,7 +45,7 @@
+
+ [target."cfg(unix)".dependencies.rustix]
+ version = "0.37.0"
+-features = ["fs"]
++features = ["fs", "cc"]
+
+ [target."cfg(windows)".dependencies.windows-sys]
+ version = "0.45.0"
+--- a/src/bootstrap/Cargo.lock 2023-07-11 20:32:40.000000000 -0700
++++ b/src/bootstrap/Cargo.lock 2023-07-14 22:41:53.269284713 -0700
+@@ -618,6 +618,7 @@
+ dependencies = [
+ "bitflags",
++ "cc",
+ "errno",
+ "io-lifetimes",
+ "libc",
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 8e106a9..d489de9 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -16,6 +16,7 @@
;;; Copyright © 2022 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2022 Jim Newsome <jnewsome@torproject.org>
;;; Copyright © 2022 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2023 Fries <fries1234@protonmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -122,6 +123,9 @@ (define* (rust-bootstrapped-package base-rust version checksum)
(alist-replace "rustc-bootstrap" (list base-rust)
(package-native-inputs base-rust))))))
+
+
+
;;; Note: mrustc's only purpose is to be able to bootstap Rust; it's designed
;;; to be used in source form.
(define %mrustc-commit "597593aba86fa2edbea80c6e09f0b1b2a480722d")
@@ -705,6 +709,81 @@ (define rust-1.68
(rust-bootstrapped-package
rust-1.67 "1.68.2" "15ifyd5jj8rd979dkakp887hgmhndr68pqaqvd2hqkfdywirqcwk"))
+(define rust-1.69
+ (let ((base-rust
+ (rust-bootstrapped-package
+ rust-1.68 "1.69.0" "03zn7kx5bi5mdfsqfccj4h8gd6abm7spj0kjsfxwlv5dcwc9f1gv")))
+ (package
+ (inherit base-rust)
+ (source
+ (origin
+ (inherit (package-source base-rust))
+ (snippet
+ '(begin
+ (for-each delete-file-recursively
+ '("src/llvm-project"
+ "vendor/tikv-jemalloc-sys/jemalloc"))
+ ;; Also remove the bundled (mostly Windows) libraries.
+ (for-each delete-file
+ (find-files "vendor" ".*\\.(a|dll|exe|lib)$")))))))))
+
+(define rust-1.70
+ (let ((base-rust
+ (rust-bootstrapped-package
+ rust-1.69 "1.70.0" "0z6j7d0ni0rmfznv0w3mrf882m11kyh51g2bxkj40l3s1c0axgxj")))
+ (package
+ (inherit base-rust)
+ (source
+ (origin
+ (inherit (package-source base-rust))
+ ;; Rust 1.70 uses the rustix library which on Linux, it defaults to
+ ;; using outline ASM which without the cc cargo feature enabled, it
+ ;; will expect a precompiled binary library. This patch will enable the cargo
+ ;; cc feature flag inside the fd-lock vendored Cargo.toml file, which is the
+ ;; crate that uses rustix.
+ (patches (search-patches "rust-1.70-fix-rustix-build.patch"))
+ (patch-flags '("-p1"))))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base-rust)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'build
+ (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")))))))))))
+
+(define rust-1.71
+ (let ((base-rust
+ (rust-bootstrapped-package
+ rust-1.70 "1.71.0" "15jc0d13cmrh2xvpkyyvsbwgn3w4klqiwf2wlgzfp22mvjmy8rx6")))
+ (package
+ (inherit base-rust)
+ (arguments
+ (substitute-keyword-arguments (package-arguments base-rust)
+ ((#:phases phases)
+ `(modify-phases ,phases
+ (replace 'patch-cargo-checksums
+ (lambda _
+ (substitute* '("Cargo.lock"
+ "src/bootstrap/Cargo.lock"
+ "src/tools/rust-analyzer/Cargo.lock"
+ "src/tools/cargo/Cargo.lock")
+ (("(checksum = )\".*\"" all name)
+ (string-append name "\"" ,%cargo-reference-hash "\"")))
+ (generate-all-checksums "vendor"))))))))))
+
+;;; Function to make creating a list to ignore tests a bit easier.
+(define (make-ignore-test-list strs)
+ (map (lambda (str)
+ (let ((ignore-string (format #f "#[ignore]\n~a" str)))
+ `((,str) ,ignore-string)))
+ strs))
+
;;; Note: Only the latest versions of Rust are supported and tested. The
;;; intermediate rusts are built for bootstrapping purposes and should not
;;; be relied upon. This is to ease maintenance and reduce the time
@@ -713,7 +792,7 @@ (define rust-1.68
;;; Here we take the latest included Rust, make it public, and re-enable tests
;;; and extra components such as rustfmt.
(define-public rust
- (let ((base-rust rust-1.67))
+ (let ((base-rust rust-1.71))
(package
(inherit base-rust)
(outputs (cons "rustfmt" (package-outputs base-rust)))
@@ -748,23 +827,43 @@ (define-public rust
(which "env")))))
(add-after 'unpack 'disable-tests-requiring-git
(lambda _
- (substitute* "src/tools/cargo/tests/testsuite/new.rs"
- (("fn author_prefers_cargo")
- "#[ignore]\nfn author_prefers_cargo")
- (("fn finds_author_git")
- "#[ignore]\nfn finds_author_git")
- (("fn finds_local_author_git")
- "#[ignore]\nfn finds_local_author_git"))))
+ (substitute* "src/tools/cargo/tests/testsuite/git.rs"
+ ,@(make-ignore-test-list
+ '("fn fetch_downloads_with_git2_first_then_with_gitoxide_and_vice_versa"
+ "fn git_fetch_cli_env_clean"
+ "fn git_with_cli_force"
+ "fn use_the_cli")))
+ ;; Gitoxide tests seem to require the internet to run
+ ;; and Guix build containers don't have the internet.
+ (substitute* "src/tools/cargo/tests/testsuite/git_shallow.rs"
+ ,@(make-ignore-test-list
+ '("fn gitoxide_clones_git_dependency_with_shallow_protocol_and_git2_is_used_for_followup_fetches"
+ "fn gitoxide_clones_registry_with_shallow_protocol_and_aborts_and_updates_again"
+ "fn gitoxide_clones_registry_with_shallow_protocol_and_follow_up_fetch_maintains_shallowness"
+ "fn gitoxide_clones_registry_with_shallow_protocol_and_follow_up_with_git2_fetch"
+ "fn gitoxide_clones_registry_without_shallow_protocol_and_follow_up_fetch_uses_shallowness"
+ "fn gitoxide_clones_shallow_two_revs_same_deps"
+ "fn gitoxide_git_dependencies_switch_from_branch_to_rev"
+ "fn gitoxide_shallow_clone_followed_by_non_shallow_update"
+ "fn shallow_deps_work_with_revisions_and_branches_mixed_on_same_dependency")))
+ (substitute* "src/tools/cargo/tests/testsuite/offline.rs"
+ ,@(make-ignore-test-list '("fn gitoxide_cargo_compile_offline_with_cached_git_dep_shallow_dep")))
+ (substitute* "src/tools/cargo/tests/testsuite/patch.rs"
+ ,@(make-ignore-test-list '("fn gitoxide_clones_shallow_old_git_patch")))))
(add-after 'unpack 'disable-tests-requiring-mercurial
(lambda _
- (substitute*
- "src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/mod.rs"
- (("fn simple_hg_ignore_exists")
- "#[ignore]\nfn simple_hg_ignore_exists"))
(substitute*
"src/tools/cargo/tests/testsuite/init/mercurial_autodetect/mod.rs"
- (("fn mercurial_autodetect")
- "#[ignore]\nfn mercurial_autodetect"))))
+ ,@(make-ignore-test-list '("fn case")))
+ (substitute*
+ "src/tools/cargo/tests/testsuite/init/simple_hg/mod.rs"
+ ,@(make-ignore-test-list '("fn case")))
+ (substitute*
+ "src/tools/cargo/tests/testsuite/init/simple_hg_ignore_exists/mod.rs"
+ ,@(make-ignore-test-list '("fn case")))
+ (substitute*
+ "src/tools/cargo/tests/testsuite/new.rs"
+ ,@(make-ignore-test-list '("fn simple_hg")))))
(add-after 'unpack 'disable-tests-broken-on-aarch64
(lambda _
(with-directory-excursion "src/tools/cargo/tests/testsuite/"
@@ -807,7 +906,7 @@ (define-public rust
;; We skip the test since it's drastically unlikely Guix's
;; packaging will introduce a bug here.
(lambda _
- (delete-file "src/test/ui/parser/shebang/sneaky-attrib.rs")))
+ (delete-file "tests/ui/parser/shebang/sneaky-attrib.rs")))
(add-after 'unpack 'patch-process-tests
(lambda* (#:key inputs #:allow-other-keys)
(let ((bash (assoc-ref inputs "bash")))
@@ -840,11 +939,17 @@ (define-public rust
"gdb = \"" gdb "/bin/gdb\"\n"))))))
(replace 'build
;; Phase overridden to also build rustfmt.
- (lambda* (#:key parallel-build? #:allow-other-keys)
+ (lambda* (#:key parallel-build? outputs #:allow-other-keys)
(let ((job-spec (string-append
"-j" (if parallel-build?
(number->string (parallel-job-count))
"1"))))
+ ;; Append the default output's lib folder to the RUSTFLAGS
+ ;; environment variable. this lets programs that depend on
+ ;; rustc's shared libraries like rustfmt work.
+ (setenv "RUSTFLAGS"
+ (format #f "-C link-arg=-Wl,-rpath,~a/lib"
+ (assoc-ref outputs "out")))
(invoke "./x.py" job-spec "build"
"library/std" ;rustc
"src/tools/cargo"
base-commit: 00ed2901f5171e4f9435641a91678217cae38030
--
2.41.0
next reply other threads:[~2023-07-23 13:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-23 6:38 Fries via Guix-patches via [this message]
2023-07-23 20:38 ` [bug#64804] [PATCH] gnu: rust: Update to Rust 1.71.0 Juliana Sims
2023-07-24 5:36 ` [bug#64804] [PATCH 1/5] gnu: rust: Add rust-1.69 Fries via Guix-patches via
2023-07-24 5:36 ` [bug#64804] [PATCH 2/5] gnu: rust: Add rust-1.70 Fries via Guix-patches via
2023-07-24 5:36 ` [bug#64804] [PATCH 3/5] gnu: rust: Add rust-1.71 Fries via Guix-patches via
2023-07-24 5:36 ` [bug#64804] [PATCH 4/5] gnu: rust: Add make-ignore-test-list function Fries via Guix-patches via
2023-07-24 5:36 ` [bug#64804] [PATCH 5/5] gnu: rust: Update to 1.71 Fries via Guix-patches via
2023-07-24 5:51 ` Fries via Guix-patches via
2023-10-01 7:10 ` Efraim Flashner
2023-09-30 15:40 ` [bug#64804] Please merge it Milan Svoboda
2023-10-01 9:30 ` Malte Frank Gerdes
2023-10-01 3:47 ` [bug#64804] [PATCH] gnu: rust: Update to Rust 1.71.0 jaeme via Guix-patches via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1bbbeed9c7c6e50464bee042e8dd06e9cd62c4c2.1690094273.git.fries1234@protonmail.com \
--to=guix-patches@gnu.org \
--cc=64804@debbugs.gnu.org \
--cc=fries1234@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.