Skip to content

Commit

Permalink
Bug 1945020 - build(rust): bump minimum Rust version 1.76 → 1.82 r=gl…
Browse files Browse the repository at this point in the history
…andium

…but for ASAN/TSAN, use a hack: a 1.82.0 nightly commit that tolerates
`unsafe extern` blocks, but doesn't break our current toolchain patches.

We also remove the `host_or_target_str` check in
`build/moz.configure/toolchain.configure`, at @glandium's suggestion. To
quote him:

> [This] essentially undoes bug 1806040 but that bug predates other
> linker related changes, and I think the discrepancy host/target is not
> necessary anymore.

Differential Revision: https://phabricator.services.mozilla.com/D236028
  • Loading branch information
ErichDonGubler committed Feb 25, 2025
1 parent 21aad97 commit 8fa1b77
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ exclude = [
resolver = "2"

[workspace.package]
rust-version = "1.76.0"
rust-version = "1.82.0"

[workspace.dependencies]
# Shared across multiple UniFFI consumers.
Expand Down
35 changes: 35 additions & 0 deletions build/build-rust/rust-compiler-intrinsics.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
The version of `rustc` we build had some `compiler-builtins` updates that broke stuff. Later version
of rustc in the 1.82 train landed more `compiler-builtins` updates that unbroke the stuff. We need at
least some of that to make the version of rustc we landed on work.

See also: <https://github.com/rust-lang/rust/pull/128691>

diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
index 479eb0a2ba..82d5893dc5 100644
--- a/library/alloc/Cargo.toml
+++ b/library/alloc/Cargo.toml
@@ -10,10 +10,7 @@

[dependencies]
core = { path = "../core" }
-compiler_builtins = { version = "0.1.114", features = ['rustc-dep-of-std'] }
-
-[target.'cfg(not(any(target_arch = "aarch64", target_arch = "x86", target_arch = "x86_64")))'.dependencies]
-compiler_builtins = { version = "0.1.114", features = ["no-f16-f128"] }
+compiler_builtins = { version = "0.1.117", features = ['rustc-dep-of-std'] }

[dev-dependencies]
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }
diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml
index fe601855cc..06e818fb7c 100644
--- a/library/std/Cargo.toml
+++ b/library/std/Cargo.toml
@@ -17,7 +17,7 @@
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
-compiler_builtins = { version = "0.1.114" }
+compiler_builtins = { version = "0.1.117" }
profiler_builtins = { path = "../profiler_builtins", optional = true }
unwind = { path = "../unwind" }
hashbrown = { version = "0.14", default-features = false, features = [
28 changes: 16 additions & 12 deletions build/build-rust/rust-vendor-std.patch
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
Teaches Rust's build system to vendor std's dependencies into the
rust-src component.
Teaches Rust's build system to vendor `std`'s dependencies into the
`rust-src` component.

This was originally landed in https://github.com/rust-lang/rust/pull/78790
This was originally landed in <https://github.com/rust-lang/rust/pull/78790>,
but was backed out for causing some breakage for distro maintainers who
need to build Rust itself in a vendored/offline context. It doesn't actually
fetch anything interesting from crates.io, just the magic fake std/core crates
fetch anything interesting from Crates.io, just the magic fake `std`/`core` crates
that exist to make the build work right. Those crates *are* vendored but
their contents are ignored in favour of the actual stdlib.

For firefox's purposes, these patches still work fine, and are necessary
to make -Zbuild-std work in a vendored environment.
For Firefox's purposes, these patches still work fine, and are necessary
to make `-Zbuild-std` work in a vendored environment.

diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index 012d64e5344..aedb53358ef 100644
index 58f86aa996d..ef8c1584011 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -927,6 +927,31 @@ fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
@@ -941,6 +941,35 @@ fn run(self, builder: &Builder<'_>) -> GeneratedTarball {
builder.copy_link(&builder.src.join(file), &dst_src.join(file));
}

Expand All @@ -40,18 +40,22 @@ index 012d64e5344..aedb53358ef 100644
+ cmd.env("RUSTC_BOOTSTRAP", "1");
+ builder.info("Dist src");
+ let _time = timeit(builder);
+ builder.run(&mut cmd);
+ builder.run(
+ &mut cmd,
+ crate::utils::exec::OutputMode::Print,
+ crate::utils::exec::OutputMode::Print,
+ );
+
+ builder.remove(&temp_lock);
+
tarball.generate()
}
}
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
index 5ed6b357e20..ad617948c4b 100644
index 453fb39327d..af579af9eca 100644
--- a/src/bootstrap/src/lib.rs
+++ b/src/bootstrap/src/lib.rs
@@ -1649,6 +1649,30 @@ fn read_stamp_file(&self, stamp: &Path) -> Vec<(PathBuf, DependencyType)> {
@@ -1732,6 +1732,30 @@ fn read_stamp_file(&self, stamp: &Path) -> Vec<(PathBuf, DependencyType)> {
paths
}

Expand All @@ -65,7 +69,7 @@ index 5ed6b357e20..ad617948c4b 100644
+ if src == dst {
+ return;
+ }
+ let _ = fs::remove_file(&dst);
+ let _ = fs::remove_file(dst);
+ let metadata = t!(src.symlink_metadata());
+ if let Err(e) = fs::copy(src, dst) {
+ panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
Expand Down
6 changes: 1 addition & 5 deletions build/moz.configure/toolchain.configure
Original file line number Diff line number Diff line change
Expand Up @@ -2052,11 +2052,7 @@ def select_linker_tmpl(host_or_target):
and (
(
target.kernel != "Darwin"
and (
developer_options
or host_or_target_str == "host"
or c_compiler.version >= "15.0"
)
and (developer_options or c_compiler.version >= "15.0")
)
or (
target.kernel == "Darwin"
Expand Down
2 changes: 1 addition & 1 deletion docs/writing-rust-code/update-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Here are the Rust versions for each Firefox version.
| Firefox 135 | Rust 1.83.0 | 1.76.0 | 2024 November 28 | 2025 January 2 | 2025 February 4
| Firefox 136 | Rust 1.84.0 | 1.76.0 | 2025 January 9 | 2025 January 30 | 2025 March 4
| **Estimated** |
| Firefox 137 | Rust 1.85.0 | ? | 2025 February 20 | 2025 February 27 | 2025 April 1
| Firefox 137 | Rust 1.85.0 | 1.82.0 | 2025 February 20 | 2025 February 27 | 2025 April 1
| Firefox 138 | Rust 1.85.0 | ? | 2025 February 20 | 2025 March 27 | 2025 April 29
| Firefox 139 | Rust 1.86.0 | ? | 2025 April 3 | 2025 April 24 | 2025 May 27
| Firefox 140 | Rust 1.87.0 | ? | 2025 May 15 | 2025 May 22 | 2025 June 24
2 changes: 1 addition & 1 deletion python/mozboot/mozboot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from mach.util import get_state_dir

# Keep in sync with rust-version in top-level Cargo.toml.
MINIMUM_RUST_VERSION = "1.76.0"
MINIMUM_RUST_VERSION = "1.82.0"


def get_tools_dir(srcdir=False):
Expand Down
5 changes: 4 additions & 1 deletion taskcluster/kinds/fetch/toolchains.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,10 @@ rust-1.81.0:
type: git
include-dot-git: true
repo: https://github.com/rust-lang/rust/
revision: eeb90cda1969383f56a2637cbd3037bdf598841c
# NOTE: This is 1.81.0 and then some, to accommodate compiling some 1.82.0 code without
# breaking patches we use for sanitizers. See
# <https://bugzilla.mozilla.org/show_bug.cgi?id=1915537> for follow-up.
revision: ab1527f1d6560168f9fd36fa8cd7ba677c1d36ad

rust-nightly:
description: Rust nightly source code
Expand Down
8 changes: 5 additions & 3 deletions taskcluster/kinds/toolchain/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ task-defaults:
script: repack_rust.py
toolchain-artifact: public/build/rustc.tar.zst

linux64-rust-1.76:
linux64-rust-1.82:
treeherder:
symbol: TL(rust-1.76)
symbol: TL(rust-1.82)
run:
arguments: [
'--channel', '1.76.0',
'--channel', '1.82.0',
'--host', 'x86_64-unknown-linux-gnu',
'--target', 'x86_64-unknown-linux-gnu',
'--target', 'i686-unknown-linux-gnu',
Expand Down Expand Up @@ -110,13 +110,15 @@ linux64-rust-1.81-dev:
RUSTFLAGS_NOT_BOOTSTRAP: '-Clink-arg=-Wl,--undefined-version'
run:
arguments: [
'--patch', 'rust-compiler-intrinsics.patch',
'--patch', 'rust-vendor-std.patch',
'--patch', 'src/tools/cargo:cargo-vendor-std-1.79.patch',
'--channel', 'dev',
'--host', 'x86_64-unknown-linux-gnu',
'--target', 'x86_64-unknown-linux-gnu',
]
resources:
- build/build-rust/rust-compiler-intrinsics.patch
- build/build-rust/rust-vendor-std.patch
- build/build-rust/cargo-vendor-std-1.79.patch
toolchain-alias:
Expand Down

0 comments on commit 8fa1b77

Please sign in to comment.