From b300f3686f490f5dd9aac205387d7af6886b2208 Mon Sep 17 00:00:00 2001
From: Pierre Langlois <pierre.langlois@gmx.com>
Date: Mon, 14 Mar 2022 01:18:16 +0000
Subject: [PATCH 2/2] wip bootstrap from 1.54.
---
gnu/packages/patches/rustc-1.54.0-src.patch | 117 +++++++++++++
gnu/packages/rust.scm | 181 ++++----------------
2 files changed, 150 insertions(+), 148 deletions(-)
create mode 100644 gnu/packages/patches/rustc-1.54.0-src.patch
new file mode 100644
@@ -0,0 +1,117 @@
+# mrustc is much better at enum packing, so causes almost all of these to be smaller by one pointer
+--- compiler/rustc_ast/src/ast.rs
++++ compiler/rustc_ast/src/ast.rs
+@@ -1075,7 +1075,7 @@ pub struct Expr {
+ }
+
+ // `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler = "mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(Expr, 104);
+
+ impl Expr {
+@@ -2779,7 +2779,7 @@ pub enum AssocItemKind {
+ MacCall(MacCall),
+ }
+
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler = "mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(AssocItemKind, 72);
+
+ impl AssocItemKind {
+@@ -2831,7 +2831,7 @@ pub enum ForeignItemKind {
+ MacCall(MacCall),
+ }
+
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler="mrustc"),target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(ForeignItemKind, 72);
+
+ impl From<ForeignItemKind> for ItemKind {
+--- compiler/rustc_hir/src/hir.rs
++++ compiler/rustc_hir/src/hir.rs
+@@ -3050,3 +3050,3 @@
+ // Some nodes are used a lot. Make sure they don't unintentionally get bigger.
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler="mrustc"),target_arch = "x86_64", target_pointer_width = "64"))]
+ mod size_asserts {
+--- compiler/rustc_middle/src/mir/interpret/error.rs
++++ compiler/rustc_middle/src/mir/interpret/error.rs
+@@ -452,2 +452,2 @@
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler="mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ static_assert_size!(InterpError<'_>, 64);
+--- compiler/rustc_middle/src/mir/mod.rs
++++ compiler/rustc_middle/src/mir/mod.rs
+@@ -2203,2 +2203,2 @@
+-#[cfg(target_arch = "x86_64")]
++#[cfg(all(not(rust_compiler="mrustc"), target_arch = "x86_64"))]
+ static_assert_size!(AggregateKind<'_>, 48);
+--- compiler/rustc_middle/src/thir.rs
++++ compiler/rustc_middle/src/thir.rs
+@@ -147,2 +147,2 @@
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler="mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(Expr<'_>, 144);
+--- compiler/rustc_mir/src/interpret/place.rs
++++ compiler/rustc_mir/src/interpret/place.rs
+@@ -91,2 +91,2 @@
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler = "mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(Place, 64);
+@@ -100,2 +100,2 @@
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler = "mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(PlaceTy<'_>, 80);
+--- compiler/rustc_mir/src/interpret/operand.rs
++++ compiler/rustc_mir/src/interpret/operand.rs
+@@ -35,2 +35,2 @@
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler = "mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(Immediate, 56);
+@@ -90,2 +90,2 @@
+-#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
++#[cfg(all(not(rust_compiler = "mrustc"), target_arch = "x86_64", target_pointer_width = "64"))]
+ rustc_data_structures::static_assert_size!(ImmTy<'_>, 72);
+
+#
+# Disable crc32fast's use of stdarch
+#
+--- vendor/crc32fast/src/specialized/mod.rs
++++ vendor/crc32fast/src/specialized/mod.rs
+@@ -1,5 +1,6 @@
+ cfg_if! {
+ if #[cfg(all(
++ not(rust_compiler = "mrustc"),
+ crc32fast_stdarchx86,
+ any(target_arch = "x86", target_arch = "x86_64")
+ ))] {
+
+#
+# Disable std_detect's detection logic (use the same logic as miri)
+#
+--- library/stdarch/crates/std_detect/src/detect/mod.rs
++++ library/stdarch/crates/std_detect/src/detect/mod.rs
+@@ -88,2 +88,2 @@
+ cfg_if! {
+- if #[cfg(miri)] {
++ if #[cfg(any(miri, rust_compiler = "mrustc"))] {
+
+# PPV-Lite also needs to know that we're pretending to be miri
+--- vendor/ppv-lite86/src/lib.rs
++++ vendor/ppv-lite86/src/lib.rs
+@@ -12,9 +12,9 @@
+-#[cfg(all(feature = "simd", target_arch = "x86_64", not(miri)))]
++#[cfg(all(feature = "simd", target_arch = "x86_64", not(miri), not(rust_compiler = "mrustc")))]
+ pub mod x86_64;
+-#[cfg(all(feature = "simd", target_arch = "x86_64", not(miri)))]
++#[cfg(all(feature = "simd", target_arch = "x86_64", not(miri), not(rust_compiler = "mrustc")))]
+ use self::x86_64 as arch;
+
+-#[cfg(any(miri, not(all(feature = "simd", any(target_arch = "x86_64")))))]
++#[cfg(any(miri, rust_compiler = "mrustc", not(all(feature = "simd", any(target_arch = "x86_64")))))]
+ pub mod generic;
+-#[cfg(any(miri, not(all(feature = "simd", any(target_arch = "x86_64")))))]
++#[cfg(any(miri, rust_compiler = "mrustc", not(all(feature = "simd", any(target_arch = "x86_64")))))]
+ use self::generic as arch;
+
@@ -48,6 +48,8 @@ (define-module (gnu packages rust)
#:use-module (gnu packages python)
#:use-module (gnu packages ssh)
#:use-module (gnu packages tls)
+ #:use-module (gnu packages version-control)
+ #:use-module (gnu packages web)
#:use-module (gnu packages)
#:use-module (guix build-system cargo)
#:use-module (guix build-system copy)
@@ -140,21 +142,27 @@ (define %mrustc-source
;;; Rust 1.39 is special in that it is built with mrustc, which shortens the
;;; bootstrap path.
-(define rust-1.39
+(define rust-1.54
(package
(name "rust")
- (version "1.39.0")
+ (version "1.54.0")
(source
(origin
(method url-fetch)
(uri (rust-uri version))
- (sha256 (base32 "0mwkc1bnil2cfyf6nglpvbn2y0zfbv44zfhsd5qg4c9rm6vgd8dl"))
+ (sha256 (base32 "0xk9dhfff16caambmwij67zgshd8v9djw6ha0fnnanlv7rii31dc"))
(modules '((guix build utils)))
- (snippet '(for-each delete-file-recursively
- '("src/llvm-emscripten"
- "src/llvm-project"
- "vendor/jemalloc-sys/jemalloc")))
- (patches (search-patches "rustc-1.39.0-src.patch"))
+ (snippet '(begin
+ (delete-file-recursively "src/llvm-project")
+ (delete-file-recursively "vendor/libnghttp2-sys/nghttp2")
+ (delete-file "vendor/libnghttp2-sys/build.rs")
+ (with-output-to-file "vendor/libnghttp2-sys/build.rs"
+ (lambda _
+ (format #t "fn main() {~@
+ println!(\"cargo:rustc-link-lib=nghttp2\");~@
+ }~%")))
+ #t))
+ (patches (search-patches "rustc-1.54.0-src.patch"))
(patch-flags '("-p0")))) ;default is -p1
(outputs '("out" "cargo"))
(properties '((timeout . 72000) ;20 hours
@@ -163,8 +171,10 @@ (define rust-1.39
(inputs
`(("libcurl" ,curl)
("libssh2" ,libssh2)
- ("llvm" ,llvm-9)
+ ("llvm" ,llvm-12)
("openssl" ,openssl)
+ ("nghttp2" ,nghttp2 "lib")
+ ("libgit2" ,libgit2)
("zlib" ,zlib)))
(native-inputs
`(("bison" ,bison)
@@ -252,6 +262,11 @@ (define rust-1.39
(substitute* "run_rustc/rustc_proxy.sh"
(("#!/bin/sh")
(string-append "#!" (which "sh"))))))))
+ (add-after 'unpack 'set-linker-locale-to-utf8
+ (lambda _
+ (substitute* (find-files "." "^linker.rs$")
+ (("linker.env\\(\"LC_ALL\", \"C\"\\);")
+ "linker.env(\"LC_ALL\", \"en_US.UTF-8\");"))))
(add-after 'patch-generated-file-shebangs 'patch-cargo-checksums
(lambda* _
(substitute* "Cargo.lock"
@@ -331,21 +346,17 @@ (define rust-1.39
;; Dual licensed.
(license (list license:asl2.0 license:expat))))
-(define rust-1.40
+(define rust-1.55
(package
(name "rust")
- (version "1.40.0")
+ (version "1.55.0")
(source
(origin
(method url-fetch)
(uri (rust-uri version))
- (sha256 (base32 "1ba9llwhqm49w7sz3z0gqscj039m53ky9wxzhaj11z6yg1ah15yx"))
+ (sha256 (base32 "07l28f7grdmi65naq71pbmvdd61hwcpi40ry7kp7dy7m233rldxj"))
(modules '((guix build utils)))
- ;; llvm-emscripten is no longer bundled, as that codegen backend got
- ;; removed.
- (snippet '(for-each delete-file-recursively
- '("src/llvm-project"
- "vendor/jemalloc-sys/jemalloc")))))
+ (snippet '(delete-file-recursively "src/llvm-project"))))
(outputs '("out" "cargo"))
(properties '((timeout . 72000) ;20 hours
(max-silent-time . 18000))) ;5 hours (for armel)
@@ -361,8 +372,7 @@ (define rust-1.40
;; putting the codegen backend in a separate library, which makes this
;; workaround only necessary for this release.
(arguments
- `(#:validate-runpath? #f
- ;; Only the final Rust is tested, not the intermediate bootstrap ones,
+ `(;; 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'
@@ -380,11 +390,6 @@ (define rust-1.40
(setenv "CC" (search-input-file inputs "/bin/gcc"))
;; The Guix LLVM package installs only shared libraries.
(setenv "LLVM_LINK_SHARED" "1")))
- (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")))))
(add-after 'unpack 'neuter-tidy
;; We often need to patch tests with various Guix-specific paths.
;; This often increases the line length and makes tidy, rustc's
@@ -449,7 +454,7 @@ (define rust-1.40
(number->string (parallel-job-count))
"1"))))
(invoke "./x.py" job-spec "build" "--stage=1"
- "src/libstd"
+ "library/std"
"src/tools/cargo"))))
(replace 'install
(lambda* (#:key outputs #:allow-other-keys)
@@ -490,12 +495,12 @@ (define rust-1.40
`(("cmake" ,cmake-minimal)
("pkg-config" ,pkg-config) ; For "cargo"
("python" ,python-wrapper)
- ("rustc-bootstrap" ,rust-1.39)
- ("cargo-bootstrap" ,rust-1.39 "cargo")
+ ("rustc-bootstrap" ,rust-1.54)
+ ("cargo-bootstrap" ,rust-1.54 "cargo")
("which" ,which)))
(inputs
`(("jemalloc" ,jemalloc)
- ("llvm" ,llvm-9)
+ ("llvm" ,llvm-12)
("openssl" ,openssl)
("libssh2" ,libssh2) ; For "cargo"
("libcurl" ,curl))) ; For "cargo"
@@ -519,126 +524,6 @@ (define rust-1.40
;; Dual licensed.
(license (list license:asl2.0 license:expat))))
-(define rust-1.41
- (let ((base-rust (rust-bootstrapped-package
- rust-1.40 "1.41.1"
- "0ws5x0fxv57fyllsa6025h3q6j9v3m8nb3syl4x0hgkddq0kvj9q")))
- (package
- (inherit base-rust)
- (arguments
- (substitute-keyword-arguments (package-arguments base-rust)
- ((#:validate-runpath? _ #t)
- #t)
- ((#:phases phases)
- `(modify-phases ,phases
- (delete 'add-cc-shim-to-path)
- (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums
- (lambda* _
- (substitute* "Cargo.lock"
- (("(checksum = )\".*\"" all name)
- (string-append name "\"" ,%cargo-reference-hash "\"")))
- (generate-all-checksums "vendor"))))))))))
-
-(define rust-1.42
- (rust-bootstrapped-package
- rust-1.41 "1.42.0" "0x9lxs82may6c0iln0b908cxyn1cv7h03n5cmbx3j1bas4qzks6j"))
-
-(define rust-1.43
- (rust-bootstrapped-package
- rust-1.42 "1.43.0" "18akhk0wz1my6y9vhardriy2ysc482z0fnjdcgs9gy59kmnarxkm"))
-
-;; This version requires llvm <= 11.
-(define rust-1.44
- (rust-bootstrapped-package
- rust-1.43 "1.44.1"
- "0ww4z2v3gxgn3zddqzwqya1gln04p91ykbrflnpdbmcd575n8bky"))
-
-(define rust-1.45
- (let ((base-rust (rust-bootstrapped-package
- rust-1.44 "1.45.2"
- "0273a1g3f59plyi1n0azf21qjzwml1yqdnj5z472crz37qggr8xp")))
- (package
- (inherit base-rust)
- (arguments
- (substitute-keyword-arguments (package-arguments base-rust)
- ((#:phases phases)
- `(modify-phases ,phases
- (add-after 'unpack 'set-linker-locale-to-utf8
- (lambda _
- (substitute* (find-files "." "^linker.rs$")
- (("linker.env\\(\"LC_ALL\", \"C\"\\);")
- "linker.env(\"LC_ALL\", \"en_US.UTF-8\");")))))))))))
-
-(define rust-1.46
- (rust-bootstrapped-package
- rust-1.45 "1.46.0" "0a17jby2pd050s24cy4dfc0gzvgcl585v3vvyfilniyvjrqknsid"))
-
-(define rust-1.47
- (let ((base-rust (rust-bootstrapped-package
- rust-1.46 "1.47.0"
- "07fqd2vp7cf1ka3hr207dnnz93ymxml4935vp74g4is79h3dz19i")))
- (package/inherit base-rust
- (arguments
- (substitute-keyword-arguments (package-arguments base-rust)
- ((#:phases phases)
- `(modify-phases ,phases
- (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")))))))))))
-
-(define rust-1.48
- (rust-bootstrapped-package
- rust-1.47 "1.48.0" "0fz4gbb5hp5qalrl9lcl8yw4kk7ai7wx511jb28nypbxninkwxhf"))
-
-(define rust-1.49
- (rust-bootstrapped-package
- rust-1.48 "1.49.0" "0yf7kll517398dgqsr7m3gldzj0iwsp3ggzxrayckpqzvylfy2mm"))
-
-(define rust-1.50
- (rust-bootstrapped-package
- rust-1.49 "1.50.0" "0pjs7j62maiyvkmhp9zrxl528g2n0fphp4rq6ap7aqdv0a6qz5wm"))
-
-(define rust-1.51
- (rust-bootstrapped-package
- rust-1.50 "1.51.0" "0ixqkqglv3isxbvl4ldr4byrkx692wghsz3fasy1pn5kr2prnsvs"))
-
-;;; The LLVM requiriment has been bumped to version 10 in Rust 1.52. Use the
-;;; latest available.
-(define rust-1.52
- (let ((base-rust (rust-bootstrapped-package
- rust-1.51 "1.52.1"
- "165zs3xzp9dravybwslqs1qhn35agp6wacmzpymqg3qfdni26vrs")))
- (package
- (inherit base-rust)
- (inputs (alist-replace "llvm" (list llvm-12)
- (package-inputs base-rust))))))
-
-(define rust-1.53
- (rust-bootstrapped-package
- rust-1.52 "1.53.0" "1f95p259dfp5ca118bg107rj3rqwlswy65dxn3hg8sqgl4wwmxsw"))
-
-(define rust-1.54
- (let ((base-rust
- (rust-bootstrapped-package
- rust-1.53
- "1.54.0" "0xk9dhfff16caambmwij67zgshd8v9djw6ha0fnnanlv7rii31dc")))
- (package/inherit base-rust
- (source
- (origin
- (inherit (package-source base-rust))
- (snippet '(delete-file-recursively "src/llvm-project")))))))
-
-(define rust-1.55
- (rust-bootstrapped-package
- rust-1.54 "1.55.0" "07l28f7grdmi65naq71pbmvdd61hwcpi40ry7kp7dy7m233rldxj"))
-
(define rust-1.56
(rust-bootstrapped-package
rust-1.55 "1.56.1" "04cmqx7nn63hzz7z27b2b0dj2qx18rck9ifvip43s6dampx8v2f3"))
--
2.34.0