From 7672b83df3c03681271fd5cbbe0684f860f0e590 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 4 Aug 2026 14:41:47 -0700 Subject: [PATCH 01/49] Upgrade and deduplicate dependencies - Upgrade from `getrandom v0.4.2` to `v0.4.3` to drop its `wasip2` and `wasip3` dependencies and many transitives. - Upgrade from `gimli v0.33` to `v0.34` as a direct dependency and through a `thorin-dwp` upgrade. - Upgrade from `object v0.37` and `v0.38` to `v0.39` as a direct dependency and via `ar_archive_writer` and `thorin-dwp` upgrades. - Upgrade `libloading` and `wasmparser` to match other dependencies. This also consolidates from `hashbrown v0.15`, `v0.16`, and `v0.17` to just `v0.17.1`, which is the same that `std` currently uses. --- Cargo.lock | 297 +++--------------- compiler/rustc_codegen_gcc/Cargo.lock | 4 +- compiler/rustc_codegen_gcc/Cargo.toml | 2 +- compiler/rustc_codegen_llvm/Cargo.toml | 4 +- compiler/rustc_codegen_ssa/Cargo.toml | 6 +- .../src/back/link/raw_dylib.rs | 6 +- compiler/rustc_metadata/Cargo.toml | 2 +- compiler/rustc_metadata/src/host_dylib.rs | 2 +- compiler/rustc_target/Cargo.toml | 2 +- src/bootstrap/Cargo.lock | 4 +- src/bootstrap/Cargo.toml | 2 +- src/bootstrap/src/utils/proc_macro_deps.rs | 19 +- src/tools/run-make-support/Cargo.toml | 6 +- src/tools/tidy/src/deps.rs | 3 +- .../duplicated-path-in-error.gnu.stderr | 2 +- 15 files changed, 71 insertions(+), 290 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60988e0ff4bc1..e63c0027f449a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,11 +177,11 @@ checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "ar_archive_writer" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4087686b4b0a3427190bae57a1d9a478dbb2d40c5dc1bd6e2b6d797913bdd348" +checksum = "73cd58deff2140a0a8eae87e417bd01db68a33e148aa93d1e8cd837e55e312b6" dependencies = [ - "object 0.37.3", + "object 0.39.1", ] [[package]] @@ -1603,16 +1603,14 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", "rand_core 0.10.1", - "wasip2", - "wasip3", ] [[package]] @@ -1623,12 +1621,12 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "gimli" -version = "0.33.0" +version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7f043f89559805f8c7cacc432749b2fa0d0a0a9ee46ce47164ed5ba7f126c" +checksum = "1033caf0b349c518623b5396bfb2cf0bddf44f0306d543a250e5743297aafd10" dependencies = [ "fnv", - "hashbrown 0.16.1", + "hashbrown", "indexmap", "stable_deref_trait", ] @@ -1678,31 +1676,13 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - -[[package]] -name = "hashbrown" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "allocator-api2", "equivalent", "foldhash 0.2.0", -] - -[[package]] -name = "hashbrown" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" -dependencies = [ - "foldhash 0.2.0", "serde", "serde_core", ] @@ -1996,7 +1976,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" dependencies = [ "equivalent", - "hashbrown 0.17.0", + "hashbrown", "serde", "serde_core", ] @@ -2319,16 +2299,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "libloading" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" -dependencies = [ - "cfg-if", - "windows-link 0.2.1", -] - [[package]] name = "libloading" version = "0.9.0" @@ -2563,11 +2533,11 @@ dependencies = [ "colored", "directories", "genmc-sys", - "getrandom 0.4.2", + "getrandom 0.4.3", "ipc-channel", "libc", "libffi", - "libloading 0.9.0", + "libloading", "measureme", "mio", "nix", @@ -2779,26 +2749,17 @@ dependencies = [ [[package]] name = "object" -version = "0.37.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe" -dependencies = [ - "memchr", -] - -[[package]] -name = "object" -version = "0.38.1" +version = "0.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "271638cd5fa9cca89c4c304675ca658efc4e64a66c716b7cfe1afb4b9611dbbc" +checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" dependencies = [ "crc32fast", "flate2", - "hashbrown 0.16.1", + "hashbrown", "indexmap", "memchr", "ruzstd", - "wasmparser 0.243.0", + "wasmparser 0.247.0", ] [[package]] @@ -3162,16 +3123,6 @@ dependencies = [ "owo-colors", ] -[[package]] -name = "prettyplease" -version = "0.2.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" -dependencies = [ - "proc-macro2", - "syn 2.0.117", -] - [[package]] name = "proc-macro-hack" version = "0.5.20+deprecated" @@ -3293,7 +3244,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2e8e8bcc7961af1fdac401278c6a831614941f6164ee3bf4ce61b7edb162207" dependencies = [ "chacha20", - "getrandom 0.4.2", + "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -3477,7 +3428,7 @@ checksum = "d9776093b7ca170454ab1406954f7b7d97a57c51dc6c0642957fb2ef25c2d399" dependencies = [ "bytecheck", "bytes", - "hashbrown 0.17.0", + "hashbrown", "indexmap", "munge", "ptr_meta", @@ -3505,15 +3456,15 @@ version = "0.0.0" dependencies = [ "bstr", "build_helper", - "gimli 0.33.0", + "gimli 0.34.0", "libc", - "object 0.38.1", + "object 0.39.1", "regex", "rustdoc-json-types", "serde_json", "similar", "tempfile", - "wasmparser 0.243.0", + "wasmparser 0.247.0", ] [[package]] @@ -3807,12 +3758,12 @@ name = "rustc_codegen_llvm" version = "0.0.0" dependencies = [ "bitflags", - "gimli 0.33.0", + "gimli 0.34.0", "itertools", "libc", - "libloading 0.9.0", + "libloading", "measureme", - "object 0.38.1", + "object 0.39.1", "rustc-demangle", "rustc_abi", "rustc_ast", @@ -3846,7 +3797,7 @@ dependencies = [ "find-msvc-tools", "itertools", "libc", - "object 0.38.1", + "object 0.39.1", "pathdiff", "regex", "rustc_abi", @@ -3876,7 +3827,7 @@ dependencies = [ "tempfile", "thorin-dwp", "tracing", - "wasm-encoder 0.219.2", + "wasm-encoder 0.247.0", "windows 0.61.3", ] @@ -3912,7 +3863,7 @@ dependencies = [ "either", "elsa", "ena", - "hashbrown 0.17.0", + "hashbrown", "indexmap", "jobserver", "libc", @@ -4376,7 +4327,7 @@ version = "0.0.0" dependencies = [ "bitflags", "libc", - "libloading 0.8.9", + "libloading", "odht", "rustc_abi", "rustc_ast", @@ -4809,7 +4760,7 @@ version = "0.0.0" dependencies = [ "arrayvec", "bitflags", - "object 0.38.1", + "object 0.39.1", "rustc_abi", "rustc_data_structures", "rustc_error_messages", @@ -5650,13 +5601,14 @@ dependencies = [ [[package]] name = "thorin-dwp" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce6b46108e50803d2c10216929e49fa3eda07ee3dc246310c18c4a1e3b1fa58" +checksum = "b5938a79ecf9cb8198d525ddb37cd8841f66ab98073f6a123af7ed7cdcbb73ae" dependencies = [ - "gimli 0.33.0", - "hashbrown 0.16.1", - "object 0.38.1", + "gimli 0.34.0", + "hashbrown", + "itertools", + "object 0.39.1", "tracing", ] @@ -6301,24 +6253,6 @@ version = "46.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b6c48003fe59c201c97a7786ff55feabe6b6f83b598aa9ff5bcc4f94d940bf3" -[[package]] -name = "wasip2" -version = "1.0.3+wasi-0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" -dependencies = [ - "wit-bindgen 0.57.1", -] - -[[package]] -name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" -dependencies = [ - "wit-bindgen 0.51.0", -] - [[package]] name = "wasm-bindgen" version = "0.2.105" @@ -6381,8 +6315,8 @@ dependencies = [ "wat", "windows-sys 0.61.2", "winsplit", - "wit-component 0.254.0", - "wit-parser 0.254.0", + "wit-component", + "wit-parser", ] [[package]] @@ -6394,22 +6328,12 @@ dependencies = [ [[package]] name = "wasm-encoder" -version = "0.219.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aa79bcd666a043b58f5fa62b221b0b914dd901e6f620e8ab7371057a797f3e1" -dependencies = [ - "leb128", - "wasmparser 0.219.2", -] - -[[package]] -name = "wasm-encoder" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +checksum = "30b6733b8b91d010a6ac5b0fb237dc46a19650bc4c67db66857e2e787d437204" dependencies = [ "leb128fmt", - "wasmparser 0.244.0", + "wasmparser 0.247.0", ] [[package]] @@ -6422,18 +6346,6 @@ dependencies = [ "wasmparser 0.254.0", ] -[[package]] -name = "wasm-metadata" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" -dependencies = [ - "anyhow", - "indexmap", - "wasm-encoder 0.244.0", - "wasmparser 0.244.0", -] - [[package]] name = "wasm-metadata" version = "0.254.0" @@ -6448,33 +6360,12 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.219.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5220ee4c6ffcc0cb9d7c47398052203bc902c8ef3985b0c8134118440c0b2921" -dependencies = [ - "bitflags", - "indexmap", -] - -[[package]] -name = "wasmparser" -version = "0.243.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6d8db401b0528ec316dfbe579e6ab4152d61739cfe076706d2009127970159d" +checksum = "8e6fb4c2bee46c5ea4d40f8cdb5c131725cd976718ec56f1c8e82fbde5fa2a80" dependencies = [ "bitflags", "indexmap", -] - -[[package]] -name = "wasmparser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" -dependencies = [ - "bitflags", - "hashbrown 0.15.5", - "indexmap", "semver", ] @@ -6485,7 +6376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5769a29f799fbab136aaf65b4fe5384cd7d93fe6fc9ba0dcb6c8382a1f16e27" dependencies = [ "bitflags", - "hashbrown 0.17.0", + "hashbrown", "indexmap", "semver", "serde", @@ -6869,32 +6760,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ab703352da6a72f35c39a533526393725640575bb211f61987a2748323ad956" -[[package]] -name = "wit-bindgen" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "wit-bindgen-rust-macro", -] - -[[package]] -name = "wit-bindgen" -version = "0.57.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" - -[[package]] -name = "wit-bindgen-core" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" -dependencies = [ - "anyhow", - "heck", - "wit-parser 0.244.0", -] - [[package]] name = "wit-bindgen-rt" version = "0.39.0" @@ -6904,56 +6769,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "wit-bindgen-rust" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" -dependencies = [ - "anyhow", - "heck", - "indexmap", - "prettyplease", - "syn 2.0.117", - "wasm-metadata 0.244.0", - "wit-bindgen-core", - "wit-component 0.244.0", -] - -[[package]] -name = "wit-bindgen-rust-macro" -version = "0.51.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" -dependencies = [ - "anyhow", - "prettyplease", - "proc-macro2", - "quote", - "syn 2.0.117", - "wit-bindgen-core", - "wit-bindgen-rust", -] - -[[package]] -name = "wit-component" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" -dependencies = [ - "anyhow", - "bitflags", - "indexmap", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-encoder 0.244.0", - "wasm-metadata 0.244.0", - "wasmparser 0.244.0", - "wit-parser 0.244.0", -] - [[package]] name = "wit-component" version = "0.254.0" @@ -6968,27 +6783,9 @@ dependencies = [ "serde_derive", "serde_json", "wasm-encoder 0.254.0", - "wasm-metadata 0.254.0", + "wasm-metadata", "wasmparser 0.254.0", - "wit-parser 0.254.0", -] - -[[package]] -name = "wit-parser" -version = "0.244.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" -dependencies = [ - "anyhow", - "id-arena", - "indexmap", - "log", - "semver", - "serde", - "serde_derive", - "serde_json", - "unicode-xid", - "wasmparser 0.244.0", + "wit-parser", ] [[package]] @@ -6998,7 +6795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1655131e4f7d3f0cb141f6eca71315ca40eff0f3d4de7cff0a82bacedd8c89b4" dependencies = [ "anyhow", - "hashbrown 0.17.0", + "hashbrown", "id-arena", "indexmap", "log", diff --git a/compiler/rustc_codegen_gcc/Cargo.lock b/compiler/rustc_codegen_gcc/Cargo.lock index a283ea4cb0b05..7ce94b58c0516 100644 --- a/compiler/rustc_codegen_gcc/Cargo.lock +++ b/compiler/rustc_codegen_gcc/Cargo.lock @@ -145,9 +145,9 @@ dependencies = [ [[package]] name = "object" -version = "0.37.1" +version = "0.39.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03fd943161069e1768b4b3d050890ba48730e590f57e56d4aa04e7e090e61b4a" +checksum = "2e5a6c098c7a3b6547378093f5cc30bc54fd361ce711e05293a5cc589562739b" dependencies = [ "memchr", ] diff --git a/compiler/rustc_codegen_gcc/Cargo.toml b/compiler/rustc_codegen_gcc/Cargo.toml index 8956bd6948979..ac5e94b9454e2 100644 --- a/compiler/rustc_codegen_gcc/Cargo.toml +++ b/compiler/rustc_codegen_gcc/Cargo.toml @@ -18,7 +18,7 @@ master = ["gccjit/master"] default = ["master"] [dependencies] -object = { version = "0.37.0", default-features = false, features = ["std", "read"] } +object = { version = "0.39.0", default-features = false, features = ["std", "read"] } tempfile = "3.20" gccjit = { version = "3.3.0", features = ["dlopen"] } #gccjit = { git = "https://github.com/rust-lang/gccjit.rs", branch = "error-dlopen", features = ["dlopen"] } diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index f085eba9d5307..f2b0d2f36dc78 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -11,12 +11,12 @@ test = false bitflags = "2.4.1" # To avoid duplicate dependencies, this should match the version of gimli used # by `rustc_codegen_ssa` via its `thorin-dwp` dependency. -gimli = "0.33" +gimli = "0.34" itertools = "0.15" libc = "0.2" libloading = { version = "0.9.0" } measureme = "12.0.1" -object = { version = "0.38.1", default-features = false, features = ["std", "read"] } +object = { version = "0.39.1", default-features = false, features = ["std", "read"] } rustc-demangle = "0.1.28" rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index f33d144ac5c63..01c9e09a56544 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -37,9 +37,9 @@ rustc_trait_selection = { path = "../rustc_trait_selection" } serde_json = "1.0.59" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } tempfile = "3.2" -thorin-dwp = "0.10" +thorin-dwp = "0.11" tracing = "0.1" -wasm-encoder = "0.219" +wasm-encoder = "0.247" # tidy-alphabetical-end [target.'cfg(unix)'.dependencies] @@ -48,7 +48,7 @@ libc = "0.2.50" # tidy-alphabetical-end [dependencies.object] -version = "0.38.1" +version = "0.39.1" default-features = false features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive", "write", "wasm"] diff --git a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs index f8cc07201d10f..778133466610e 100644 --- a/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs +++ b/compiler/rustc_codegen_ssa/src/back/link/raw_dylib.rs @@ -477,13 +477,13 @@ fn create_elf_raw_dylib_stub(sess: &Session, soname: &str, symbols: &[DllImport] // the DT_SONAME will be used by the linker to populate DT_NEEDED // which the loader uses to find the library. stub.write_align_dynamic(); - stub.write_dynamic_string(elf::DT_SONAME, soname); + stub.write_dynamic_string(elf::DT_SONAME, soname).unwrap(); // LSB section "2.7. Symbol Versioning" requires `DT_VERDEFNUM` to be reliable. if verdef_count > 1 { - stub.write_dynamic(elf::DT_VERDEFNUM, verdef_count as u64); + stub.write_dynamic(elf::DT_VERDEFNUM, verdef_count as u64).unwrap(); } // DT_NULL terminates the .dynamic table. - stub.write_dynamic(elf::DT_NULL, 0); + stub.write_dynamic(elf::DT_NULL, 0).unwrap(); stub_buf } diff --git a/compiler/rustc_metadata/Cargo.toml b/compiler/rustc_metadata/Cargo.toml index 2fce131e08b6a..1bb01e08a207d 100644 --- a/compiler/rustc_metadata/Cargo.toml +++ b/compiler/rustc_metadata/Cargo.toml @@ -6,7 +6,7 @@ edition = "2024" [dependencies] # tidy-alphabetical-start bitflags = "2.4.1" -libloading = "0.8.0" +libloading = "0.9.0" odht = { version = "0.3.1", features = ["nightly"] } rustc_abi = { path = "../rustc_abi" } rustc_ast = { path = "../rustc_ast" } diff --git a/compiler/rustc_metadata/src/host_dylib.rs b/compiler/rustc_metadata/src/host_dylib.rs index 9bd2a57fcd285..8f446d2651207 100644 --- a/compiler/rustc_metadata/src/host_dylib.rs +++ b/compiler/rustc_metadata/src/host_dylib.rs @@ -33,7 +33,7 @@ fn attempt_load_dylib(path: &Path) -> Result pub static CRATES: &[&str] = &[ // tidy-alphabetical-start - "anyhow", + "allocator_api2", "askama_derive", "askama_parser", "basic_toml", - "bitflags", "block_buffer", "bumpalo", "cfg_if", @@ -27,32 +26,24 @@ pub static CRATES: &[&str] = &[ "glob", "hashbrown", "heck", - "id_arena", "ident_case", "indexmap", "intl_memoizer", "intl_pluralrules", - "itoa", - "leb128fmt", "libc", - "log", "memchr", "minimal_lexical", "nom", "pest", "pest_generator", "pest_meta", - "prettyplease", "proc_macro2", "quote", "rustc_hash", - "ryu", "self_cell", - "semver", "serde", "serde_core", "serde_derive_internals", - "serde_json", "sha2", "smallvec", "stable_deref_trait", @@ -68,18 +59,10 @@ pub static CRATES: &[&str] = &[ "unic_langid_impl", "unic_langid_macros", "unicode_ident", - "unicode_xid", "version_check", "wasm_bindgen_macro_support", "wasm_bindgen_shared", - "wasm_encoder", - "wasm_metadata", - "wasmparser", "winnow", - "wit_bindgen_core", - "wit_bindgen_rust", - "wit_component", - "wit_parser", "yoke", "zerofrom", "zerovec", diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml index 697652012d48c..0e1310862589d 100644 --- a/src/tools/run-make-support/Cargo.toml +++ b/src/tools/run-make-support/Cargo.toml @@ -11,14 +11,14 @@ edition = "2024" # tidy-alphabetical-start bstr = "1.12" -gimli = "0.33" +gimli = "0.34" libc = "0.2" -object = { version = "0.38.1", features = ["wasm"] } +object = { version = "0.39.1", features = ["wasm"] } regex = "1.11" serde_json = "1.0" similar = "2.7" tempfile = "3" -wasmparser = { version = "0.243", default-features = false, features = ["std", "features", "validate"] } +wasmparser = { version = "0.247", default-features = false, features = ["std", "features", "validate"] } # tidy-alphabetical-end # Shared with bootstrap and compiletest diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 3d2f118de1b93..721dcb851035a 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -370,7 +370,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "jiff-tzdb-platform", "jobserver", "lazy_static", - "leb128", + "leb128fmt", "libc", "libloading", "linux-raw-sys", @@ -432,6 +432,7 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[ "scoped-tls", "scopeguard", "self_cell", + "semver", "serde", "serde_core", "serde_derive", diff --git a/tests/ui/codegen/duplicated-path-in-error.gnu.stderr b/tests/ui/codegen/duplicated-path-in-error.gnu.stderr index d0d34e2f93468..ed8b9f6a962d1 100644 --- a/tests/ui/codegen/duplicated-path-in-error.gnu.stderr +++ b/tests/ui/codegen/duplicated-path-in-error.gnu.stderr @@ -1,2 +1,2 @@ -error: couldn't load codegen backend /non-existing-one.so: cannot open shared object file: No such file or directory +error: couldn't load codegen backend /non-existing-one.so: dlopen failed: /non-existing-one.so: cannot open shared object file: No such file or directory From c234ba35f6a14aa3ff6374e16f9af672be672d2e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sun, 9 Aug 2026 14:56:55 -0700 Subject: [PATCH 02/49] Update run-make/wasm tests --- tests/run-make/wasm-import-module/rmake.rs | 2 +- tests/run-make/wasm-spurious-import/rmake.rs | 2 +- tests/run-make/wasm-symbols-different-module/rmake.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run-make/wasm-import-module/rmake.rs b/tests/run-make/wasm-import-module/rmake.rs index 3b74cb205589d..77614ce1ceb86 100644 --- a/tests/run-make/wasm-import-module/rmake.rs +++ b/tests/run-make/wasm-import-module/rmake.rs @@ -15,7 +15,7 @@ fn main() { for payload in wasmparser::Parser::new(0).parse_all(&file) { let payload = payload.unwrap(); if let wasmparser::Payload::ImportSection(s) = payload { - for i in s { + for i in s.into_imports() { let i = i.unwrap(); imports.entry(i.module).or_insert(Vec::new()).push((i.name, i.ty)); } diff --git a/tests/run-make/wasm-spurious-import/rmake.rs b/tests/run-make/wasm-spurious-import/rmake.rs index 8fde8d295c7e2..435c6219aa502 100644 --- a/tests/run-make/wasm-spurious-import/rmake.rs +++ b/tests/run-make/wasm-spurious-import/rmake.rs @@ -20,7 +20,7 @@ fn main() { for payload in wasmparser::Parser::new(0).parse_all(&file) { let payload = payload.unwrap(); if let wasmparser::Payload::ImportSection(s) = payload { - for i in s { + for i in s.into_imports() { let i = i.unwrap(); imports.entry(i.module).or_insert(Vec::new()).push((i.name, i.ty)); } diff --git a/tests/run-make/wasm-symbols-different-module/rmake.rs b/tests/run-make/wasm-symbols-different-module/rmake.rs index 3cd459db02fae..0e7113c3df8f9 100644 --- a/tests/run-make/wasm-symbols-different-module/rmake.rs +++ b/tests/run-make/wasm-symbols-different-module/rmake.rs @@ -30,7 +30,7 @@ fn test(file: &str, args: &[&str], expected_imports: &[(&str, &[&str])]) { for payload in wasmparser::Parser::new(0).parse_all(&file) { let payload = payload.unwrap(); if let wasmparser::Payload::ImportSection(s) = payload { - for i in s { + for i in s.into_imports() { let i = i.unwrap(); imports.entry(i.module).or_insert(HashSet::new()).insert(i.name); } From 377ef9f028c7853b70e21fdecf5f6d376d9031b5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 12 Aug 2026 23:52:29 +0200 Subject: [PATCH 03/49] Build newer binutils before building gcc --- src/ci/docker/scripts/build-gcc.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 6a96b82d3f924..bef169fafe38c 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -4,6 +4,13 @@ set -eux source shared.sh +BINUTILS="2.47" +curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - +cd binutils-$BINUTILS +hide_output ./configure +hide_output make +hide_output make install + # Note: in the future when bumping to version 10.1.0, also take care of the sed block below. # This version is specified in the Dockerfile GCC=$GCC_VERSION From 46eb4fde6a9eee926c46550031d8bd1b49c03d97 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Wed, 12 Aug 2026 18:52:28 +0000 Subject: [PATCH 04/49] clippy::needless_borrow --- library/alloc/src/boxed.rs | 2 +- library/alloc/src/collections/btree/map.rs | 6 +++--- library/alloc/src/collections/btree/node.rs | 2 +- library/alloc/src/collections/btree/set.rs | 4 ++-- library/alloc/src/io/impls.rs | 4 ++-- library/alloc/src/vec/splice.rs | 2 +- library/alloc/src/wtf8/mod.rs | 4 ++-- library/core/src/ffi/c_str.rs | 4 ++-- library/core/src/iter/traits/iterator.rs | 2 +- library/core/src/slice/ascii.rs | 2 +- library/core/src/slice/iter.rs | 2 +- library/core/src/str/iter.rs | 2 +- library/core/src/task/wake.rs | 4 ++-- library/std/src/ffi/os_str.rs | 10 +++++----- library/std/src/net/socket_addr.rs | 2 +- library/std/src/os/unix/net/ancillary.rs | 4 ++-- library/std/src/path.rs | 2 +- library/std/src/sync/nonpoison/rwlock.rs | 8 ++++---- library/std/src/sync/poison/rwlock.rs | 8 ++++---- library/std/src/sys/fs/common.rs | 2 +- library/std/src/sys/fs/unix.rs | 4 ++-- library/std/src/sys/fs/unix/dir.rs | 2 +- library/std/src/sys/fs/windows.rs | 10 +++++----- library/std/src/sys/process/unix/common.rs | 2 +- 24 files changed, 47 insertions(+), 47 deletions(-) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index cd2508a76a10e..c25a06968e293 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2141,7 +2141,7 @@ impl Clone for Box<[T], A> { /// ``` fn clone_from(&mut self, source: &Self) { if self.len() == source.len() { - self.clone_from_slice(&source); + self.clone_from_slice(source); } else { *self = source.clone(); } diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 0a1f7738632c1..d8421d3c3f70a 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -1572,7 +1572,7 @@ impl BTreeMap { let right_root = left_root.split_off(key, (*self.alloc).clone()); - let (new_left_len, right_len) = Root::calc_split_length(total_num, &left_root, &right_root); + let (new_left_len, right_len) = Root::calc_split_length(total_num, left_root, &right_root); self.length = new_left_len; BTreeMap { @@ -2208,8 +2208,8 @@ impl<'a, K, V, R> ExtractIfInner<'a, K, V, R> { // On creation, we navigated directly to the left bound, so we need only check the // right bound here to decide whether to stop. match self.range.end_bound() { - Bound::Included(ref end) if (*k).le(end) => (), - Bound::Excluded(ref end) if (*k).lt(end) => (), + Bound::Included(end) if (*k).le(end) => (), + Bound::Excluded(end) if (*k).lt(end) => (), Bound::Unbounded => (), _ => return None, } diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs index 84dd4b7e49def..0c7afcc63b9b7 100644 --- a/library/alloc/src/collections/btree/node.rs +++ b/library/alloc/src/collections/btree/node.rs @@ -1430,7 +1430,7 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> { left_node.val_area_mut(old_left_len + 1..new_left_len), ); - slice_remove(&mut parent_node.edge_area_mut(..old_parent_len + 1), parent_idx + 1); + slice_remove(parent_node.edge_area_mut(..old_parent_len + 1), parent_idx + 1); parent_node.correct_childrens_parent_links(parent_idx + 1..old_parent_len); *parent_node.len_mut() -= 1; diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 2a483b3d3982e..d06daa7c6c1b7 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1971,7 +1971,7 @@ impl<'a, T: Ord, A: Allocator + Clone> Iterator for Difference<'a, T, A> { } DifferenceInner::Search { self_iter, other_set } => loop { let self_next = self_iter.next()?; - if !other_set.contains(&self_next) { + if !other_set.contains(self_next) { return Some(self_next); } }, @@ -2068,7 +2068,7 @@ impl<'a, T: Ord, A: Allocator + Clone> Iterator for Intersection<'a, T, A> { } IntersectionInner::Search { small_iter, large_set } => loop { let small_next = small_iter.next()?; - if large_set.contains(&small_next) { + if large_set.contains(small_next) { return Some(small_next); } }, diff --git a/library/alloc/src/io/impls.rs b/library/alloc/src/io/impls.rs index a6c9428ba62dc..dae6b3aa3371d 100644 --- a/library/alloc/src/io/impls.rs +++ b/library/alloc/src/io/impls.rs @@ -625,7 +625,7 @@ where #[inline] fn is_read_vectored(&self) -> bool { - (&**self).is_read_vectored() + (**self).is_read_vectored() } #[inline] @@ -667,7 +667,7 @@ where #[inline] fn is_write_vectored(&self) -> bool { - (&**self).is_write_vectored() + (**self).is_write_vectored() } #[inline] diff --git a/library/alloc/src/vec/splice.rs b/library/alloc/src/vec/splice.rs index 99ebcb4ada296..6436afd1ba12f 100644 --- a/library/alloc/src/vec/splice.rs +++ b/library/alloc/src/vec/splice.rs @@ -59,7 +59,7 @@ impl Drop for Splice<'_, I, A> { // Which means we can replace the slice::Iter with pointers that won't point to deallocated // memory, so that Drain::drop is still allowed to call iter.len(), otherwise it would break // the ptr.offset_from_unsigned contract. - self.drain.iter = (&[]).iter(); + self.drain.iter = [].iter(); unsafe { if self.drain.tail_len == 0 { diff --git a/library/alloc/src/wtf8/mod.rs b/library/alloc/src/wtf8/mod.rs index 394c41bf36727..36ec32c549763 100644 --- a/library/alloc/src/wtf8/mod.rs +++ b/library/alloc/src/wtf8/mod.rs @@ -284,7 +284,7 @@ impl Wtf8Buf { /// like concatenating ill-formed UTF-16 strings effectively would. #[inline] pub fn push_wtf8(&mut self, other: &Wtf8) { - match ((&*self).final_lead_surrogate(), other.initial_trail_surrogate()) { + match ((*self).final_lead_surrogate(), other.initial_trail_surrogate()) { // Replace newly paired surrogates by a supplementary code point. (Some(lead), Some(trail)) => { let len_without_lead_surrogate = self.len() - 3; @@ -322,7 +322,7 @@ impl Wtf8Buf { #[inline] pub fn push(&mut self, code_point: CodePoint) { if let Some(trail) = code_point.to_trail_surrogate() { - if let Some(lead) = (&*self).final_lead_surrogate() { + if let Some(lead) = (*self).final_lead_surrogate() { let len_without_lead_surrogate = self.len() - 3; self.bytes.truncate(len_without_lead_surrogate); self.push_char(decode_surrogate_pair(lead, trail)); diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index d3318b0863e6e..ae25e09230faa 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -682,7 +682,7 @@ impl PartialEq<&Self> for CStr { impl PartialOrd for CStr { #[inline] fn partial_cmp(&self, other: &CStr) -> Option { - self.to_bytes().partial_cmp(&other.to_bytes()) + self.to_bytes().partial_cmp(other.to_bytes()) } } @@ -690,7 +690,7 @@ impl PartialOrd for CStr { impl Ord for CStr { #[inline] fn cmp(&self, other: &CStr) -> Ordering { - self.to_bytes().cmp(&other.to_bytes()) + self.to_bytes().cmp(other.to_bytes()) } } diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 3867a44099f6d..e3fadd2363911 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -4082,7 +4082,7 @@ pub const trait Iterator { mut compare: impl FnMut(&T, &T) -> bool + 'a, ) -> impl FnMut(T) -> bool + 'a { move |curr| { - if !compare(&last, &curr) { + if !compare(last, &curr) { return false; } *last = curr; diff --git a/library/core/src/slice/ascii.rs b/library/core/src/slice/ascii.rs index bc99290a38dfc..2b6037b2ee53e 100644 --- a/library/core/src/slice/ascii.rs +++ b/library/core/src/slice/ascii.rs @@ -91,7 +91,7 @@ impl [u8] { let mut b = other; while let ([first_a, rest_a @ ..], [first_b, rest_b @ ..]) = (a, b) { - if first_a.eq_ignore_ascii_case(&first_b) { + if first_a.eq_ignore_ascii_case(first_b) { a = rest_a; b = rest_b; } else { diff --git a/library/core/src/slice/iter.rs b/library/core/src/slice/iter.rs index 6f75808015e71..a054c9d742c88 100644 --- a/library/core/src/slice/iter.rs +++ b/library/core/src/slice/iter.rs @@ -424,7 +424,7 @@ impl<'a, T: 'a, P: FnMut(&T) -> bool> Split<'a, T, P> { /// ``` #[unstable(feature = "split_as_slice", issue = "96137")] pub fn as_slice(&self) -> &'a [T] { - if self.finished { &[] } else { &self.v } + if self.finished { &[] } else { self.v } } } diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs index 70d9c7aef2a74..26c48d48d211e 100644 --- a/library/core/src/str/iter.rs +++ b/library/core/src/str/iter.rs @@ -1410,7 +1410,7 @@ impl<'a> SplitAsciiWhitespace<'a> { } // SAFETY: Slice is created from str. - Some(unsafe { crate::str::from_utf8_unchecked(&self.inner.iter.iter.v) }) + Some(unsafe { crate::str::from_utf8_unchecked(self.inner.iter.iter.v) }) } } diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs index 63b7691582a7d..473b185d24652 100644 --- a/library/core/src/task/wake.rs +++ b/library/core/src/task/wake.rs @@ -245,14 +245,14 @@ impl<'a> Context<'a> { #[stable(feature = "futures_api", since = "1.36.0")] #[rustc_const_stable(feature = "const_waker", since = "1.82.0")] pub const fn waker(&self) -> &'a Waker { - &self.waker + self.waker } /// Returns a reference to the [`LocalWaker`] for the current task. #[inline] #[unstable(feature = "local_waker", issue = "118959")] pub const fn local_waker(&self) -> &'a LocalWaker { - &self.local_waker + self.local_waker } /// Returns a reference to the extension data for the current task. diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 73fb3f54097fa..937bf0f119d3d 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -762,7 +762,7 @@ impl Eq for OsString {} impl PartialOrd for OsString { #[inline] fn partial_cmp(&self, other: &OsString) -> Option { - (&**self).partial_cmp(&**other) + (**self).partial_cmp(&**other) } #[inline] fn lt(&self, other: &OsString) -> bool { @@ -786,7 +786,7 @@ impl PartialOrd for OsString { impl PartialOrd for OsString { #[inline] fn partial_cmp(&self, other: &str) -> Option { - (&**self).partial_cmp(other) + (**self).partial_cmp(other) } } @@ -794,7 +794,7 @@ impl PartialOrd for OsString { impl Ord for OsString { #[inline] fn cmp(&self, other: &OsString) -> cmp::Ordering { - (&**self).cmp(&**other) + (**self).cmp(&**other) } } @@ -802,7 +802,7 @@ impl Ord for OsString { impl Hash for OsString { #[inline] fn hash(&self, state: &mut H) { - (&**self).hash(state) + (**self).hash(state) } } @@ -1777,7 +1777,7 @@ impl AsRef for str { impl AsRef for String { #[inline] fn as_ref(&self) -> &OsStr { - (&**self).as_ref() + (**self).as_ref() } } diff --git a/library/std/src/net/socket_addr.rs b/library/std/src/net/socket_addr.rs index 2dab8c26f1f6b..6aa625d66a363 100644 --- a/library/std/src/net/socket_addr.rs +++ b/library/std/src/net/socket_addr.rs @@ -257,6 +257,6 @@ impl ToSocketAddrs for &T { impl ToSocketAddrs for String { type Iter = vec::IntoIter; fn to_socket_addrs(&self) -> io::Result> { - (&**self).to_socket_addrs() + (**self).to_socket_addrs() } } diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index a9029f7fa0bfb..5d2cbd403ad20 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -744,7 +744,7 @@ impl<'a> SocketAncillary<'a> { pub fn add_fds(&mut self, fds: &[RawFd]) -> bool { self.truncated = false; add_to_ancillary_data( - &mut self.buffer, + self.buffer, &mut self.length, fds, libc::SOL_SOCKET, @@ -771,7 +771,7 @@ impl<'a> SocketAncillary<'a> { pub fn add_creds(&mut self, creds: &[SocketCred]) -> bool { self.truncated = false; add_to_ancillary_data( - &mut self.buffer, + self.buffer, &mut self.length, creds, libc::SOL_SOCKET, diff --git a/library/std/src/path.rs b/library/std/src/path.rs index be216d87f3241..8b41a3792ac9a 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2673,7 +2673,7 @@ impl Path { #[stable(feature = "path_ancestors", since = "1.28.0")] #[inline] pub fn ancestors(&self) -> Ancestors<'_> { - Ancestors { next: Some(&self) } + Ancestors { next: Some(self) } } /// Returns the final component of the `Path`, if there is one. diff --git a/library/std/src/sync/nonpoison/rwlock.rs b/library/std/src/sync/nonpoison/rwlock.rs index dc5d9479ba5a9..19064fdd1ce10 100644 --- a/library/std/src/sync/nonpoison/rwlock.rs +++ b/library/std/src/sync/nonpoison/rwlock.rs @@ -636,7 +636,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { // reference passed to it. If the closure panics, the guard will be dropped. let data = NonNull::from(f(unsafe { orig.data.as_ref() })); let orig = ManuallyDrop::new(orig); - MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } + MappedRwLockReadGuard { data, inner_lock: orig.inner_lock } } /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. The @@ -668,7 +668,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { Some(data) => { let data = NonNull::from(data); let orig = ManuallyDrop::new(orig); - Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + Ok(MappedRwLockReadGuard { data, inner_lock: orig.inner_lock }) } None => Err(orig), } @@ -861,7 +861,7 @@ impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T> { // reference passed to it. If the closure panics, the guard will be dropped. let data = NonNull::from(f(unsafe { orig.data.as_ref() })); let orig = ManuallyDrop::new(orig); - MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } + MappedRwLockReadGuard { data, inner_lock: orig.inner_lock } } /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. @@ -893,7 +893,7 @@ impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T> { Some(data) => { let data = NonNull::from(data); let orig = ManuallyDrop::new(orig); - Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + Ok(MappedRwLockReadGuard { data, inner_lock: orig.inner_lock }) } None => Err(orig), } diff --git a/library/std/src/sync/poison/rwlock.rs b/library/std/src/sync/poison/rwlock.rs index 4cfd9d19df74a..de1fedf88f63a 100644 --- a/library/std/src/sync/poison/rwlock.rs +++ b/library/std/src/sync/poison/rwlock.rs @@ -770,7 +770,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { // reference passed to it. If the closure panics, the guard will be dropped. let data = NonNull::from(f(unsafe { orig.data.as_ref() })); let orig = ManuallyDrop::new(orig); - MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } + MappedRwLockReadGuard { data, inner_lock: orig.inner_lock } } /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. The @@ -802,7 +802,7 @@ impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> { Some(data) => { let data = NonNull::from(data); let orig = ManuallyDrop::new(orig); - Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + Ok(MappedRwLockReadGuard { data, inner_lock: orig.inner_lock }) } None => Err(orig), } @@ -996,7 +996,7 @@ impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T> { // reference passed to it. If the closure panics, the guard will be dropped. let data = NonNull::from(f(unsafe { orig.data.as_ref() })); let orig = ManuallyDrop::new(orig); - MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock } + MappedRwLockReadGuard { data, inner_lock: orig.inner_lock } } /// Makes a [`MappedRwLockReadGuard`] for a component of the borrowed data. @@ -1028,7 +1028,7 @@ impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T> { Some(data) => { let data = NonNull::from(data); let orig = ManuallyDrop::new(orig); - Ok(MappedRwLockReadGuard { data, inner_lock: &orig.inner_lock }) + Ok(MappedRwLockReadGuard { data, inner_lock: orig.inner_lock }) } None => Err(orig), } diff --git a/library/std/src/sys/fs/common.rs b/library/std/src/sys/fs/common.rs index 68aed39d1dcdf..edc31d21ca1fa 100644 --- a/library/std/src/sys/fs/common.rs +++ b/library/std/src/sys/fs/common.rs @@ -72,7 +72,7 @@ impl Dir { } pub fn open_file(&self, path: &Path, opts: &OpenOptions) -> io::Result { - File::open(&self.path.join(path), &opts) + File::open(&self.path.join(path), opts) } pub fn metadata(&self) -> io::Result { diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs index cdd1ef6146fd9..393a4d13b603b 100644 --- a/library/std/src/sys/fs/unix.rs +++ b/library/std/src/sys/fs/unix.rs @@ -2415,7 +2415,7 @@ mod remove_dir_impl { fn remove_dir_all_recursive(parent_fd: Option, path: &CStr) -> io::Result<()> { // try opening as directory - let fd = match openat_nofollow_dironly(parent_fd, &path) { + let fd = match openat_nofollow_dironly(parent_fd, path) { Err(err) if matches!(err.raw_os_error(), Some(libc::ENOTDIR | libc::ELOOP)) => { // not a directory - don't traverse further // (for symlinks, older Linux kernels may return ELOOP instead of ENOTDIR) @@ -2485,7 +2485,7 @@ mod remove_dir_impl { if attr.file_type().is_symlink() { super::unlink(p) } else { - remove_dir_all_recursive(None, &p) + remove_dir_all_recursive(None, p) } } diff --git a/library/std/src/sys/fs/unix/dir.rs b/library/std/src/sys/fs/unix/dir.rs index f3f612a225ed1..13a17350ff7b9 100644 --- a/library/std/src/sys/fs/unix/dir.rs +++ b/library/std/src/sys/fs/unix/dir.rs @@ -38,7 +38,7 @@ impl Dir { } pub fn open_file(&self, path: &Path, opts: &OpenOptions) -> io::Result { - run_path_with_cstr(path.as_ref(), &|path| self.open_file_c(path, &opts)) + run_path_with_cstr(path.as_ref(), &|path| self.open_file_c(path, opts)) } pub fn metadata(&self) -> io::Result { diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs index ef76a038c1fb5..9023d1f1c8338 100644 --- a/library/std/src/sys/fs/windows.rs +++ b/library/std/src/sys/fs/windows.rs @@ -339,7 +339,7 @@ impl File { let path = maybe_verbatim(path)?; // SAFETY: maybe_verbatim returns null-terminated strings let path = unsafe { WCStr::from_wchars_with_null_unchecked(&path) }; - Self::open_native(&path, opts) + Self::open_native(path, opts) } fn open_native(path: &WCStr, opts: &OpenOptions) -> io::Result { @@ -1305,7 +1305,7 @@ pub fn unlink(path: &WCStr) -> io::Result<()> { let mut opts = OpenOptions::new(); opts.access_mode(c::DELETE); opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT); - if let Ok(f) = File::open_native(&path, &opts) { + if let Ok(f) = File::open_native(path, &opts) { if f.posix_delete().is_ok() { return Ok(()); } @@ -1328,7 +1328,7 @@ pub fn rename(old: &WCStr, new: &WCStr) -> io::Result<()> { let mut opts = OpenOptions::new(); opts.access_mode(c::DELETE); opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT | c::FILE_FLAG_BACKUP_SEMANTICS); - let Ok(f) = File::open_native(&old, &opts) else { return Err(err).io_result() }; + let Ok(f) = File::open_native(old, &opts) else { return Err(err).io_result() }; // Calculate the layout of the `FILE_RENAME_INFO` we pass to `SetFileInformation` // This is a dynamically sized struct so we need to get the position of the last field to calculate the actual size. @@ -1419,7 +1419,7 @@ pub fn readlink(path: &WCStr) -> io::Result { let mut opts = OpenOptions::new(); opts.access_mode(0); opts.custom_flags(c::FILE_FLAG_OPEN_REPARSE_POINT | c::FILE_FLAG_BACKUP_SEMANTICS); - let file = File::open_native(&path, &opts)?; + let file = File::open_native(path, &opts)?; file.readlink() } @@ -1506,7 +1506,7 @@ fn metadata(path: &WCStr, reparse: ReparsePoint) -> io::Result { // Attempt to open the file normally. // If that fails with `ERROR_SHARING_VIOLATION` then retry using `FindFirstFileExW`. // If the fallback fails for any reason we return the original error. - match File::open_native(&path, &opts) { + match File::open_native(path, &opts) { Ok(file) => file.file_attr(), Err(e) if [Some(c::ERROR_SHARING_VIOLATION as _), Some(c::ERROR_ACCESS_DENIED as _)] diff --git a/library/std/src/sys/process/unix/common.rs b/library/std/src/sys/process/unix/common.rs index 2e32770e90e77..a67c14b58faf1 100644 --- a/library/std/src/sys/process/unix/common.rs +++ b/library/std/src/sys/process/unix/common.rs @@ -218,7 +218,7 @@ impl Command { pub fn chroot(&mut self, dir: &Path) { self.chroot = Some(os2c(dir.as_os_str(), &mut self.saw_nul)); if self.cwd.is_none() { - self.cwd(&OsStr::new("/")); + self.cwd(OsStr::new("/")); } } pub fn setsid(&mut self, setsid: bool) { From ddd8fa08135bb6d006fcc7e3f2c5bd4be849c426 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Wed, 12 Aug 2026 14:16:16 +0000 Subject: [PATCH 05/49] clippy::op_ref --- library/core/src/bstr/traits.rs | 2 +- library/std/src/ffi/os_str.rs | 10 +++++----- library/std/src/sys/path/windows.rs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/core/src/bstr/traits.rs b/library/core/src/bstr/traits.rs index bcfffd52d7419..1d8d0e29e9a5a 100644 --- a/library/core/src/bstr/traits.rs +++ b/library/core/src/bstr/traits.rs @@ -25,7 +25,7 @@ impl PartialOrd for ByteStr { impl PartialEq for ByteStr { #[inline] fn eq(&self, other: &ByteStr) -> bool { - &self.0 == &other.0 + self.0 == other.0 } } diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 937bf0f119d3d..27039f0d3d2eb 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -719,7 +719,7 @@ impl fmt::Debug for OsString { impl PartialEq for OsString { #[inline] fn eq(&self, other: &OsString) -> bool { - &**self == &**other + **self == **other } } @@ -766,19 +766,19 @@ impl PartialOrd for OsString { } #[inline] fn lt(&self, other: &OsString) -> bool { - &**self < &**other + **self < **other } #[inline] fn le(&self, other: &OsString) -> bool { - &**self <= &**other + **self <= **other } #[inline] fn gt(&self, other: &OsString) -> bool { - &**self > &**other + **self > **other } #[inline] fn ge(&self, other: &OsString) -> bool { - &**self >= &**other + **self >= **other } } diff --git a/library/std/src/sys/path/windows.rs b/library/std/src/sys/path/windows.rs index 1c7bf50d1907f..2dbe33e2cf8b0 100644 --- a/library/std/src/sys/path/windows.rs +++ b/library/std/src/sys/path/windows.rs @@ -251,6 +251,6 @@ pub(crate) fn is_absolute_exact(path: &[u16]) -> bool { unsafe { new_path.set_len((result as usize) + 1); } - path == &new_path + path == new_path } } From fafcb2be486f2c24bbeb8417e5d32335df5d9a34 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 13 Aug 2026 01:51:53 +0000 Subject: [PATCH 06/49] clippy::borrow_deref_ref --- library/core/src/cell.rs | 2 +- library/core/src/fmt/mod.rs | 2 +- library/core/src/mem/maybe_uninit.rs | 2 +- library/core/src/pin.rs | 2 +- library/std/src/fs.rs | 4 ++-- library/std/src/io/stdio.rs | 4 ++-- library/std/src/os/unix/net/stream.rs | 4 ++-- library/std/src/process.rs | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 2dc2c5981cafd..e8cd3a500084a 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -704,7 +704,7 @@ impl AsRef<[Cell; N]> for Cell<[T; N]> { impl AsRef<[Cell]> for Cell<[T; N]> { #[inline] fn as_ref(&self) -> &[Cell] { - &*self.as_array_of_cells() + self.as_array_of_cells() } } diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 47886aa7165d9..6a4c58afc16f3 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -3189,7 +3189,7 @@ impl Debug for Ref<'_, T> { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for RefMut<'_, T> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { - Debug::fmt(&*(self.deref()), f) + Debug::fmt(self.deref(), f) } } diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 6275d7cd59a2c..94703940baa1f 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -1639,7 +1639,7 @@ impl AsRef<[MaybeUninit; N]> for MaybeUninit<[T; N]> { impl AsRef<[MaybeUninit]> for MaybeUninit<[T; N]> { #[inline] fn as_ref(&self) -> &[MaybeUninit] { - &*AsRef::<[MaybeUninit; N]>::as_ref(self) + AsRef::<[MaybeUninit; N]>::as_ref(self) } } diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs index 52a84082f3b92..58e63ff04af15 100644 --- a/library/core/src/pin.rs +++ b/library/core/src/pin.rs @@ -1540,7 +1540,7 @@ impl<'a, T: ?Sized> Pin<&'a T> { U: ?Sized, F: FnOnce(&T) -> &U, { - let pointer = &*self.pointer; + let pointer = self.pointer; let new_pointer = func(pointer); // SAFETY: the safety contract for `new_unchecked` must be diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 58874a27f8ae5..61e62e2064952 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1497,7 +1497,7 @@ impl Read for File { } #[inline] fn is_read_vectored(&self) -> bool { - (&&*self).is_read_vectored() + (&self).is_read_vectored() } fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { (&*self).read_to_end(buf) @@ -1516,7 +1516,7 @@ impl Write for File { } #[inline] fn is_write_vectored(&self) -> bool { - (&&*self).is_write_vectored() + (&self).is_write_vectored() } #[inline] fn flush(&mut self) -> io::Result<()> { diff --git a/library/std/src/io/stdio.rs b/library/std/src/io/stdio.rs index 957235f9f3fb0..b104ea69cd1fc 100644 --- a/library/std/src/io/stdio.rs +++ b/library/std/src/io/stdio.rs @@ -796,7 +796,7 @@ impl Write for Stdout { } #[inline] fn is_write_vectored(&self) -> bool { - io::Write::is_write_vectored(&&*self) + io::Write::is_write_vectored(&self) } fn flush(&mut self) -> io::Result<()> { (&*self).flush() @@ -1028,7 +1028,7 @@ impl Write for Stderr { } #[inline] fn is_write_vectored(&self) -> bool { - io::Write::is_write_vectored(&&*self) + io::Write::is_write_vectored(&self) } fn flush(&mut self) -> io::Result<()> { (&*self).flush() diff --git a/library/std/src/os/unix/net/stream.rs b/library/std/src/os/unix/net/stream.rs index 8567e2fbb783d..9a17f9e0b8b9b 100644 --- a/library/std/src/os/unix/net/stream.rs +++ b/library/std/src/os/unix/net/stream.rs @@ -642,7 +642,7 @@ impl io::Read for UnixStream { #[inline] fn is_read_vectored(&self) -> bool { - io::Read::is_read_vectored(&&*self) + io::Read::is_read_vectored(&self) } } @@ -678,7 +678,7 @@ impl io::Write for UnixStream { #[inline] fn is_write_vectored(&self) -> bool { - io::Write::is_write_vectored(&&*self) + io::Write::is_write_vectored(&self) } fn flush(&mut self) -> io::Result<()> { diff --git a/library/std/src/process.rs b/library/std/src/process.rs index a398363cf4bf9..59480aa79fe9e 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -333,7 +333,7 @@ impl Write for ChildStdin { } fn is_write_vectored(&self) -> bool { - io::Write::is_write_vectored(&&*self) + io::Write::is_write_vectored(&self) } #[inline] From d9d6acfad73e941bcf08fbbb278e3c77903f6c31 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 13 Aug 2026 02:01:47 +0000 Subject: [PATCH 07/49] clippy::explicit_auto_deref --- library/alloc/src/borrow.rs | 2 +- library/alloc/src/boxed.rs | 12 ++++++------ library/alloc/src/io/impls.rs | 4 ++-- library/alloc/src/rc.rs | 12 ++++++------ library/alloc/src/sync.rs | 14 +++++++------- library/alloc/src/vec/mod.rs | 2 +- library/core/src/clone.rs | 2 +- library/core/src/mem/drop_guard.rs | 4 ++-- library/core/src/str/pattern.rs | 2 +- library/std/src/os/unix/net/ancillary.rs | 8 ++++---- library/std/src/sync/lazy_lock.rs | 2 +- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/library/alloc/src/borrow.rs b/library/alloc/src/borrow.rs index d1c7cd47da0f0..b6a7a1eae2a70 100644 --- a/library/alloc/src/borrow.rs +++ b/library/alloc/src/borrow.rs @@ -188,7 +188,7 @@ impl<'a, B: ?Sized + ToOwned> Borrow for Cow<'a, B> // B::Owned: [const] Borrow, { fn borrow(&self) -> &B { - &**self + self } } diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index c25a06968e293..8c790d1105050 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -2293,14 +2293,14 @@ impl Deref for Box { type Target = T; fn deref(&self) -> &T { - &**self + self } } #[stable(feature = "rust1", since = "1.0.0")] impl DerefMut for Box { fn deref_mut(&mut self) -> &mut T { - &mut **self + self } } @@ -2396,28 +2396,28 @@ impl, U: ?Sized> DispatchFromDyn> for Box Borrow for Box { fn borrow(&self) -> &T { - &**self + self } } #[stable(feature = "box_borrow", since = "1.1.0")] impl BorrowMut for Box { fn borrow_mut(&mut self) -> &mut T { - &mut **self + self } } #[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] impl AsRef for Box { fn as_ref(&self) -> &T { - &**self + self } } #[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] impl AsMut for Box { fn as_mut(&mut self) -> &mut T { - &mut **self + self } } diff --git a/library/alloc/src/io/impls.rs b/library/alloc/src/io/impls.rs index dae6b3aa3371d..0296cada74171 100644 --- a/library/alloc/src/io/impls.rs +++ b/library/alloc/src/io/impls.rs @@ -327,7 +327,7 @@ impl Read for &[u8] { fn read_buf_exact(&mut self, mut cursor: BorrowedCursor<'_, u8>) -> io::Result<()> { if cursor.capacity() > self.len() { // Append everything we can to the cursor. - cursor.append(*self); + cursor.append(self); *self = &self[self.len()..]; return Err(io::Error::READ_EXACT_EOF); } @@ -349,7 +349,7 @@ impl Read for &[u8] { buf.try_extend_from_slice_of_bytes(*self)?; } _ => { - buf.extend_from_slice(*self); + buf.extend_from_slice(self); } } diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs index 38ba8d64f900e..73dabb3b02b60 100644 --- a/library/alloc/src/rc.rs +++ b/library/alloc/src/rc.rs @@ -3858,14 +3858,14 @@ impl<'a> RcInnerPtr for WeakInner<'a> { #[stable(feature = "rust1", since = "1.0.0")] impl borrow::Borrow for Rc { fn borrow(&self) -> &T { - &**self + self } } #[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] impl AsRef for Rc { fn as_ref(&self) -> &T { - &**self + self } } @@ -3990,28 +3990,28 @@ impl fmt::Pointer for UniqueRc { #[unstable(feature = "unique_rc_arc", issue = "112566")] impl borrow::Borrow for UniqueRc { fn borrow(&self) -> &T { - &**self + self } } #[unstable(feature = "unique_rc_arc", issue = "112566")] impl borrow::BorrowMut for UniqueRc { fn borrow_mut(&mut self) -> &mut T { - &mut **self + self } } #[unstable(feature = "unique_rc_arc", issue = "112566")] impl AsRef for UniqueRc { fn as_ref(&self) -> &T { - &**self + self } } #[unstable(feature = "unique_rc_arc", issue = "112566")] impl AsMut for UniqueRc { fn as_mut(&mut self) -> &mut T { - &mut **self + self } } diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 5e1344c0994cb..a3356b423288f 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -3836,7 +3836,7 @@ impl Default for Arc { #[inline] fn default() -> Self { let arc: Arc<[u8]> = Default::default(); - debug_assert!(core::str::from_utf8(&*arc).is_ok()); + debug_assert!(core::str::from_utf8(&arc).is_ok()); let (ptr, alloc) = Arc::into_inner_with_allocator(arc); unsafe { Arc::from_ptr_in(ptr.as_ptr() as *mut ArcInner, alloc) } } @@ -4246,14 +4246,14 @@ impl> ToArcSlice for I { #[stable(feature = "rust1", since = "1.0.0")] impl borrow::Borrow for Arc { fn borrow(&self) -> &T { - &**self + self } } #[stable(since = "1.5.0", feature = "smart_ptr_as_ref")] impl AsRef for Arc { fn as_ref(&self) -> &T { - &**self + self } } @@ -4463,28 +4463,28 @@ impl fmt::Pointer for UniqueArc { #[unstable(feature = "unique_rc_arc", issue = "112566")] impl borrow::Borrow for UniqueArc { fn borrow(&self) -> &T { - &**self + self } } #[unstable(feature = "unique_rc_arc", issue = "112566")] impl borrow::BorrowMut for UniqueArc { fn borrow_mut(&mut self) -> &mut T { - &mut **self + self } } #[unstable(feature = "unique_rc_arc", issue = "112566")] impl AsRef for UniqueArc { fn as_ref(&self) -> &T { - &**self + self } } #[unstable(feature = "unique_rc_arc", issue = "112566")] impl AsMut for UniqueArc { fn as_mut(&mut self) -> &mut T { - &mut **self + self } } diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index a619aa6e5427b..898ed0378bb80 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -3875,7 +3875,7 @@ impl Clone for Vec { /// capacity of the original. fn clone(&self) -> Self { let alloc = self.allocator().clone(); - <[T]>::to_vec_in(&**self, alloc) + <[T]>::to_vec_in(self, alloc) } /// Overwrites the contents of `self` with a clone of the contents of `source`. diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index 2996c753faea4..f124b8bceaded 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -781,7 +781,7 @@ mod impls { #[inline(always)] #[rustc_diagnostic_item = "noop_method_clone"] fn clone(&self) -> Self { - *self + self } } diff --git a/library/core/src/mem/drop_guard.rs b/library/core/src/mem/drop_guard.rs index 70658f0efb242..8e6655f785466 100644 --- a/library/core/src/mem/drop_guard.rs +++ b/library/core/src/mem/drop_guard.rs @@ -116,7 +116,7 @@ where type Target = T; fn deref(&self) -> &T { - &*self.inner + &self.inner } } @@ -127,7 +127,7 @@ where F: FnOnce(T), { fn deref_mut(&mut self) -> &mut T { - &mut *self.inner + &mut self.inner } } diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index 38006b638fdcd..e157ab588e701 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -1051,7 +1051,7 @@ impl<'b> Pattern for &'b str { #[inline] fn as_utf8_pattern(&self) -> Option> { - Some(Utf8Pattern::StringPattern(*self)) + Some(Utf8Pattern::StringPattern(self)) } } diff --git a/library/std/src/os/unix/net/ancillary.rs b/library/std/src/os/unix/net/ancillary.rs index 5d2cbd403ad20..bdf0384e34f80 100644 --- a/library/std/src/os/unix/net/ancillary.rs +++ b/library/std/src/os/unix/net/ancillary.rs @@ -506,12 +506,12 @@ impl<'a> AncillaryData<'a> { fn try_from_cmsghdr(cmsg: &'a libc::cmsghdr) -> Result { unsafe { let cmsg_len_zero = libc::CMSG_LEN(0) as usize; - let data_len = (*cmsg).cmsg_len as usize - cmsg_len_zero; + let data_len = cmsg.cmsg_len as usize - cmsg_len_zero; let data = libc::CMSG_DATA(cmsg).cast(); let data = from_raw_parts(data, data_len); - match (*cmsg).cmsg_level { - libc::SOL_SOCKET => match (*cmsg).cmsg_type { + match cmsg.cmsg_level { + libc::SOL_SOCKET => match cmsg.cmsg_type { libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)), #[cfg(any(target_os = "android", target_os = "linux", target_os = "cygwin"))] libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)), @@ -524,7 +524,7 @@ impl<'a> AncillaryData<'a> { } }, cmsg_level => { - Err(AncillaryError::Unknown { cmsg_level, cmsg_type: (*cmsg).cmsg_type }) + Err(AncillaryError::Unknown { cmsg_level, cmsg_type: cmsg.cmsg_type }) } } } diff --git a/library/std/src/sync/lazy_lock.rs b/library/std/src/sync/lazy_lock.rs index 9bb25287275b2..f150d42a3137c 100644 --- a/library/std/src/sync/lazy_lock.rs +++ b/library/std/src/sync/lazy_lock.rs @@ -258,7 +258,7 @@ impl T> LazyLock { // * the closure was not called, but a previous call initialized `value`. // * the closure was not called because the Once is poisoned, which we handled above. // So `value` has definitely been initialized and will not be modified again. - unsafe { &*(*this.data.get()).value } + unsafe { &(*this.data.get()).value } } } From 5653e8f78d16dfe364de15d217d535c90bb3c4f5 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 13 Aug 2026 02:22:22 +0000 Subject: [PATCH 08/49] Library: enforce clippy deref lints in CI --- src/bootstrap/src/core/build_steps/clippy.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index 6f6c76d23a454..95a850e3984f2 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -588,6 +588,10 @@ impl CommandLineStep for CI { "clippy::ptr_offset_with_cast".into(), "clippy::let_and_return".into(), "clippy::needless_return".into(), + "clippy::needless_borrow".into(), + "clippy::op_ref".into(), + "clippy::borrow_deref_ref".into(), + "clippy::explicit_auto_deref".into(), ], forbid: vec![], }; From 7f74e595a84d917c0b8bcbf8e6ed64fac4c3ef4d Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 13 Aug 2026 03:22:53 +0000 Subject: [PATCH 09/49] Ignore clippy lint in backtrace submodule --- library/std/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 22ac7443f464b..d3bbb7c2353cd 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -740,7 +740,7 @@ mod panicking; #[path = "../../backtrace/src/lib.rs"] #[allow(dead_code, unused_attributes, implicit_provenance_casts, unsafe_op_in_unsafe_fn)] -#[allow(clippy::len_zero)] // FIXME +#[allow(clippy::len_zero, clippy::needless_borrow)] // FIXME mod backtrace_rs; #[stable(feature = "cfg_select", since = "1.95.0")] From b20f425c4a08666c7d5b21548093a786f23d4e13 Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Sun, 17 May 2026 17:53:39 +0000 Subject: [PATCH 10/49] port stdarch-gen checks into bootstrap --- src/bootstrap/src/core/build_steps/test.rs | 93 ++++++++++++++++++++++ src/bootstrap/src/core/builder/mod.rs | 1 + 2 files changed, 94 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index dca3220acda55..011a566329a3d 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1200,6 +1200,99 @@ impl CommandLineStep for IntrinsicTest { } } +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct StdarchGenCheck { + host: TargetSelection, +} + +impl Step for StdarchGenCheck { + type Output = (); + const IS_HOST: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.alias("stdarch-gen-check") + .path("library/stdarch/crates/stdarch-gen-arm") + .path("library/stdarch/crates/stdarch-gen-loongarch") + .path("library/stdarch/crates/stdarch-gen-hexagon") + .path("library/stdarch/crates/stdarch-gen-hexagon-scalar") + } + + fn is_default_step(_builder: &Builder<'_>) -> bool { + true + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(StdarchGenCheck { host: run.target }); + } + + fn run(self, builder: &Builder<'_>) { + let stdarch_root = builder.src.join("library/stdarch"); + let bless = builder.config.cmd.bless(); + + // The generators shell out to rustfmt to format their output so we need + // it discoverable on PATH. Bootstrap downloads one and exposes it here. + let rustfmt_path = builder.config.initial_rustfmt.clone().unwrap_or_else(|| { + eprintln!( + "stdarch-gen-check: a rustfmt binary is required but none was found.\n\ + Set `rustfmt = true` in `bootstrap.toml` so bootstrap downloads one." + ); + crate::exit!(1); + }); + + let mut path_dirs: Vec = Vec::new(); + if let Some(cargo_dir) = builder.initial_cargo.parent() { + path_dirs.push(cargo_dir.to_path_buf()); + } + if let Some(rustfmt_dir) = rustfmt_path.parent() { + path_dirs.push(rustfmt_dir.to_path_buf()); + } + let old_path = env::var_os("PATH").unwrap_or_default(); + let new_path = env::join_paths(path_dirs.into_iter().chain(env::split_paths(&old_path))) + .expect("could not build PATH for stdarch-gen-check"); + + // Mirrors `library/stdarch/.github/workflows/main.yml` (check-stdarch-gen job). + let invocations: &[(&str, &str, Option<&str>)] = &[ + ("--bin", "stdarch-gen-arm", Some("crates/stdarch-gen-arm/spec")), + ("--bin", "stdarch-gen-loongarch", Some("crates/stdarch-gen-loongarch/lsx.spec")), + ("--bin", "stdarch-gen-loongarch", Some("crates/stdarch-gen-loongarch/lasx.spec")), + ("-p", "stdarch-gen-hexagon", None), + ("-p", "stdarch-gen-hexagon-scalar", None), + ]; + + for (selector, pkg, spec) in invocations { + let mut cmd = command(&builder.initial_cargo); + cmd.current_dir(&stdarch_root); + cmd.arg("run").arg(selector).arg(pkg).arg("--release"); + if let Some(spec) = spec { + cmd.arg("--").arg(spec); + } + // RUSTC_BOOTSTRAP=1 allow nightly features when building tools against stage0. + cmd.env("RUSTC_BOOTSTRAP", "1"); + cmd.env("PATH", &new_path); + cmd.run(builder); + } + + let mut git = command("git"); + git.current_dir(&stdarch_root); + git.arg("diff").arg("--exit-code").arg("--").arg("crates/core_arch"); + let clean = git.allow_failure().run(builder); + + if !clean { + if bless { + builder.info( + "stdarch-gen-check: generated files updated. Review the diff and commit.", + ); + } else { + eprintln!( + "stdarch-gen-check: generated files are out of date.\n\ + Run `./x test stdarch-gen-check --bless` to update them, then commit." + ); + crate::exit!(1); + } + } + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Clippy { compilers: RustcPrivateCompilers, diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 8d0461f0787ed..2fe850ed23a26 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -949,6 +949,7 @@ impl<'a> Builder<'a> { test::Clippy, test::CompiletestTest, test::StdarchVerify, + test::StdarchGenCheck, test::CrateRunMakeSupport, test::CrateBuildHelper, test::RustdocJSStd, From 34cf67c882d3b8e1486eaeffe0bea9ea2eccb7a8 Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Mon, 18 May 2026 04:27:14 +0000 Subject: [PATCH 11/49] use helpers::git --- src/bootstrap/src/core/build_steps/test.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 011a566329a3d..0dc1b3ba6cb86 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1272,8 +1272,7 @@ impl Step for StdarchGenCheck { cmd.run(builder); } - let mut git = command("git"); - git.current_dir(&stdarch_root); + let mut git = helpers::git(Some(&stdarch_root)); git.arg("diff").arg("--exit-code").arg("--").arg("crates/core_arch"); let clean = git.allow_failure().run(builder); From 55e715d36537fc8149322bc2d1d498b10d7b2021 Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Mon, 18 May 2026 07:17:07 +0000 Subject: [PATCH 12/49] fix: set CARGO_TARGET_DIR for read-only CI --- src/bootstrap/src/core/build_steps/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 0dc1b3ba6cb86..b4d6e01c8cf75 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1269,6 +1269,7 @@ impl Step for StdarchGenCheck { // RUSTC_BOOTSTRAP=1 allow nightly features when building tools against stage0. cmd.env("RUSTC_BOOTSTRAP", "1"); cmd.env("PATH", &new_path); + cmd.env("CARGO_TARGET_DIR", builder.out.join("stdarch-gen-check")); cmd.run(builder); } From 22e2b157fac56d0fb806113332342c395c7d4daa Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Tue, 26 May 2026 13:17:40 +0000 Subject: [PATCH 13/49] fix: redirect generator output to a writable dir --- src/bootstrap/src/core/build_steps/test.rs | 94 +++++++++++++++++----- 1 file changed, 76 insertions(+), 18 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index b4d6e01c8cf75..e92a1cf25bb62 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1250,38 +1250,71 @@ impl Step for StdarchGenCheck { let new_path = env::join_paths(path_dirs.into_iter().chain(env::split_paths(&old_path))) .expect("could not build PATH for stdarch-gen-check"); - // Mirrors `library/stdarch/.github/workflows/main.yml` (check-stdarch-gen job). - let invocations: &[(&str, &str, Option<&str>)] = &[ - ("--bin", "stdarch-gen-arm", Some("crates/stdarch-gen-arm/spec")), - ("--bin", "stdarch-gen-loongarch", Some("crates/stdarch-gen-loongarch/lsx.spec")), - ("--bin", "stdarch-gen-loongarch", Some("crates/stdarch-gen-loongarch/lasx.spec")), - ("-p", "stdarch-gen-hexagon", None), - ("-p", "stdarch-gen-hexagon-scalar", None), - ]; - - for (selector, pkg, spec) in invocations { + let work_dir = builder.out.join("stdarch-gen-check"); + let cargo_target_dir = work_dir.join("target"); + + // Writable copy of `crates/core_arch` that the generators write into. + let src_core_arch = stdarch_root.join("crates/core_arch"); + let out_core_arch = work_dir.join("core_arch"); + if out_core_arch.exists() { + t!(fs::remove_dir_all(&out_core_arch)); + } + cp_writable_r(&src_core_arch, &out_core_arch); + let out_core_arch_src = out_core_arch.join("src"); + + // Mirrors the check-stdarch-gen CI job with its output redirected + // into `out_core_arch` args follow `--` and `out_dir` when set becomes OUT_DIR. + let run_gen = |selector: &str, pkg: &str, args: &[&OsStr], out_dir: Option<&Path>| { let mut cmd = command(&builder.initial_cargo); cmd.current_dir(&stdarch_root); - cmd.arg("run").arg(selector).arg(pkg).arg("--release"); - if let Some(spec) = spec { - cmd.arg("--").arg(spec); - } + cmd.arg("run").arg(selector).arg(pkg).arg("--release").arg("--").args(args); // RUSTC_BOOTSTRAP=1 allow nightly features when building tools against stage0. cmd.env("RUSTC_BOOTSTRAP", "1"); cmd.env("PATH", &new_path); - cmd.env("CARGO_TARGET_DIR", builder.out.join("stdarch-gen-check")); + cmd.env("CARGO_TARGET_DIR", &cargo_target_dir); + if let Some(out_dir) = out_dir { + cmd.env("OUT_DIR", out_dir); + } cmd.run(builder); - } + }; + + let hexagon_out = out_core_arch_src.join("hexagon"); + run_gen( + "--bin", + "stdarch-gen-arm", + &[OsStr::new("crates/stdarch-gen-arm/spec"), out_core_arch_src.as_os_str()], + None, + ); + run_gen( + "--bin", + "stdarch-gen-loongarch", + &[OsStr::new("crates/stdarch-gen-loongarch/lsx.spec")], + Some(&out_core_arch), + ); + run_gen( + "--bin", + "stdarch-gen-loongarch", + &[OsStr::new("crates/stdarch-gen-loongarch/lasx.spec")], + Some(&out_core_arch), + ); + run_gen("-p", "stdarch-gen-hexagon", &[hexagon_out.as_os_str()], None); + run_gen("-p", "stdarch-gen-hexagon-scalar", &[hexagon_out.as_os_str()], None); let mut git = helpers::git(Some(&stdarch_root)); - git.arg("diff").arg("--exit-code").arg("--").arg("crates/core_arch"); + git.arg("diff") + .arg("--no-index") + .arg("--exit-code") + .arg(&src_core_arch) + .arg(&out_core_arch); let clean = git.allow_failure().run(builder); if !clean { if bless { builder.info( - "stdarch-gen-check: generated files updated. Review the diff and commit.", + "stdarch-gen-check: updating generated files in the source tree. \ + Review the diff and commit.", ); + cp_writable_r(&out_core_arch, &src_core_arch); } else { eprintln!( "stdarch-gen-check: generated files are out of date.\n\ @@ -1293,6 +1326,31 @@ impl Step for StdarchGenCheck { } } +/// Recursively copy src to dst clearing the read-only bit so the destination can be +/// regenerated even when src lives on a read-only filesystem. +fn cp_writable_r(src: &Path, dst: &Path) { + let metadata = t!(fs::symlink_metadata(src)); + if metadata.file_type().is_symlink() { + return; + } + if metadata.is_dir() { + t!(fs::create_dir_all(dst)); + for entry in t!(fs::read_dir(src)) { + let entry = t!(entry); + cp_writable_r(&entry.path(), &dst.join(entry.file_name())); + } + } else { + if let Some(parent) = dst.parent() { + t!(fs::create_dir_all(parent)); + } + t!(fs::copy(src, dst)); + let mut perms = t!(fs::metadata(dst)).permissions(); + #[allow(clippy::permissions_set_readonly_false)] + perms.set_readonly(false); + t!(fs::set_permissions(dst, perms)); + } +} + #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Clippy { compilers: RustcPrivateCompilers, From 7bbe5d690f54caebdbaf4345e5fc8dfa35489c42 Mon Sep 17 00:00:00 2001 From: zakrad <49591476+zakrad@users.noreply.github.com> Date: Thu, 13 Aug 2026 02:12:01 +0330 Subject: [PATCH 14/49] Add regression test for static lifetime of borrowed array of Drop type in const --- ...omotion-drop-type-static-lifetime-86672.rs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/ui/consts/promotion-drop-type-static-lifetime-86672.rs diff --git a/tests/ui/consts/promotion-drop-type-static-lifetime-86672.rs b/tests/ui/consts/promotion-drop-type-static-lifetime-86672.rs new file mode 100644 index 0000000000000..5fc8d06708451 --- /dev/null +++ b/tests/ui/consts/promotion-drop-type-static-lifetime-86672.rs @@ -0,0 +1,23 @@ +// Regression test for . +// Borrowing an array of a Drop type in a const used to fail with E0493 and E0716 +// unless the borrow went through another const. +//@ check-pass + +#![allow(dead_code)] + +pub struct Foo<'a, B: ?Sized>(&'a B); + +struct Bar; +impl Drop for Bar { + fn drop(&mut self) {} +} + +// These always worked. +const BAR0: Bar = Bar; +const BAR1: &'static [Bar] = &[Bar]; +const BAR2: Foo<'static, [Bar]> = Foo(BAR1); +// These used to fail. +const BAR3: Foo<'static, [Bar]> = Foo(&[Bar]); +const BAR4: Foo<'static, [Bar]> = Foo(&[Bar] as &'static [Bar]); + +fn main() {} From 748a319ee14347ddb87aa7be35a51c3fcc3bbb0a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 13 Aug 2026 15:05:15 +0200 Subject: [PATCH 15/49] Add extra checks to ensure GCC and binutils have needed support for the `retain` attribute --- src/ci/docker/scripts/build-gcc.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index bef169fafe38c..41bc3495e0b2e 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -11,6 +11,15 @@ hide_output ./configure hide_output make hide_output make install +if echo '.section .test,"awR",@progbits' | as - -o /dev/null 2>/dev/null; then + echo "binutils assembler supports SHF_GNU_RETAIN" +else + echo "binutils assembler DOES NOT support SHF_GNU_RETAIN" + exit 1 +fi + +cd .. + # Note: in the future when bumping to version 10.1.0, also take care of the sed block below. # This version is specified in the Dockerfile GCC=$GCC_VERSION @@ -54,6 +63,12 @@ hide_output ../gcc-$GCC/configure \ hide_output make -j$(nproc) hide_output make install ln -s gcc /rustroot/bin/cc +if echo 'int x __attribute__((used, retain));' | gcc -S -x c -o - - | grep -i '"a.*R"'; then + echo "retain attribute is supported" +else + echo "retain attribute is not supported" + exit 1 +fi cd .. rm -rf gcc-build From 487e0e0b00837f573c076cd238db9fa819b5309d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 13 Aug 2026 17:47:16 +0200 Subject: [PATCH 16/49] Display generated asm in case it failed --- src/ci/docker/scripts/build-gcc.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 41bc3495e0b2e..6ac0514b6569f 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -67,6 +67,8 @@ if echo 'int x __attribute__((used, retain));' | gcc -S -x c -o - - | grep -i '" echo "retain attribute is supported" else echo "retain attribute is not supported" + # We display the generated asm just in case... + echo 'int x __attribute__((used, retain));' | gcc -S -x c -o - - exit 1 fi From 59674c128a04a62f92aaccf983854bb74abb68ed Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Thu, 13 Aug 2026 19:30:15 +0000 Subject: [PATCH 17/49] check stdarch-gen output via stdarch-gen-common --- src/bootstrap/src/core/build_steps/test.rs | 116 +++--------------- .../builder/cli_paths/snapshots/x_test.snap | 6 + .../cli_paths/snapshots/x_test_library.snap | 5 + ...st_library_core_and_alloc_and_stdarch.snap | 5 + .../snapshots/x_test_skip_coverage.snap | 6 + .../snapshots/x_test_skip_coverage_map.snap | 6 + .../snapshots/x_test_skip_coverage_run.snap | 6 + .../snapshots/x_test_skip_tests.snap | 6 + .../snapshots/x_test_skip_tests_coverage.snap | 6 + .../snapshots/x_test_skip_tests_etc.snap | 3 + 10 files changed, 68 insertions(+), 97 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e92a1cf25bb62..2cb78978b9f20 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1205,7 +1205,7 @@ pub struct StdarchGenCheck { host: TargetSelection, } -impl Step for StdarchGenCheck { +impl CommandLineStep for StdarchGenCheck { type Output = (); const IS_HOST: bool = true; @@ -1214,7 +1214,6 @@ impl Step for StdarchGenCheck { .path("library/stdarch/crates/stdarch-gen-arm") .path("library/stdarch/crates/stdarch-gen-loongarch") .path("library/stdarch/crates/stdarch-gen-hexagon") - .path("library/stdarch/crates/stdarch-gen-hexagon-scalar") } fn is_default_step(_builder: &Builder<'_>) -> bool { @@ -1227,17 +1226,17 @@ impl Step for StdarchGenCheck { fn run(self, builder: &Builder<'_>) { let stdarch_root = builder.src.join("library/stdarch"); - let bless = builder.config.cmd.bless(); - // The generators shell out to rustfmt to format their output so we need - // it discoverable on PATH. Bootstrap downloads one and exposes it here. - let rustfmt_path = builder.config.initial_rustfmt.clone().unwrap_or_else(|| { + // `--bless` regenerates and writes back into the tree otherwise just check. + let mode = if builder.config.cmd.bless() { "bless" } else { "check" }; + + // Generators shell out to `rustfmt`skip if bootstrap has none for this channel. + let Some(rustfmt_path) = builder.ensure(InternalRustfmt) else { eprintln!( - "stdarch-gen-check: a rustfmt binary is required but none was found.\n\ - Set `rustfmt = true` in `bootstrap.toml` so bootstrap downloads one." + "WARNING: stdarch-gen-check skipped because rustfmt is required but not available on this channel" ); - crate::exit!(1); - }); + return; + }; let mut path_dirs: Vec = Vec::new(); if let Some(cargo_dir) = builder.initial_cargo.parent() { @@ -1250,21 +1249,12 @@ impl Step for StdarchGenCheck { let new_path = env::join_paths(path_dirs.into_iter().chain(env::split_paths(&old_path))) .expect("could not build PATH for stdarch-gen-check"); - let work_dir = builder.out.join("stdarch-gen-check"); - let cargo_target_dir = work_dir.join("target"); + // Keep cargo's build artifacts out of the (possibly read-only) source tree. + let cargo_target_dir = builder.out.join("stdarch-gen-check").join("target"); - // Writable copy of `crates/core_arch` that the generators write into. - let src_core_arch = stdarch_root.join("crates/core_arch"); - let out_core_arch = work_dir.join("core_arch"); - if out_core_arch.exists() { - t!(fs::remove_dir_all(&out_core_arch)); - } - cp_writable_r(&src_core_arch, &out_core_arch); - let out_core_arch_src = out_core_arch.join("src"); - - // Mirrors the check-stdarch-gen CI job with its output redirected - // into `out_core_arch` args follow `--` and `out_dir` when set becomes OUT_DIR. - let run_gen = |selector: &str, pkg: &str, args: &[&OsStr], out_dir: Option<&Path>| { + // `stdarch-gen-common` runs each generator into a temp dir and diffs/blesses + // against the committed files itself, driven by STDARCH_GEN_MODE. + let run_gen = |selector: &str, pkg: &str, args: &[&OsStr]| { let mut cmd = command(&builder.initial_cargo); cmd.current_dir(&stdarch_root); cmd.arg("run").arg(selector).arg(pkg).arg("--release").arg("--").args(args); @@ -1272,82 +1262,14 @@ impl Step for StdarchGenCheck { cmd.env("RUSTC_BOOTSTRAP", "1"); cmd.env("PATH", &new_path); cmd.env("CARGO_TARGET_DIR", &cargo_target_dir); - if let Some(out_dir) = out_dir { - cmd.env("OUT_DIR", out_dir); - } + cmd.env("STDARCH_GEN_MODE", mode); cmd.run(builder); }; - let hexagon_out = out_core_arch_src.join("hexagon"); - run_gen( - "--bin", - "stdarch-gen-arm", - &[OsStr::new("crates/stdarch-gen-arm/spec"), out_core_arch_src.as_os_str()], - None, - ); - run_gen( - "--bin", - "stdarch-gen-loongarch", - &[OsStr::new("crates/stdarch-gen-loongarch/lsx.spec")], - Some(&out_core_arch), - ); - run_gen( - "--bin", - "stdarch-gen-loongarch", - &[OsStr::new("crates/stdarch-gen-loongarch/lasx.spec")], - Some(&out_core_arch), - ); - run_gen("-p", "stdarch-gen-hexagon", &[hexagon_out.as_os_str()], None); - run_gen("-p", "stdarch-gen-hexagon-scalar", &[hexagon_out.as_os_str()], None); - - let mut git = helpers::git(Some(&stdarch_root)); - git.arg("diff") - .arg("--no-index") - .arg("--exit-code") - .arg(&src_core_arch) - .arg(&out_core_arch); - let clean = git.allow_failure().run(builder); - - if !clean { - if bless { - builder.info( - "stdarch-gen-check: updating generated files in the source tree. \ - Review the diff and commit.", - ); - cp_writable_r(&out_core_arch, &src_core_arch); - } else { - eprintln!( - "stdarch-gen-check: generated files are out of date.\n\ - Run `./x test stdarch-gen-check --bless` to update them, then commit." - ); - crate::exit!(1); - } - } - } -} - -/// Recursively copy src to dst clearing the read-only bit so the destination can be -/// regenerated even when src lives on a read-only filesystem. -fn cp_writable_r(src: &Path, dst: &Path) { - let metadata = t!(fs::symlink_metadata(src)); - if metadata.file_type().is_symlink() { - return; - } - if metadata.is_dir() { - t!(fs::create_dir_all(dst)); - for entry in t!(fs::read_dir(src)) { - let entry = t!(entry); - cp_writable_r(&entry.path(), &dst.join(entry.file_name())); - } - } else { - if let Some(parent) = dst.parent() { - t!(fs::create_dir_all(parent)); - } - t!(fs::copy(src, dst)); - let mut perms = t!(fs::metadata(dst)).permissions(); - #[allow(clippy::permissions_set_readonly_false)] - perms.set_readonly(false); - t!(fs::set_permissions(dst, perms)); + run_gen("--bin", "stdarch-gen-arm", &[OsStr::new("crates/stdarch-gen-arm/spec")]); + run_gen("-p", "stdarch-gen-loongarch", &[OsStr::new("lsx")]); + run_gen("-p", "stdarch-gen-loongarch", &[OsStr::new("lasx")]); + run_gen("-p", "stdarch-gen-hexagon", &[]); } } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 7807566751a2f..0b5fa1747c1ca 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -185,6 +185,12 @@ expression: test [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) + - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap index 0d6c34daacf0a..9b6016449c97b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap @@ -21,3 +21,8 @@ expression: test library [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap index 2664ab7a404cc..00e616c820984 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap @@ -9,3 +9,8 @@ expression: test library/core library/alloc library/stdarch [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index 7bac4c859c450..b3f0ef29c091e 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -182,6 +182,12 @@ expression: test --skip=coverage [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) + - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 732b84e90a880..9f6bc865ed959 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -185,6 +185,12 @@ expression: test --skip=coverage-map [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) + - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index c36a9fd752aed..3d45cab6f6c9e 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -185,6 +185,12 @@ expression: test --skip=coverage-run [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) + - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index bf5de019af6f4..392980c75d57c 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -146,6 +146,12 @@ expression: test --skip=tests [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) + - Set({stdarch-gen-check}) [Test] test::RustdocTheme targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rustdoc-themes}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 3236872a46469..4006ef2b8c57b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -182,6 +182,12 @@ expression: test --skip=tests/coverage [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({library/stdarch/crates/stdarch-gen-arm}) + - Set({library/stdarch/crates/stdarch-gen-hexagon}) + - Set({library/stdarch/crates/stdarch-gen-loongarch}) + - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] - Suite(tests/rustdoc-js-std) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap index 93d3ee139e3fb..326b3557bd69b 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_etc.snap @@ -126,6 +126,9 @@ expression: test --skip=tests --skip=library --skip=tidyselftest [Test] test::RustcBook targets: [x86_64-unknown-linux-gnu] - Set({src/doc/rustc}) +[Test] test::StdarchGenCheck + targets: [x86_64-unknown-linux-gnu] + - Set({stdarch-gen-check}) [Test] test::RustdocTheme targets: [x86_64-unknown-linux-gnu] - Set({src/tools/rustdoc-themes}) From 4c097cfeda80dd0fc8307f804f946106330cb18a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 13 Aug 2026 21:56:22 +0200 Subject: [PATCH 18/49] Use `--prefix` to generate binaries in the right location --- src/ci/docker/scripts/build-gcc.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 6ac0514b6569f..bb2c97b475ece 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -7,8 +7,8 @@ source shared.sh BINUTILS="2.47" curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - cd binutils-$BINUTILS -hide_output ./configure -hide_output make +hide_output ./configure --prefix=/rustroot +hide_output make -j$(nproc) hide_output make install if echo '.section .test,"awR",@progbits' | as - -o /dev/null 2>/dev/null; then From 3c395a999b49ca4e1c2d54524951bacacc4997c4 Mon Sep 17 00:00:00 2001 From: zakrad <49591476+zakrad@users.noreply.github.com> Date: Fri, 14 Aug 2026 01:04:04 +0330 Subject: [PATCH 19/49] Add regression test for path printing with infinitely many visible names --- tests/ui/imports/auxiliary/pathloop.rs | 6 ++++++ .../path-with-infinite-visible-names-57500.rs | 12 ++++++++++++ .../path-with-infinite-visible-names-57500.stderr | 11 +++++++++++ 3 files changed, 29 insertions(+) create mode 100644 tests/ui/imports/auxiliary/pathloop.rs create mode 100644 tests/ui/imports/path-with-infinite-visible-names-57500.rs create mode 100644 tests/ui/imports/path-with-infinite-visible-names-57500.stderr diff --git a/tests/ui/imports/auxiliary/pathloop.rs b/tests/ui/imports/auxiliary/pathloop.rs new file mode 100644 index 0000000000000..f69f0e0c8c056 --- /dev/null +++ b/tests/ui/imports/auxiliary/pathloop.rs @@ -0,0 +1,6 @@ +pub struct AStruct; + +pub mod prelude { + pub use crate as pathloop; + pub use crate::AStruct; +} diff --git a/tests/ui/imports/path-with-infinite-visible-names-57500.rs b/tests/ui/imports/path-with-infinite-visible-names-57500.rs new file mode 100644 index 0000000000000..74a3bb1969b19 --- /dev/null +++ b/tests/ui/imports/path-with-infinite-visible-names-57500.rs @@ -0,0 +1,12 @@ +// Regression test for . +// An item reachable under infinitely many paths used to hang path printing +// while rendering this error. +//@ aux-build: pathloop.rs + +extern crate pathloop; + +use pathloop::prelude::*; + +fn main() { + let _x: AStruct = 42; //~ ERROR mismatched types +} diff --git a/tests/ui/imports/path-with-infinite-visible-names-57500.stderr b/tests/ui/imports/path-with-infinite-visible-names-57500.stderr new file mode 100644 index 0000000000000..2f7b1e6ad106c --- /dev/null +++ b/tests/ui/imports/path-with-infinite-visible-names-57500.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/path-with-infinite-visible-names-57500.rs:11:23 + | +LL | let _x: AStruct = 42; + | ------- ^^ expected `AStruct`, found integer + | | + | expected due to this + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. From 88cfd2278aac08e6f0a6098d3c3a0acd5ef4be08 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 14 Aug 2026 01:58:50 +0200 Subject: [PATCH 20/49] Use `--with-as` and `--with-ld` options for `gcc` configure --- src/ci/docker/scripts/build-gcc.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index bb2c97b475ece..24598f62e05e2 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -11,13 +11,16 @@ hide_output ./configure --prefix=/rustroot hide_output make -j$(nproc) hide_output make install -if echo '.section .test,"awR",@progbits' | as - -o /dev/null 2>/dev/null; then +if echo '.section .test,"awR",@progbits' | /rustroot/bin/as - -o /dev/null 2>/dev/null; then echo "binutils assembler supports SHF_GNU_RETAIN" else echo "binutils assembler DOES NOT support SHF_GNU_RETAIN" exit 1 fi +AS_PATH="/rustroot/bin/as" +LD_PATH="/rustroot/bin/ld" + cd .. # Note: in the future when bumping to version 10.1.0, also take care of the sed block below. @@ -57,6 +60,8 @@ cd ../gcc-build # which is included in librustc_driver.so hide_output ../gcc-$GCC/configure \ --prefix=/rustroot \ + --with-as=$AS_PATH \ + --with-ld=$LD_PATH \ --enable-languages=c,c++ \ --disable-gnu-unique-object \ --enable-cxx-flags='-fno-reorder-blocks-and-partition' From bcc35a8e30a0061d07df3973fffbd7d8ffa85d2f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 14 Aug 2026 14:22:38 +0200 Subject: [PATCH 21/49] More settings targetting binutils --- src/ci/docker/scripts/build-gcc.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 24598f62e05e2..9a70071242d83 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -55,11 +55,13 @@ sed -i'' 's|ftp://gcc\.gnu\.org/pub/gcc/infrastructure|https://ci-mirrors.rust-l mkdir ../gcc-build cd ../gcc-build +export PATH=/rustroot/bin:$PATH # '-fno-reorder-blocks-and-partition' is required to # enable BOLT optimization of the C++ standard library, # which is included in librustc_driver.so hide_output ../gcc-$GCC/configure \ --prefix=/rustroot \ + --with-bintuils=/rustroot/bin \ --with-as=$AS_PATH \ --with-ld=$LD_PATH \ --enable-languages=c,c++ \ @@ -68,12 +70,13 @@ hide_output ../gcc-$GCC/configure \ hide_output make -j$(nproc) hide_output make install ln -s gcc /rustroot/bin/cc -if echo 'int x __attribute__((used, retain));' | gcc -S -x c -o - - | grep -i '"a.*R"'; then + +if echo 'int x __attribute__((used, retain));' | /rustroot/bin/gcc -S -x c -o - - | grep -i '"a.*R"'; then echo "retain attribute is supported" else echo "retain attribute is not supported" # We display the generated asm just in case... - echo 'int x __attribute__((used, retain));' | gcc -S -x c -o - - + echo 'int x __attribute__((used, retain));' | /rustroot/bin/gcc -S -x c -o - - exit 1 fi From 5b93f5472432b546a9a7e71e68a432e2229f9325 Mon Sep 17 00:00:00 2001 From: zakrad <49591476+zakrad@users.noreply.github.com> Date: Fri, 14 Aug 2026 11:53:11 +0330 Subject: [PATCH 22/49] Add regression test for unstable def_ident_span fingerprint with incremental recompilation --- .../macros/lib.rs | 73 +++++++++++++++++++ .../rmake.rs | 71 ++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 tests/run-make/incr-unstable-fingerprint-def-ident-span/macros/lib.rs create mode 100644 tests/run-make/incr-unstable-fingerprint-def-ident-span/rmake.rs diff --git a/tests/run-make/incr-unstable-fingerprint-def-ident-span/macros/lib.rs b/tests/run-make/incr-unstable-fingerprint-def-ident-span/macros/lib.rs new file mode 100644 index 0000000000000..5eee82170edb1 --- /dev/null +++ b/tests/run-make/incr-unstable-fingerprint-def-ident-span/macros/lib.rs @@ -0,0 +1,73 @@ +extern crate proc_macro; + +use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree}; + +// Re-emits each enum variant's identifier as an associated constant, reusing the +// original `Ident` tokens so the generated items keep the variants' spans. +#[proc_macro_derive(Bar)] +pub fn derive_bar(input: TokenStream) -> TokenStream { + let mut it = input.into_iter(); + let mut name: Option = None; + let mut body: Option = None; + + while let Some(tt) = it.next() { + match tt { + TokenTree::Ident(id) => { + if id.to_string() == "enum" { + if let Some(TokenTree::Ident(n)) = it.next() { + name = Some(n); + } + } + } + TokenTree::Group(g) => { + if g.delimiter() == Delimiter::Brace { + body = Some(g); + break; + } + } + _ => {} + } + } + + let name = name.expect("enum name"); + let body = body.expect("enum body"); + + // Collect variant idents (skip commas / discriminants). + let mut variants: Vec = Vec::new(); + let mut expect_ident = true; + for tt in body.stream() { + match tt { + TokenTree::Ident(id) => { + if expect_ident { + variants.push(id); + expect_ident = false; + } + } + TokenTree::Punct(p) => { + if p.as_char() == ',' { + expect_ident = true; + } + } + _ => {} + } + } + + // Build: impl Name { const V: () = (); ... } + let mut inner: Vec = Vec::new(); + for v in variants { + inner.push(TokenTree::Ident(Ident::new("const", Span::call_site()))); + inner.push(TokenTree::Ident(v)); // original ident + span + inner.push(TokenTree::Punct(Punct::new(':', Spacing::Alone))); + inner.push(TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new()))); + inner.push(TokenTree::Punct(Punct::new('=', Spacing::Alone))); + inner.push(TokenTree::Group(Group::new(Delimiter::Parenthesis, TokenStream::new()))); + inner.push(TokenTree::Punct(Punct::new(';', Spacing::Alone))); + } + + let mut out: Vec = Vec::new(); + out.push(TokenTree::Ident(Ident::new("impl", Span::call_site()))); + out.push(TokenTree::Ident(name)); + out.push(TokenTree::Group(Group::new(Delimiter::Brace, inner.into_iter().collect()))); + + out.into_iter().collect() +} diff --git a/tests/run-make/incr-unstable-fingerprint-def-ident-span/rmake.rs b/tests/run-make/incr-unstable-fingerprint-def-ident-span/rmake.rs new file mode 100644 index 0000000000000..8be1525ad2991 --- /dev/null +++ b/tests/run-make/incr-unstable-fingerprint-def-ident-span/rmake.rs @@ -0,0 +1,71 @@ +//@ ignore-cross-compile +//@ needs-crate-type: proc-macro + +// Regression test for . +// Recompiling incrementally after inserting an enum variant before an existing one used +// to ICE with "Found unstable fingerprints for def_ident_span". The derive re-emits the +// variant identifiers as associated constants, so their spans move while the surrounding +// generated tokens keep call-site hygiene. +// +// This cannot use the `revisions` system: the `#[cfg]`-based revisions keep both versions +// of the text in the file, so the identifier spans never move. The source has to actually +// be rewritten between the two compilations. + +use std::fs; +use std::path::PathBuf; + +use run_make_support::{rfs, rustc}; + +fn main() { + rustc().input("macros/lib.rs").crate_name("macros").crate_type("proc-macro").run(); + let macros_dylib = find_proc_macro_dylib("macros"); + + rfs::write("lib.rs", "#[derive(macros::Bar)]\npub enum FooEnum { One }\n"); + rustc() + .input("lib.rs") + .crate_type("lib") + .incremental("incr") + .arg("-Zincremental-verify-ich") + .extern_("macros", ¯os_dylib) + .run(); + + // Insert a variant *before* the existing one, moving `One`'s span. + rfs::write("lib.rs", "#[derive(macros::Bar)]\npub enum FooEnum { Zero, One }\n"); + let out = rustc() + .input("lib.rs") + .crate_type("lib") + .incremental("incr") + .arg("-Zincremental-verify-ich") + .extern_("macros", ¯os_dylib) + .run(); + + out.assert_stderr_not_contains("internal compiler error"); + out.assert_stderr_not_contains("Found unstable fingerprints"); +} + +fn find_proc_macro_dylib(name: &str) -> PathBuf { + let prefix = if cfg!(target_os = "windows") { "" } else { "lib" }; + + let ext: &str = if cfg!(target_os = "macos") { + "dylib" + } else if cfg!(target_os = "windows") { + "dll" + } else if cfg!(target_os = "aix") { + "a" + } else { + "so" + }; + + let lib_name = format!("{prefix}{name}.{ext}"); + + for entry in fs::read_dir(".").unwrap() { + let entry = entry.unwrap(); + let name = entry.file_name(); + let name = name.to_str().unwrap(); + if name == lib_name { + return entry.path(); + } + } + + panic!("could not find proc-macro dylib for `{name}`"); +} From 9291af1bbe9e1ad80a215d9211061837692bdcd8 Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Fri, 14 Aug 2026 13:58:01 +0000 Subject: [PATCH 23/49] add requested changes --- src/bootstrap/src/core/build_steps/test.rs | 8 +------- .../src/core/builder/cli_paths/snapshots/x_test.snap | 3 --- .../core/builder/cli_paths/snapshots/x_test_library.snap | 5 ----- .../x_test_library_core_and_alloc_and_stdarch.snap | 5 ----- .../builder/cli_paths/snapshots/x_test_skip_coverage.snap | 3 --- .../cli_paths/snapshots/x_test_skip_coverage_map.snap | 3 --- .../cli_paths/snapshots/x_test_skip_coverage_run.snap | 3 --- .../builder/cli_paths/snapshots/x_test_skip_tests.snap | 3 --- .../cli_paths/snapshots/x_test_skip_tests_coverage.snap | 3 --- 9 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 2cb78978b9f20..8d8a63291f527 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1211,9 +1211,6 @@ impl CommandLineStep for StdarchGenCheck { fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { run.alias("stdarch-gen-check") - .path("library/stdarch/crates/stdarch-gen-arm") - .path("library/stdarch/crates/stdarch-gen-loongarch") - .path("library/stdarch/crates/stdarch-gen-hexagon") } fn is_default_step(_builder: &Builder<'_>) -> bool { @@ -1230,7 +1227,7 @@ impl CommandLineStep for StdarchGenCheck { // `--bless` regenerates and writes back into the tree otherwise just check. let mode = if builder.config.cmd.bless() { "bless" } else { "check" }; - // Generators shell out to `rustfmt`skip if bootstrap has none for this channel. + // Generators shell out to `rustfmt`. Skip this step if bootstrap has none for this channel. let Some(rustfmt_path) = builder.ensure(InternalRustfmt) else { eprintln!( "WARNING: stdarch-gen-check skipped because rustfmt is required but not available on this channel" @@ -1239,9 +1236,6 @@ impl CommandLineStep for StdarchGenCheck { }; let mut path_dirs: Vec = Vec::new(); - if let Some(cargo_dir) = builder.initial_cargo.parent() { - path_dirs.push(cargo_dir.to_path_buf()); - } if let Some(rustfmt_dir) = rustfmt_path.parent() { path_dirs.push(rustfmt_dir.to_path_buf()); } diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap index 0b5fa1747c1ca..8bc5639677273 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test.snap @@ -187,9 +187,6 @@ expression: test - Set({library/stdarch/crates/stdarch-verify}) [Test] test::StdarchGenCheck targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap index 9b6016449c97b..0d6c34daacf0a 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library.snap @@ -21,8 +21,3 @@ expression: test library [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) -[Test] test::StdarchGenCheck - targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap index 00e616c820984..2664ab7a404cc 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_library_core_and_alloc_and_stdarch.snap @@ -9,8 +9,3 @@ expression: test library/core library/alloc library/stdarch [Test] test::StdarchVerify targets: [x86_64-unknown-linux-gnu] - Set({library/stdarch/crates/stdarch-verify}) -[Test] test::StdarchGenCheck - targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap index b3f0ef29c091e..a28d2bbe09e70 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage.snap @@ -184,9 +184,6 @@ expression: test --skip=coverage - Set({library/stdarch/crates/stdarch-verify}) [Test] test::StdarchGenCheck targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap index 9f6bc865ed959..c3f709deca166 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_map.snap @@ -187,9 +187,6 @@ expression: test --skip=coverage-map - Set({library/stdarch/crates/stdarch-verify}) [Test] test::StdarchGenCheck targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap index 3d45cab6f6c9e..0d012b6dc6851 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_coverage_run.snap @@ -187,9 +187,6 @@ expression: test --skip=coverage-run - Set({library/stdarch/crates/stdarch-verify}) [Test] test::StdarchGenCheck targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap index 392980c75d57c..7ce29f19beace 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests.snap @@ -148,9 +148,6 @@ expression: test --skip=tests - Set({library/stdarch/crates/stdarch-verify}) [Test] test::StdarchGenCheck targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) - Set({stdarch-gen-check}) [Test] test::RustdocTheme targets: [x86_64-unknown-linux-gnu] diff --git a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap index 4006ef2b8c57b..559231eac9e35 100644 --- a/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap +++ b/src/bootstrap/src/core/builder/cli_paths/snapshots/x_test_skip_tests_coverage.snap @@ -184,9 +184,6 @@ expression: test --skip=tests/coverage - Set({library/stdarch/crates/stdarch-verify}) [Test] test::StdarchGenCheck targets: [x86_64-unknown-linux-gnu] - - Set({library/stdarch/crates/stdarch-gen-arm}) - - Set({library/stdarch/crates/stdarch-gen-hexagon}) - - Set({library/stdarch/crates/stdarch-gen-loongarch}) - Set({stdarch-gen-check}) [Test] test::RustdocJSStd targets: [x86_64-unknown-linux-gnu] From 8e2b1c478d0e532011e783e393db5cfe2f1b7f0b Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Fri, 14 Aug 2026 17:16:08 +0000 Subject: [PATCH 24/49] pin stage0 rustc --- src/bootstrap/src/core/build_steps/test.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 8d8a63291f527..7acaef6f5c397 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1254,6 +1254,7 @@ impl CommandLineStep for StdarchGenCheck { cmd.arg("run").arg(selector).arg(pkg).arg("--release").arg("--").args(args); // RUSTC_BOOTSTRAP=1 allow nightly features when building tools against stage0. cmd.env("RUSTC_BOOTSTRAP", "1"); + cmd.env("RUSTC", &builder.initial_rustc); cmd.env("PATH", &new_path); cmd.env("CARGO_TARGET_DIR", &cargo_target_dir); cmd.env("STDARCH_GEN_MODE", mode); From 6cab463a7a9381471ee291057cf37aa664a0ae27 Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Fri, 14 Aug 2026 17:23:12 +0000 Subject: [PATCH 25/49] fix tidy --- src/bootstrap/src/core/build_steps/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 7acaef6f5c397..5da021182d0a1 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1254,7 +1254,7 @@ impl CommandLineStep for StdarchGenCheck { cmd.arg("run").arg(selector).arg(pkg).arg("--release").arg("--").args(args); // RUSTC_BOOTSTRAP=1 allow nightly features when building tools against stage0. cmd.env("RUSTC_BOOTSTRAP", "1"); - cmd.env("RUSTC", &builder.initial_rustc); + cmd.env("RUSTC", &builder.initial_rustc); cmd.env("PATH", &new_path); cmd.env("CARGO_TARGET_DIR", &cargo_target_dir); cmd.env("STDARCH_GEN_MODE", mode); From 80cc60a7ea59a2edf33c7cbbc3c6cfa2a0bcb78b Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 14 Aug 2026 21:26:24 +0200 Subject: [PATCH 26/49] Correctly test the custom GCC built in CI --- .../host-x86_64/dist-x86_64-linux/dist.sh | 11 ++++++++ src/ci/docker/scripts/build-gcc.sh | 26 +++++-------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 46d34cd001a95..0ccfd0d765946 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -18,4 +18,15 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then CC=/rustroot/bin/cc CXX=/rustroot/bin/c++ python3 ../x.py dist \ gcc-dev \ gcc + # We confirm that the built GCC has support for the `retain` attribute. + # FIXME: Maybe get the path from `.x.py` instead? + gcc_path="./build/$HOSTS/gcc/$HOSTS/install/bin/gcc" + if echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - | grep -i '"a.*R"'; then + echo "retain attribute is supported" + else + echo "retain attribute is not supported" + # We display the generated asm just in case... + echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - + exit 1 + fi fi diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 9a70071242d83..29502ec56a767 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -6,22 +6,22 @@ source shared.sh BINUTILS="2.47" curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - -cd binutils-$BINUTILS -hide_output ./configure --prefix=/rustroot +mkdir binutils-build +cd binutils-build +hide_output ../binutils-$BINUTILS/configure --prefix=/rustroot hide_output make -j$(nproc) hide_output make install -if echo '.section .test,"awR",@progbits' | /rustroot/bin/as - -o /dev/null 2>/dev/null; then +cd .. +rm -rf binutils-build binutils-$BINUTILS + +if echo '.section .test,"awR",@progbits' | as - -o /dev/null 2>/dev/null; then echo "binutils assembler supports SHF_GNU_RETAIN" else echo "binutils assembler DOES NOT support SHF_GNU_RETAIN" exit 1 fi -AS_PATH="/rustroot/bin/as" -LD_PATH="/rustroot/bin/ld" - -cd .. # Note: in the future when bumping to version 10.1.0, also take care of the sed block below. # This version is specified in the Dockerfile @@ -61,9 +61,6 @@ export PATH=/rustroot/bin:$PATH # which is included in librustc_driver.so hide_output ../gcc-$GCC/configure \ --prefix=/rustroot \ - --with-bintuils=/rustroot/bin \ - --with-as=$AS_PATH \ - --with-ld=$LD_PATH \ --enable-languages=c,c++ \ --disable-gnu-unique-object \ --enable-cxx-flags='-fno-reorder-blocks-and-partition' @@ -71,15 +68,6 @@ hide_output make -j$(nproc) hide_output make install ln -s gcc /rustroot/bin/cc -if echo 'int x __attribute__((used, retain));' | /rustroot/bin/gcc -S -x c -o - - | grep -i '"a.*R"'; then - echo "retain attribute is supported" -else - echo "retain attribute is not supported" - # We display the generated asm just in case... - echo 'int x __attribute__((used, retain));' | /rustroot/bin/gcc -S -x c -o - - - exit 1 -fi - cd .. rm -rf gcc-build rm -rf gcc-$GCC From 942fe31efedf5fee6f3d5dfdf21be2296704abab Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 14 Aug 2026 21:34:37 +0200 Subject: [PATCH 27/49] Fix tidy error --- src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 0ccfd0d765946..835fb6ee5e724 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -21,12 +21,13 @@ if [ "${DIST_TRY_BUILD:-0}" == "0" ]; then # We confirm that the built GCC has support for the `retain` attribute. # FIXME: Maybe get the path from `.x.py` instead? gcc_path="./build/$HOSTS/gcc/$HOSTS/install/bin/gcc" - if echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - | grep -i '"a.*R"'; then + c_code='int x __attribute__((used, retain));' + if echo "$c_code" | "$gcc_path" -S -x c -o - - | grep -i '"a.*R"'; then echo "retain attribute is supported" else echo "retain attribute is not supported" # We display the generated asm just in case... - echo 'int x __attribute__((used, retain));' | "$gcc_path" -S -x c -o - - + echo "$c_code" | "$gcc_path" -S -x c -o - - exit 1 fi fi From f08d8c47937307fad96c23ee6f748fb16e5aee3c Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Sat, 15 Aug 2026 13:05:18 +0000 Subject: [PATCH 28/49] pass explicit output dir --- src/bootstrap/src/core/build_steps/test.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 5da021182d0a1..3b5d801a31c61 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1261,7 +1261,11 @@ impl CommandLineStep for StdarchGenCheck { cmd.run(builder); }; - run_gen("--bin", "stdarch-gen-arm", &[OsStr::new("crates/stdarch-gen-arm/spec")]); + run_gen( + "--bin", + "stdarch-gen-arm", + &[OsStr::new("crates/stdarch-gen-arm/spec"), OsStr::new("crates/core_arch/src")], + ); run_gen("-p", "stdarch-gen-loongarch", &[OsStr::new("lsx")]); run_gen("-p", "stdarch-gen-loongarch", &[OsStr::new("lasx")]); run_gen("-p", "stdarch-gen-hexagon", &[]); From 581ac1c9eaace91ad57963875e78c53593aa92fc Mon Sep 17 00:00:00 2001 From: vad Date: Sat, 15 Aug 2026 17:40:43 +0200 Subject: [PATCH 29/49] Add documentation for BPF targets BPF targets, despite being Tier 3, were lacking documentation. Add it, describing how the targets work. Nominate @nagisa and myself as maintainers. --- src/doc/rustc/src/SUMMARY.md | 1 + src/doc/rustc/src/platform-support.md | 4 +- .../src/platform-support/bpf-unknown-none.md | 155 ++++++++++++++++++ 3 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 src/doc/rustc/src/platform-support/bpf-unknown-none.md diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index bedfa65ac894d..b9c79ab0128e9 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -87,6 +87,7 @@ - [\*-unknown-l4re](platform-support/l4re.md) - [\*-unknown-trusty](platform-support/trusty.md) - [\*-kmc-solid_\*](platform-support/kmc-solid.md) + - [bpf\*-unknown-none](platform-support/bpf-unknown-none.md) - [csky-unknown-linux-gnuabiv2\*](platform-support/csky-unknown-linux-gnuabiv2.md) - [hexagon-unknown-linux-musl](platform-support/hexagon-unknown-linux-musl.md) - [hexagon-unknown-none-elf](platform-support/hexagon-unknown-none-elf.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index c8ae02b091034..2643c7fd12891 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -330,8 +330,8 @@ target | std | host | notes [`armv7a-nuttx-eabi`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX [`armv7a-nuttx-eabihf`](platform-support/nuttx.md) | ✓ | | ARMv7-A with NuttX, hardfloat [`avr-none`](platform-support/avr-none.md) | * | | AVR; requires `-Zbuild-std=core` and `-Ctarget-cpu=...` -`bpfeb-unknown-none` | * | | BPF (big endian) -`bpfel-unknown-none` | * | | BPF (little endian) +[`bpfeb-unknown-none`](platform-support/bpf-unknown-none.md) | * | | BPF (big endian) +[`bpfel-unknown-none`](platform-support/bpf-unknown-none.md) | * | | BPF (little endian) [`csky-unknown-linux-gnuabiv2`](platform-support/csky-unknown-linux-gnuabiv2.md) | ✓ | | C-SKY abiv2 Linux (little endian) [`csky-unknown-linux-gnuabiv2hf`](platform-support/csky-unknown-linux-gnuabiv2.md) | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian) [`hexagon-unknown-linux-musl`](platform-support/hexagon-unknown-linux-musl.md) | ✓ | | Hexagon Linux with musl 1.2.5 diff --git a/src/doc/rustc/src/platform-support/bpf-unknown-none.md b/src/doc/rustc/src/platform-support/bpf-unknown-none.md new file mode 100644 index 0000000000000..430b5bc28646c --- /dev/null +++ b/src/doc/rustc/src/platform-support/bpf-unknown-none.md @@ -0,0 +1,155 @@ +# `bpf*-unknown-none` + +**Tier: 3** + +* `bpfeb-unknown-none` (big endian) +* `bpfel-unknown-none` (little endian) + +Targets for the 64-bit [BPF virtual machine][ebpf]. + +## Target maintainers + +[@nagisa](https://github.com/nagisa) [@vadorovsky](https://github.com/vadorovsky) + +## Requirements + +BPF targets require a Rust toolchain with the `rust-src` component. In +addition, you must install the [bpf-linker]. + +They don't support std and alloc and are meant for a `no_std` environment. + +`extern "C"` uses the [BPF ABI calling convention][bpf-abi]. + +Produced binaries use the ELF format. + +## Building the target + +You can build Rust with support for BPF targets by adding them to the `target` +list in `config.toml`: + +```toml +[build] +target = ["bpfeb-unknown-none", "bpfel-unknown-none"] +``` + +## Building Rust programs + +Rust does not yet ship pre-compiled artifacts for this target. To compile for +this target, you will either need to build Rust with the target enabled (see +"Building the target" above), or build your own copy of `core` by using +`build-std` or similar. + +Building the BPF target requires specifying it explicitly. Users can either +add it to the `target` list in `config.toml`: + +```toml +[build] +target = ["bpfel-unknown-none"] +``` + +Or specify it directly in the `cargo build` invocation: + +```console +cargo +nightly build -Z build-std=core --target bpfel-unknown-none +``` + +BPF has its own debug info format called [BTF][btf]. + +BPF targets use [bpf-linker], an LLVM bitcode linker. + +## Error handling + +There is no concept of stack unwinding in BPF, therefore BPF programs are +expected to handle errors in a recoverable manner. Therefore most BPF programs +written in Rust use the following no-op panic handler implementation: + +```rust,ignore (a panic handler implementation specific to BPF targets) +#[cfg(not(test))] +#[panic_handler] +fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} +``` + +Infinite loops are forbidden by the BPF verifier. Therefore, if the program +contains any code which can panic, the BPF VM refuses to load it. + +## Testing + +BPF bytecode needs to be executed on a BPF virtual machine, like the one +provided by the Linux kernel or one of the user-space implementations like +[rbpf][rbpf]. None of them support running Rust `#[test]` functions. One of the +reasons is the lack of support for panicking. + +Therefore, unit tests need to run on the host system. That requirement can be +enforced by the following conditional check: + +```rust +#[cfg(all(not(target_arch = "bpf"), test))] +mod test {} +``` + +## Cross-compilation toolchains + +BPF programs are always cross-compiled from a host (e.g. +`x86_64-unknown-linux-*`) for a BPF target (e.g. `bpfel-unknown-none`). + +The endianness of a chosen BPF target needs to match the endianness of the BPF +VM host on which the program is supposed to run. + +The architecture of the BPF VM host often has an impact on types that the BPF +programs should use. For example [kprobes][kprobe], [fprobes][fprobe] and +[uprobes][uprobe] allow dynamic function tracing and lookup into host registers +through the [`pt_regs`][pt-regs] struct, which differs across architectures. + +That difference is still not a concern of the compiler. Instead, it should be +handled by the developers. [Aya][aya] (the library for writing Linux BPF +programs and the main consumer of BPF targets in Rust) handles that by +providing the [`aya-ebpf-cty`][aya-ebpf-cty] crate, with type aliases similar +to those provided by [`core:ffi`][core-ffi]. [`aya-ebpf-cty`][aya-ebpf-cty] +allows to specify the VM target through the `CARGO_CFG_BPF_TARGET_ARCH` +environment variable (e.g. `CARGO_CFG_BPF_TARGET_ARCH=aarch64`). + +## C code + +It's possible to link a Rust BPF project to bitcode or object files which are +built from C code with [clang][clang]. It can be done using a `rustc-link-lib` +instruction in `build.rs`. Example: + +```rust,no_run +use std::{env, process::Command}; + +let out_dir = env::var("OUT_DIR").unwrap(); +let c_module = "my_module.bpf.c"; +let s = Command::new("clang") + .arg("-I") + .arg("src/") + .arg("-O2") + .arg("-emit-llvm") + .arg("-target") + .arg("bpf") + .arg("-c") + .arg("-g") + .arg(c_module) + .arg("-o") + .arg(format!("{out_dir}/my_module.bpf.o")) + .status() + .unwrap(); +assert!(s.success()); +println!("cargo:rustc-link-search=native={out_dir}"); +println!("cargo:rustc-link-lib=link-arg={out_dir}/my_module.bpf.o"); +``` + +[ebpf]: https://ebpf.io/ +[bpf-linker]: https://github.com/aya-rs/bpf-linker +[bpf-abi]: https://www.kernel.org/doc/html/v6.13-rc5/bpf/standardization/abi.html +[btf]: https://www.kernel.org/doc/html/latest/bpf/btf.html +[rbpf]: https://github.com/qmonnet/rbpf +[kprobe]: https://www.kernel.org/doc/html/latest/trace/kprobes.html +[fprobe]: https://www.kernel.org/doc/html/latest/trace/fprobe.html +[uprobe]: https://www.kernel.org/doc/html/latest/trace/uprobetracer.html +[pt-regs]: https://elixir.bootlin.com/linux/v6.12.6/source/arch/x86/include/uapi/asm/ptrace.h#L44 +[aya]: https://aya-rs.dev +[aya-ebpf-cty]: https://github.com/aya-rs/aya/tree/main/ebpf/aya-ebpf-cty +[core-ffi]: https://doc.rust-lang.org/stable/core/ffi/index.html +[clang]: https://clang.llvm.org/ From 0958d0c262d082031f2c6990a499167e4f725928 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 15 Aug 2026 17:27:22 -0400 Subject: [PATCH 30/49] Switch to c8a EC2 runner for auto merges --- src/ci/github-actions/jobs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index e7c33c13e2cf1..08121a9a693b7 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -312,7 +312,7 @@ auto: - name: dist-x86_64-illumos <<: *job-linux-4c - - <<: [*job-dist-x86_64-linux, *job-linux-36c-codebuild] + - <<: [*job-dist-x86_64-linux, *job-linux-32c-ec2] - name: dist-x86_64-linux-alt env: From d061443eaffeb978677e3b679f593ac5bc9c68fe Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 16 Aug 2026 00:03:18 +0200 Subject: [PATCH 31/49] Update `browser-ui-test` version to `0.25.1` --- yarn.lock | 68 +++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/yarn.lock b/yarn.lock index c62a4c75f949b..55c862d1e75dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -74,12 +74,12 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@puppeteer/browsers@3.0.6": - version "3.0.6" - resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-3.0.6.tgz#6b772e0fc11deb255c8a3c14219e34a16a2ab23d" - integrity sha512-B/gKoqlFkzhvzsI6jo9K1cZz9o5ypviVv/xu8CwA4grZzyVwN+XfkT+tu8T1zrauuEXv6VhS2oGX+6NL95WcKA== +"@puppeteer/browsers@3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-3.2.0.tgz#269293687a4c701a0a4701a15b50e9c0e337de93" + integrity sha512-LlBrE8oqGfU7b1Nk2d5Q1SbuPhZxTj0cJEMDPEws28OjNMELlflekmPPuf4FnK03x0ZRjKaYwJElUcKK4kyqJA== dependencies: - modern-tar "^0.7.6" + modern-tar "^0.8.0" yargs "^18.0.0" "@ungap/structured-clone@^1.2.0": @@ -113,9 +113,9 @@ ansi-regex@^5.0.1: integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== ansi-regex@^6.2.2: - version "6.2.2" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.2.2.tgz#60216eea464d864597ce2832000738a0589650c1" - integrity sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg== + version "6.3.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.3.0.tgz#247c8e7b70a1a43b10ce14c0226fcbf58e8815d5" + integrity sha512-WpDfL7NO6j7tH88IDBNVdUJxDh9nmCteAVW9dsep846XdwF4naCBK+/tGLX3KJgcpgMRXCFlTM2hKGoK9FsdrQ== ansi-styles@^4.1.0: version "4.3.0" @@ -155,9 +155,9 @@ braces@^3.0.3: fill-range "^7.1.1" browser-ui-test@^0.25.0: - version "0.25.0" - resolved "https://registry.yarnpkg.com/browser-ui-test/-/browser-ui-test-0.25.0.tgz#e24352d63009f07ec42583c96330a1ca57487d88" - integrity sha512-DBSpC3UFzQTKhj9cc11AiRliCUiWut1GAJ6sLPEYYPCmF6gTQGg/eynwev0NXPiDpuawiVxSpXPttHQePRK6Ug== + version "0.25.1" + resolved "https://registry.yarnpkg.com/browser-ui-test/-/browser-ui-test-0.25.1.tgz#c7f22a5e2b9e51be4ba34df3adf7bd7a9249bce6" + integrity sha512-woRwKU1dPBIwYmCI6npox8qlPO0WQ8GZH2YbL39mNkiWymByebiB4EK0PlaGMbmEja0MEqfMQD+d33LCW4S2AA== dependencies: css-unit-converter "^1.1.2" pngjs "^3.4.0" @@ -237,10 +237,10 @@ deep-is@^0.1.3: resolved "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== -devtools-protocol@0.0.1653615: - version "0.0.1653615" - resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1653615.tgz#c600e0c619612156b2422a66d958ba188d87dbe8" - integrity sha512-pGVkY3T/qXxAp2nFPodwYqOevk6ncNMSmvL8QfRCx5ZWGd6Vor7AFNmyaA8Zs6uJyP1QAfjuLandCgvSix1BNA== +devtools-protocol@0.0.1666840: + version "0.0.1666840" + resolved "https://registry.yarnpkg.com/devtools-protocol/-/devtools-protocol-0.0.1666840.tgz#796cbc307f82750afc13a3b471c829bf3da19a65" + integrity sha512-gCcO42XCHKEs7Ag0S7aGYsnJ7hlgrO3qderYqeiY0Eqk+0GFfuvT13IA0hHreJTa2KCdDVyGMeOhdMNmrrTjVg== doctrine@^3.0.0: version "3.0.0" @@ -626,10 +626,10 @@ mitt@^3.0.1: resolved "https://registry.yarnpkg.com/mitt/-/mitt-3.0.1.tgz#ea36cf0cc30403601ae074c8f77b7092cdab36d1" integrity sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw== -modern-tar@^0.7.6: - version "0.7.7" - resolved "https://registry.yarnpkg.com/modern-tar/-/modern-tar-0.7.7.tgz#ca71d79603630076b10733b0751ccab284bbc1ef" - integrity sha512-t9VmxaqrmANnEOBhpSDI6HD192Ge48k8vmWqQQL7hSFEqHEYwZbbsu49+aKLWZeRvFs3j1pMhXOqqF4kPlvjkQ== +modern-tar@^0.8.0: + version "0.8.4" + resolved "https://registry.yarnpkg.com/modern-tar/-/modern-tar-0.8.4.tgz#25d2de2f522250012f33a3b366400b49741f6b8e" + integrity sha512-gN54ddmyzEg10orwZ2u4OOv+bjpMWdIl5jIkodK97bMq8QBSL5c0D7YX0lT1Ooz+99S7+PvFbnxzdjgHo1r41g== ms@^2.1.3: version "2.1.3" @@ -716,28 +716,28 @@ punycode@^2.1.0: resolved "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== -puppeteer-core@25.4.0: - version "25.4.0" - resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-25.4.0.tgz#2fcba53a9ab94d55f196e1e42dbe794bbadf8759" - integrity sha512-K1plkLOdeoUnGeT1OvdqF3qxl33v+Ra/uH5VyPEhXdMcpvGiEskHzxxEU3fgpccJpJLIipB/rPUsvkZRWeKqOA== +puppeteer-core@25.7.0: + version "25.7.0" + resolved "https://registry.yarnpkg.com/puppeteer-core/-/puppeteer-core-25.7.0.tgz#e1a31698ec4646ecf891de42636d6f6405945625" + integrity sha512-wgBBj7dU5ceGyoT2PCrJpkYOhxPY8mDOmcSKZP92Cj5GgqQ3kv/UxzawnOLxiYuupe4bDf/yiQm3bzs/1nI0rQ== dependencies: - "@puppeteer/browsers" "3.0.6" + "@puppeteer/browsers" "3.2.0" chromium-bidi "17.0.2" - devtools-protocol "0.0.1653615" + devtools-protocol "0.0.1666840" typed-query-selector "^2.12.2" webdriver-bidi-protocol "0.4.2" ws "^8.21.1" puppeteer@^25.1.0: - version "25.4.0" - resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-25.4.0.tgz#87b549a666ffc4f68fee2f195c42d67eba9b8168" - integrity sha512-xfQp8dFBcGaLc1hEMaVr7s+oW4ZkAurr8Y9H81ilKhu6QoLfSTkZjU7IavnyJ/VWpB9ni3KNJUQHUatslLWyGw== + version "25.7.0" + resolved "https://registry.yarnpkg.com/puppeteer/-/puppeteer-25.7.0.tgz#4536e40b3685309b9f8444860d237d6be3484c83" + integrity sha512-zLBIYuW66SGwY7JNqGmiqeKiM92CYOs6xPibSRBPIeYGIfM1nE/8VCE8G0fGot2EfXENC4PbhktxLrQ0EK5Thg== dependencies: - "@puppeteer/browsers" "3.0.6" + "@puppeteer/browsers" "3.2.0" chromium-bidi "17.0.2" - devtools-protocol "0.0.1653615" + devtools-protocol "0.0.1666840" lilconfig "^3.1.3" - puppeteer-core "25.4.0" + puppeteer-core "25.7.0" typed-query-selector "^2.12.2" queue-microtask@^1.2.2: @@ -902,9 +902,9 @@ wrappy@1: integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== ws@^8.21.1: - version "8.21.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.21.1.tgz#045650cd4b1207809e7547146223c3814a9af586" - integrity sha512-+0NTnW77fFN/DjQi6k/Sq/Yvk4Sgajw7urW8V+asjXnRgDs9gyGkdb7EzgfhA4goXsRIZKE28fzIXBHEzhuiWw== + version "8.21.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.21.3.tgz#660b4faddb6a3e575c86e078126919961f4de4fc" + integrity sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw== y18n@^5.0.5: version "5.0.8" From 3183856eca58b52239dea80afd2d290bd71cec0e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 16 Aug 2026 00:03:50 +0200 Subject: [PATCH 32/49] Fix typo in search.js --- src/librustdoc/html/static/js/search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/js/search.js b/src/librustdoc/html/static/js/search.js index 976d7e39d4ddd..8584e0aff0538 100644 --- a/src/librustdoc/html/static/js/search.js +++ b/src/librustdoc/html/static/js/search.js @@ -5301,7 +5301,7 @@ async function showResults(docSearch, results, goToFirst, filterCrates) { } const crateSearch = document.getElementById("crate-search"); if (crateSearch) { - // #crate-search is an input element + // #crate-search is a `"). +assert-text: (".search-switcher", "Search results in all crates", STARTS_WITH) + +// Checking the display of the crate filter. +// We start with the light theme. +call-function: ("switch-theme", {"theme": "light"}) + +set-timeout: 2000 +wait-for: "#crate-search" +assert-css: ("#crate-search", { + "border": "1px solid #e0e0e0", + "color": "black", + "background-color": "white", +}) + +// We now check the dark theme. +call-function: ("switch-theme", {"theme": "dark"}) +wait-for-css: ("#crate-search", { + "border": "1px solid #e0e0e0", + "color": "#ddd", + "background-color": "#353535", +}) + +// And finally we check the ayu theme. +call-function: ("switch-theme", {"theme": "ayu"}) +wait-for-css: ("#crate-search", { + "border": "1px solid #5c6773", + "color": "#c5c5c5", + "background-color": "#0f1419", +}) From f955803a50e00e32320c03fb906c2f919c77097c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 14:36:39 +1000 Subject: [PATCH 34/49] Move `LLVM_TOOLS` and `LLD_FILE_NAMES` into `build_steps::dist` This seems to be the module that relies on them the most, and other modules already pull in things from `dist`. --- src/bootstrap/src/core/build_steps/compile.rs | 5 ++-- src/bootstrap/src/core/build_steps/dist.rs | 24 +++++++++++++++++-- src/bootstrap/src/core/build_steps/tool.rs | 3 ++- src/bootstrap/src/lib.rs | 20 ---------------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 6b659206fbca5..d3e454ae22c81 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -37,8 +37,7 @@ use crate::utils::helpers::{ self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date, }; use crate::{ - CLang, CodegenBackendKind, Compiler, DependencyType, FileType, GitRepo, LLVM_TOOLS, Mode, - debug, trace, + CLang, CodegenBackendKind, Compiler, DependencyType, FileType, GitRepo, Mode, debug, trace, }; /// Build a standard library for the given `target` using the given `build_compiler`. @@ -2179,7 +2178,7 @@ impl CommandLineStep for Assemble { let _llvm_tools_span = span!(tracing::Level::TRACE, "installing llvm tools to sysroot", ?libdir_bin) .entered(); - for tool in LLVM_TOOLS { + for tool in dist::LLVM_TOOLS { trace!("installing `{tool}`"); let tool_exe = exe(tool, target_compiler.host); let src_path = llvm_bin_dir.join(&tool_exe); diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index 43ac42a8158ba..e2301673141c6 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -40,7 +40,27 @@ use crate::utils::helpers::{ exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit, }; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; -use crate::{CodegenBackendKind, Compiler, DependencyType, FileType, LLVM_TOOLS, Mode, trace}; +use crate::{CodegenBackendKind, Compiler, DependencyType, FileType, Mode, trace}; + +pub(crate) const LLVM_TOOLS: &[&str] = &[ + "llvm-cov", // used to generate coverage report + "llvm-nm", // used to inspect binaries; it shows symbol names, their sizes and visibility + "llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume + "llvm-objdump", // used to disassemble programs + "llvm-profdata", // used to inspect and merge files generated by profiles + "llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide + "llvm-size", // used to prints the size of the linker sections of a program + "llvm-strip", // used to discard symbols from binary files to reduce their size + "llvm-ar", // used for creating and modifying archive files + "llvm-as", // used to convert LLVM assembly to LLVM bitcode + "llvm-dis", // used to disassemble LLVM bitcode + "llvm-link", // Used to link LLVM bitcode + "llc", // used to compile LLVM bytecode + "opt", // used to optimize LLVM bytecode +]; + +/// LLD file names for all flavors. +pub(crate) const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"]; pub fn pkgname(builder: &Builder<'_>, component: &str) -> String { format!("{}-{}", component, builder.rust_package_vers()) @@ -598,7 +618,7 @@ impl CommandLineStep for Rustc { let self_contained_lld_src_dir = src_dir.join("gcc-ld"); let self_contained_lld_dst_dir = dst_dir.join("gcc-ld"); t!(fs::create_dir(&self_contained_lld_dst_dir)); - for name in crate::LLD_FILE_NAMES { + for name in LLD_FILE_NAMES { let exe_name = exe(name, target_compiler.host); builder.copy_link( &self_contained_lld_src_dir.join(&exe_name), diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 75d5fdcdd2c33..32dd25e88ed2f 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -14,6 +14,7 @@ use std::path::{Path, PathBuf}; use std::{env, fs}; use crate::core::build_steps::compile::{CargoMessage, is_lto_stage}; +use crate::core::build_steps::dist::LLD_FILE_NAMES; use crate::core::build_steps::toolstate::ToolState; use crate::core::build_steps::{compile, llvm}; use crate::core::builder::{ @@ -978,7 +979,7 @@ pub(crate) fn copy_lld_artifacts( let self_contained_lld_dir = libdir_bin.join("gcc-ld"); t!(fs::create_dir_all(&self_contained_lld_dir)); - for name in crate::LLD_FILE_NAMES { + for name in LLD_FILE_NAMES { builder.copy_link( &lld_wrapper.tool.tool_path, &self_contained_lld_dir.join(exe(name, target)), diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 116099ee3972f..800099d6fdae6 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -50,26 +50,6 @@ pub mod cli_main; mod core; mod utils; -const LLVM_TOOLS: &[&str] = &[ - "llvm-cov", // used to generate coverage report - "llvm-nm", // used to inspect binaries; it shows symbol names, their sizes and visibility - "llvm-objcopy", // used to transform ELFs into binary format which flashing tools consume - "llvm-objdump", // used to disassemble programs - "llvm-profdata", // used to inspect and merge files generated by profiles - "llvm-readobj", // used to get information from ELFs/objects that the other tools don't provide - "llvm-size", // used to prints the size of the linker sections of a program - "llvm-strip", // used to discard symbols from binary files to reduce their size - "llvm-ar", // used for creating and modifying archive files - "llvm-as", // used to convert LLVM assembly to LLVM bitcode - "llvm-dis", // used to disassemble LLVM bitcode - "llvm-link", // Used to link LLVM bitcode - "llc", // used to compile LLVM bytecode - "opt", // used to optimize LLVM bytecode -]; - -/// LLD file names for all flavors. -const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"]; - /// Extra `--check-cfg` to add when building the compiler or tools /// (Mode restriction, config name, config values (if any)) #[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above. From 73960bfc3c658c26cdfbb6c7e95bed56589e542f Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 14:45:05 +1000 Subject: [PATCH 35/49] Move `EXTRA_CHECK_CFGS` into `crate::core::builder::cargo` --- src/bootstrap/src/core/builder/cargo.rs | 20 ++++++++++++++++---- src/bootstrap/src/lib.rs | 15 --------------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 1ae2f69ccfe84..e5a9f405dc1cf 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -11,10 +11,22 @@ use crate::core::config::{CompressDebuginfo, Config, DryRun, SplitDebuginfo, Tar use crate::utils::build_stamp; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_flags, t}; -use crate::{ - CLang, Compiler, EXTRA_CHECK_CFGS, GitRepo, Mode, RemapScheme, envify, - prepare_behaviour_dump_dir, -}; +use crate::{CLang, Compiler, GitRepo, Mode, RemapScheme, envify, prepare_behaviour_dump_dir}; + +/// Extra `--check-cfg` to add when building the compiler or tools +/// (Mode restriction, config name, config values (if any)) +#[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above. +const EXTRA_CHECK_CFGS: &[(Option, &str, Option<&[&'static str]>)] = &[ + (Some(Mode::Rustc), "bootstrap", None), + (Some(Mode::Codegen), "bootstrap", None), + (Some(Mode::ToolRustcPrivate), "bootstrap", None), + (Some(Mode::ToolStd), "bootstrap", None), + (Some(Mode::ToolRustcPrivate), "rust_analyzer", None), + (Some(Mode::ToolStd), "rust_analyzer", None), + // Any library specific cfgs like `target_os`, `target_arch` should be put in + // priority the `[lints.rust.unexpected_cfgs.check-cfg]` table + // in the appropriate `library/{std,alloc,core}/Cargo.toml` +]; /// Represents flag values in `String` form with a `\x1f` delimiter to pass to the compiler later. /// diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 800099d6fdae6..61165cee13b40 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -50,21 +50,6 @@ pub mod cli_main; mod core; mod utils; -/// Extra `--check-cfg` to add when building the compiler or tools -/// (Mode restriction, config name, config values (if any)) -#[expect(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above. -const EXTRA_CHECK_CFGS: &[(Option, &str, Option<&[&'static str]>)] = &[ - (Some(Mode::Rustc), "bootstrap", None), - (Some(Mode::Codegen), "bootstrap", None), - (Some(Mode::ToolRustcPrivate), "bootstrap", None), - (Some(Mode::ToolStd), "bootstrap", None), - (Some(Mode::ToolRustcPrivate), "rust_analyzer", None), - (Some(Mode::ToolStd), "rust_analyzer", None), - // Any library specific cfgs like `target_os`, `target_arch` should be put in - // priority the `[lints.rust.unexpected_cfgs.check-cfg]` table - // in the appropriate `library/{std,alloc,core}/Cargo.toml` -]; - /// A structure representing a Rust compiler. /// /// Each compiler has a `stage` that it is associated with and a `host` that From 43620bc5ef5e112c69f6df3bdd4c09c3dcae7abc Mon Sep 17 00:00:00 2001 From: vad Date: Sun, 16 Aug 2026 09:05:07 +0200 Subject: [PATCH 36/49] Describe Linux kernel version reqirements --- .../rustc/src/platform-support/bpf-unknown-none.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/rustc/src/platform-support/bpf-unknown-none.md b/src/doc/rustc/src/platform-support/bpf-unknown-none.md index 430b5bc28646c..84242755a9b24 100644 --- a/src/doc/rustc/src/platform-support/bpf-unknown-none.md +++ b/src/doc/rustc/src/platform-support/bpf-unknown-none.md @@ -22,6 +22,14 @@ They don't support std and alloc and are meant for a `no_std` environment. Produced binaries use the ELF format. +BPF virtual machines provide a [JIT compiler][jit] that compiles the BPF +bytecode into the native host architecture. + +Running BPF programs on most host architectures requires Linux kernel 4.18, +[that introduced BTF][linux-commit-btf], or newer. On RISC-V hosts that +requirement goes up to [5.7][linux-commit-riscv], on PowerPC32 - to [5.13] +[linux-commit-ppc32], and on LoongArch - to [6.1][linux-commit-loongarch]. + ## Building the target You can build Rust with support for BPF targets by adding them to the `target` @@ -143,6 +151,11 @@ println!("cargo:rustc-link-lib=link-arg={out_dir}/my_module.bpf.o"); [ebpf]: https://ebpf.io/ [bpf-linker]: https://github.com/aya-rs/bpf-linker [bpf-abi]: https://www.kernel.org/doc/html/v6.13-rc5/bpf/standardization/abi.html +[jit]: https://www.kernel.org/doc/html/latest/networking/filter.html#jit-compiler +[linux-commit-btf]: https://github.com/torvalds/linux/commit/69b693f0a +[linux-commit-riscv]: https://github.com/torvalds/linux/commit/5f316b65e +[linux-commit-ppc32]: https://github.com/torvalds/linux/commit/51c66ad84 +[linux-commit-loongarch]: https://github.com/torvalds/linux/commit/5dc615520 [btf]: https://www.kernel.org/doc/html/latest/bpf/btf.html [rbpf]: https://github.com/qmonnet/rbpf [kprobe]: https://www.kernel.org/doc/html/latest/trace/kprobes.html From 7e2707604356187efe9a5e81fe147927d996aea4 Mon Sep 17 00:00:00 2001 From: vad Date: Sun, 16 Aug 2026 09:10:47 +0200 Subject: [PATCH 37/49] Mention the plan of using GNU flabor of linker --- src/doc/rustc/src/platform-support/bpf-unknown-none.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/bpf-unknown-none.md b/src/doc/rustc/src/platform-support/bpf-unknown-none.md index 84242755a9b24..be6975f6ee330 100644 --- a/src/doc/rustc/src/platform-support/bpf-unknown-none.md +++ b/src/doc/rustc/src/platform-support/bpf-unknown-none.md @@ -63,7 +63,9 @@ cargo +nightly build -Z build-std=core --target bpfel-unknown-none BPF has its own debug info format called [BTF][btf]. -BPF targets use [bpf-linker], an LLVM bitcode linker. +BPF targets use [bpf-linker], an LLVM bitcode linker. In future, they may +migrate to the GNU flavor of linker, see the details in the [following issue] +[bpf-object-linking]. ## Error handling @@ -157,6 +159,7 @@ println!("cargo:rustc-link-lib=link-arg={out_dir}/my_module.bpf.o"); [linux-commit-ppc32]: https://github.com/torvalds/linux/commit/51c66ad84 [linux-commit-loongarch]: https://github.com/torvalds/linux/commit/5dc615520 [btf]: https://www.kernel.org/doc/html/latest/bpf/btf.html +[bpf-object-linking]: https://github.com/rust-lang/rust/issues/135175 [rbpf]: https://github.com/qmonnet/rbpf [kprobe]: https://www.kernel.org/doc/html/latest/trace/kprobes.html [fprobe]: https://www.kernel.org/doc/html/latest/trace/fprobe.html From 3da3659c076bfa4b91f02329e57476fc953fd6ba Mon Sep 17 00:00:00 2001 From: vad Date: Sun, 16 Aug 2026 09:12:42 +0200 Subject: [PATCH 38/49] Fix the link to the BPF ABI convention --- src/doc/rustc/src/platform-support/bpf-unknown-none.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/bpf-unknown-none.md b/src/doc/rustc/src/platform-support/bpf-unknown-none.md index be6975f6ee330..a25520564d505 100644 --- a/src/doc/rustc/src/platform-support/bpf-unknown-none.md +++ b/src/doc/rustc/src/platform-support/bpf-unknown-none.md @@ -152,7 +152,7 @@ println!("cargo:rustc-link-lib=link-arg={out_dir}/my_module.bpf.o"); [ebpf]: https://ebpf.io/ [bpf-linker]: https://github.com/aya-rs/bpf-linker -[bpf-abi]: https://www.kernel.org/doc/html/v6.13-rc5/bpf/standardization/abi.html +[bpf-abi]: https://www.kernel.org/doc/html/latest/bpf/standardization/abi.html [jit]: https://www.kernel.org/doc/html/latest/networking/filter.html#jit-compiler [linux-commit-btf]: https://github.com/torvalds/linux/commit/69b693f0a [linux-commit-riscv]: https://github.com/torvalds/linux/commit/5f316b65e From ea31c35e770e1c4ee8aaba2ca32589b604a8bbb0 Mon Sep 17 00:00:00 2001 From: vad Date: Sun, 16 Aug 2026 09:14:50 +0200 Subject: [PATCH 39/49] Remove the "no-op" word from panic handler description It's confusing, and the next paragraph explains what's exactly happening. --- src/doc/rustc/src/platform-support/bpf-unknown-none.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/bpf-unknown-none.md b/src/doc/rustc/src/platform-support/bpf-unknown-none.md index a25520564d505..2e0e7e2f9d023 100644 --- a/src/doc/rustc/src/platform-support/bpf-unknown-none.md +++ b/src/doc/rustc/src/platform-support/bpf-unknown-none.md @@ -71,7 +71,7 @@ migrate to the GNU flavor of linker, see the details in the [following issue] There is no concept of stack unwinding in BPF, therefore BPF programs are expected to handle errors in a recoverable manner. Therefore most BPF programs -written in Rust use the following no-op panic handler implementation: +written in Rust use the following panic handler implementation: ```rust,ignore (a panic handler implementation specific to BPF targets) #[cfg(not(test))] From 5e54aa26a041edfdbfb834c6186970492b047a1a Mon Sep 17 00:00:00 2001 From: vad Date: Sun, 16 Aug 2026 09:28:30 +0200 Subject: [PATCH 40/49] Pin all kernel links to the v6.13 --- .../rustc/src/platform-support/bpf-unknown-none.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/rustc/src/platform-support/bpf-unknown-none.md b/src/doc/rustc/src/platform-support/bpf-unknown-none.md index 2e0e7e2f9d023..4b1d46e0b41d7 100644 --- a/src/doc/rustc/src/platform-support/bpf-unknown-none.md +++ b/src/doc/rustc/src/platform-support/bpf-unknown-none.md @@ -152,18 +152,18 @@ println!("cargo:rustc-link-lib=link-arg={out_dir}/my_module.bpf.o"); [ebpf]: https://ebpf.io/ [bpf-linker]: https://github.com/aya-rs/bpf-linker -[bpf-abi]: https://www.kernel.org/doc/html/latest/bpf/standardization/abi.html -[jit]: https://www.kernel.org/doc/html/latest/networking/filter.html#jit-compiler +[bpf-abi]: https://www.kernel.org/doc/html/v6.13/bpf/standardization/abi.html +[jit]: https://www.kernel.org/doc/html/v6.13/networking/filter.html#jit-compiler [linux-commit-btf]: https://github.com/torvalds/linux/commit/69b693f0a [linux-commit-riscv]: https://github.com/torvalds/linux/commit/5f316b65e [linux-commit-ppc32]: https://github.com/torvalds/linux/commit/51c66ad84 [linux-commit-loongarch]: https://github.com/torvalds/linux/commit/5dc615520 -[btf]: https://www.kernel.org/doc/html/latest/bpf/btf.html +[btf]: https://www.kernel.org/doc/html/v6.13/bpf/btf.html [bpf-object-linking]: https://github.com/rust-lang/rust/issues/135175 [rbpf]: https://github.com/qmonnet/rbpf -[kprobe]: https://www.kernel.org/doc/html/latest/trace/kprobes.html -[fprobe]: https://www.kernel.org/doc/html/latest/trace/fprobe.html -[uprobe]: https://www.kernel.org/doc/html/latest/trace/uprobetracer.html +[kprobe]: https://www.kernel.org/doc/html/v6.13/trace/kprobes.html +[fprobe]: https://www.kernel.org/doc/html/v6.13/trace/fprobe.html +[uprobe]: https://www.kernel.org/doc/html/v6.13/trace/uprobetracer.html [pt-regs]: https://elixir.bootlin.com/linux/v6.12.6/source/arch/x86/include/uapi/asm/ptrace.h#L44 [aya]: https://aya-rs.dev [aya-ebpf-cty]: https://github.com/aya-rs/aya/tree/main/ebpf/aya-ebpf-cty From 7322485defd33090a2c17517569ca76187684683 Mon Sep 17 00:00:00 2001 From: cyrgani Date: Sat, 15 Aug 2026 22:22:23 +0000 Subject: [PATCH 41/49] add crashtests --- tests/crashes/126725.rs | 22 ++++++++++++++++++++++ tests/crashes/138262.rs | 11 +++++++++++ tests/crashes/141590.rs | 9 +++++++++ tests/crashes/142229.rs | 7 +++++++ tests/crashes/145217.rs | 6 ++++++ tests/crashes/148094.rs | 11 +++++++++++ tests/crashes/148095.rs | 11 +++++++++++ tests/crashes/152410.rs | 9 +++++++++ 8 files changed, 86 insertions(+) create mode 100644 tests/crashes/126725.rs create mode 100644 tests/crashes/138262.rs create mode 100644 tests/crashes/141590.rs create mode 100644 tests/crashes/142229.rs create mode 100644 tests/crashes/145217.rs create mode 100644 tests/crashes/148094.rs create mode 100644 tests/crashes/148095.rs create mode 100644 tests/crashes/152410.rs diff --git a/tests/crashes/126725.rs b/tests/crashes/126725.rs new file mode 100644 index 0000000000000..33893f95537fd --- /dev/null +++ b/tests/crashes/126725.rs @@ -0,0 +1,22 @@ +//@ known-bug: #126725 +type Indirect = ::Output; + +trait Foo { + fn foo<'a>() -> Indirect<&'a impl Sized>; +} + +trait Bar { + type Output; +} + +impl<'a> Bar for &'a () { + type Output = &'a i32; +} + +impl Foo for () { + fn foo<'a>() -> <&'a Self as Bar>::Output { + &0 + } +} + +fn main() {} diff --git a/tests/crashes/138262.rs b/tests/crashes/138262.rs new file mode 100644 index 0000000000000..b99daeae98e41 --- /dev/null +++ b/tests/crashes/138262.rs @@ -0,0 +1,11 @@ +//@ known-bug: #138262 +//@ compile-flags: -Zsanitizer=cfi -Ccodegen-units=1 -Clto -Clink-dead-code=true -Cunsafe-allow-abi-mismatch=sanitizer +//@ ignore-backends: gcc +fn foo() {} + +core::arch::global_asm!("/* {} */", sym foo::<{ + || {}; + 0 +}>); + +fn main() {} diff --git a/tests/crashes/141590.rs b/tests/crashes/141590.rs new file mode 100644 index 0000000000000..71276c50c7dda --- /dev/null +++ b/tests/crashes/141590.rs @@ -0,0 +1,9 @@ +//@ known-bug: #141590 +use std::sync::OnceLock; + +enum Void {} + +static LAZY_INIT: Void = OnceLock::new(); +static LAZY_INIT_REF: &[&Void] = &[&LAZY_INIT]; + +fn main() {} diff --git a/tests/crashes/142229.rs b/tests/crashes/142229.rs new file mode 100644 index 0000000000000..b34a7636b4185 --- /dev/null +++ b/tests/crashes/142229.rs @@ -0,0 +1,7 @@ +//@ known-bug: #142229 +#![feature(super_let)] + +const _: *const i32 = { + super let x = 1; + &raw const x +}; diff --git a/tests/crashes/145217.rs b/tests/crashes/145217.rs new file mode 100644 index 0000000000000..75e23b7728e37 --- /dev/null +++ b/tests/crashes/145217.rs @@ -0,0 +1,6 @@ +//@ known-bug: #145217 +//@ compile-flags: -Zlint-mir +#![feature(super_let)] +fn main() { + super let Some(1) = Some(2) else { return }; +} diff --git a/tests/crashes/148094.rs b/tests/crashes/148094.rs new file mode 100644 index 0000000000000..7c08240a198c5 --- /dev/null +++ b/tests/crashes/148094.rs @@ -0,0 +1,11 @@ +//@ known-bug: #148094 +//@ compile-flags: -Zvalidate-mir +#![feature(type_alias_impl_trait)] +type Tait = impl Sized; +trait Foo: Bar {} +trait Bar {} +#[define_opaque(Tait)] +fn test_correct3(x: &dyn Foo) -> &dyn Bar<()> { + x +} +fn main() {} diff --git a/tests/crashes/148095.rs b/tests/crashes/148095.rs new file mode 100644 index 0000000000000..43be99254164f --- /dev/null +++ b/tests/crashes/148095.rs @@ -0,0 +1,11 @@ +//@ known-bug: #148095 +use std::ops::Mul; + +struct Quantity(S); +impl Mul>::Output>> for f32 +where + Quantity: +{ + type Output = (); + fn mul(self, _: Quantity<>::Output>) {} +} diff --git a/tests/crashes/152410.rs b/tests/crashes/152410.rs new file mode 100644 index 0000000000000..94fc9c0dd19eb --- /dev/null +++ b/tests/crashes/152410.rs @@ -0,0 +1,9 @@ +//@ known-bug: #152410 +trait Trait { + fn foo(&self); +} +impl Trait for () {} + +const OBJECT: *const (dyn Trait + Send) = &(); + +const _: *const dyn Send = OBJECT as _; From 96123571d2bca493a01c3604ac5af52436a5085c Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 13:17:00 +1000 Subject: [PATCH 42/49] Move `Compiler` to its own module `crate::core::compiler` --- src/bootstrap/src/core/build_steps/check.rs | 3 +- src/bootstrap/src/core/build_steps/clean.rs | 3 +- src/bootstrap/src/core/build_steps/clippy.rs | 3 +- src/bootstrap/src/core/build_steps/compile.rs | 5 +- src/bootstrap/src/core/build_steps/dist.rs | 3 +- src/bootstrap/src/core/build_steps/doc.rs | 3 +- src/bootstrap/src/core/build_steps/install.rs | 2 +- .../src/core/build_steps/synthetic_targets.rs | 2 +- src/bootstrap/src/core/build_steps/test.rs | 3 +- src/bootstrap/src/core/build_steps/tool.rs | 3 +- src/bootstrap/src/core/builder/cargo.rs | 3 +- src/bootstrap/src/core/builder/mod.rs | 3 +- src/bootstrap/src/core/builder/tests.rs | 2 +- src/bootstrap/src/core/compiler.rs | 51 +++++++++++++++++++ src/bootstrap/src/core/mod.rs | 1 + src/bootstrap/src/lib.rs | 49 +----------------- src/bootstrap/src/utils/build_stamp.rs | 3 +- 17 files changed, 78 insertions(+), 64 deletions(-) create mode 100644 src/bootstrap/src/core/compiler.rs diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index ff16a814c456d..e72f1d05003b0 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -16,11 +16,12 @@ use crate::core::builder::{ self, Alias, Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description, }; +use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; use crate::core::config::flags::Subcommand; use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::helpers::t; -use crate::{CodegenBackendKind, Compiler, Mode}; +use crate::{CodegenBackendKind, Mode}; /// Allows individual check-step instances to keep track of whether they /// represent `cargo check` or `cargo fix`, independently of [`Builder::kind`]. diff --git a/src/bootstrap/src/core/build_steps/clean.rs b/src/bootstrap/src/core/build_steps/clean.rs index b7dae28c42ab3..a5c7398d11302 100644 --- a/src/bootstrap/src/core/build_steps/clean.rs +++ b/src/bootstrap/src/core/build_steps/clean.rs @@ -12,10 +12,11 @@ use std::path::Path; use crate::core::builder::{ Builder, CommandLineStep, Kind, RunConfig, ShouldRun, crate_description, }; +use crate::core::compiler::Compiler; use crate::core::config::flags::Subcommand; use crate::utils::build_stamp::BuildStamp; use crate::utils::helpers::t; -use crate::{Build, Compiler, Mode}; +use crate::{Build, Mode}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CleanAll {} diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index 0d5dd410a57c6..8dc4e1f62eede 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -14,6 +14,7 @@ //! (as usual) a massive undertaking/refactoring. use super::tool::{SourceType, prepare_tool_cargo}; +use crate::Mode; use crate::core::build_steps::check::{CompilerForCheck, prepare_compiler_for_check}; use crate::core::build_steps::compile::{ ArtifactKeepMode, run_cargo, rustc_cargo, std_cargo, std_crates_for_make_run, @@ -22,11 +23,11 @@ use crate::core::builder::{ self, Alias, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, StepMetadata, crate_description, }; +use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; use crate::core::config::flags::Subcommand; use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::helpers; -use crate::{Compiler, Mode}; /// Disable the most spammy clippy lints const IGNORED_RULES_FOR_STD_AND_RUSTC: &[&str] = &[ diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index d3e454ae22c81..97c834cfaf666 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -26,6 +26,7 @@ use crate::core::builder::{ self, Builder, Cargo, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, apply_pgo, crate_description, }; +use crate::core::compiler::Compiler; use crate::core::config::toml::target::DefaultLinuxLinkerOverride; use crate::core::config::{ Allocator, CompilerBuiltins, DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection, @@ -36,9 +37,7 @@ use crate::utils::exec::command; use crate::utils::helpers::{ self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date, }; -use crate::{ - CLang, CodegenBackendKind, Compiler, DependencyType, FileType, GitRepo, Mode, debug, trace, -}; +use crate::{CLang, CodegenBackendKind, DependencyType, FileType, GitRepo, Mode, debug, trace}; /// Build a standard library for the given `target` using the given `build_compiler`. #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index e2301673141c6..d45ddc4a4a257 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -32,6 +32,7 @@ use crate::core::build_steps::{compile, llvm}; use crate::core::builder::{ Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, }; +use crate::core::compiler::Compiler; use crate::core::config::{GccCiMode, TargetSelection}; use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::channel::{self, Info}; @@ -40,7 +41,7 @@ use crate::utils::helpers::{ exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit, }; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; -use crate::{CodegenBackendKind, Compiler, DependencyType, FileType, Mode, trace}; +use crate::{CodegenBackendKind, DependencyType, FileType, Mode, trace}; pub(crate) const LLVM_TOOLS: &[&str] = &[ "llvm-cov", // used to generate coverage report diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 21f1395351a80..adff654fe88e8 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -19,9 +19,10 @@ use crate::core::builder::{ self, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description, }; +use crate::core::compiler::Compiler; use crate::core::config::{Config, TargetSelection}; use crate::utils::helpers::{submodule_path_of, symlink_dir, t, up_to_date}; -use crate::{Compiler, FileType, Mode}; +use crate::{FileType, Mode}; macro_rules! book { ($($name:ident, $path:expr, $book_name:expr, $lang:expr ;)+) => { diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 766c2cc0297d6..db0d18e8368e2 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -6,10 +6,10 @@ use std::path::{Component, Path, PathBuf}; use std::{env, fs}; -use crate::Compiler; use crate::core::build_steps::dist; use crate::core::build_steps::tool::RustcPrivateCompilers; use crate::core::builder::{Builder, CommandLineStep, Kind, RunConfig, ShouldRun}; +use crate::core::compiler::Compiler; use crate::core::config::{Config, TargetSelection}; use crate::utils::exec::command; use crate::utils::helpers::t; diff --git a/src/bootstrap/src/core/build_steps/synthetic_targets.rs b/src/bootstrap/src/core/build_steps/synthetic_targets.rs index 88f04dcb27c6e..2b5039214f62c 100644 --- a/src/bootstrap/src/core/build_steps/synthetic_targets.rs +++ b/src/bootstrap/src/core/build_steps/synthetic_targets.rs @@ -7,8 +7,8 @@ //! one of the target specs already defined in this module, or create new ones by adding a new step //! that calls create_synthetic_target. -use crate::Compiler; use crate::core::builder::{Builder, Step}; +use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 6776487b5870e..7578a90d205c4 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -34,6 +34,7 @@ use crate::core::builder::{ self, Alias, Builder, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, crate_description, }; +use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; use crate::core::config::flags::{Subcommand, get_completion, top_level_help}; use crate::core::{android, debuggers}; @@ -45,7 +46,7 @@ use crate::utils::helpers::{ up_to_date, }; use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; -use crate::{CLang, CodegenBackendKind, Compiler, GitRepo, Mode, TestTarget, envify}; +use crate::{CLang, CodegenBackendKind, GitRepo, Mode, TestTarget, envify}; mod compiletest; pub mod failed_tests; diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 32dd25e88ed2f..f74207fdd6d32 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -21,10 +21,11 @@ use crate::core::builder::{ self, Builder, Cargo as CargoCommand, CommandLineStep, Kind, RunConfig, ShouldRun, Step, StepMetadata, apply_pgo, cargo_profile_var, }; +use crate::core::compiler::Compiler; use crate::core::config::{Allocator, DebuginfoLevel, RustcLto, TargetSelection}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, add_dylib_path, exe, t}; -use crate::{Compiler, FileType, Mode}; +use crate::{FileType, Mode}; #[derive(Debug, Clone, Hash, PartialEq, Eq)] pub enum SourceType { diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index e5a9f405dc1cf..d157610add218 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -5,13 +5,14 @@ use std::path::{Path, PathBuf}; use super::{Builder, Kind}; use crate::core::build_steps::test; use crate::core::build_steps::tool::SourceType; +use crate::core::compiler::Compiler; use crate::core::config::flags::Color; use crate::core::config::toml::pgo::PgoConfig; use crate::core::config::{CompressDebuginfo, Config, DryRun, SplitDebuginfo, TargetSelection}; use crate::utils::build_stamp; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_flags, t}; -use crate::{CLang, Compiler, GitRepo, Mode, RemapScheme, envify, prepare_behaviour_dump_dir}; +use crate::{CLang, GitRepo, Mode, RemapScheme, envify, prepare_behaviour_dump_dir}; /// Extra `--check-cfg` to add when building the compiler or tools /// (Mode restriction, config name, config values (if any)) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index e941e26e43efb..0c57bbff1749a 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -21,6 +21,7 @@ use crate::core::build_steps::{ }; use crate::core::builder::step_stack::StepRecord; pub use crate::core::builder::step_stack::StepStack; +use crate::core::compiler::Compiler; use crate::core::config::flags::Subcommand; use crate::core::config::{DryRun, TargetSelection}; use crate::utils::build_stamp::BuildStamp; @@ -28,7 +29,7 @@ use crate::utils::cache::Cache; use crate::utils::exec::{BootstrapCommand, ExecutionContext, command}; use crate::utils::helpers::{self, LldThreads, add_dylib_path, exe, libdir, linker_args, t}; use crate::utils::tracing::format_location; -use crate::{Build, Compiler, Crate, trace}; +use crate::{Build, Crate, trace}; mod cargo; mod cli_paths; diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index d5e2ef1579dc1..223ecdc8298dd 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -389,10 +389,10 @@ fn any_debug() { /// These tests use insta for snapshot testing. /// See bootstrap's README on how to bless the snapshots. mod snapshot { - use crate::Compiler; use crate::core::build_steps::test; use crate::core::builder::tests::{RenderConfig, TEST_TRIPLE_1, TEST_TRIPLE_2, host_target}; use crate::core::builder::{Kind, StepMetadata}; + use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; use crate::core::config::toml::target::{ DefaultLinuxLinkerOverride, with_default_linux_linker_overrides, diff --git a/src/bootstrap/src/core/compiler.rs b/src/bootstrap/src/core/compiler.rs new file mode 100644 index 0000000000000..a57c60465f24c --- /dev/null +++ b/src/bootstrap/src/core/compiler.rs @@ -0,0 +1,51 @@ +use std::hash::{Hash, Hasher}; + +use crate::Build; +use crate::core::config::TargetSelection; + +/// A structure representing a Rust compiler. +/// +/// Each compiler has a `stage` that it is associated with and a `host` that +/// corresponds to the platform the compiler runs on. +#[derive(Eq, PartialOrd, Ord, Clone, Copy, Debug)] +pub struct Compiler { + pub(crate) stage: u32, + pub(crate) host: TargetSelection, + /// Indicates whether the compiler was forced to use a specific stage. + /// This field is ignored in `Hash` and `PartialEq` implementations as only the `stage` + /// and `host` fields are relevant for those. + pub(crate) forced_compiler: bool, +} + +impl Hash for Compiler { + fn hash(&self, state: &mut H) { + self.stage.hash(state); + self.host.hash(state); + } +} + +impl PartialEq for Compiler { + fn eq(&self, other: &Self) -> bool { + self.stage == other.stage && self.host == other.host + } +} + +impl Compiler { + pub(crate) fn new(stage: u32, host: TargetSelection) -> Self { + Self { stage, host, forced_compiler: false } + } + + pub(crate) fn forced_compiler(&mut self, forced_compiler: bool) { + self.forced_compiler = forced_compiler; + } + + /// Returns `true` if this is a snapshot compiler for `build`'s configuration + pub(crate) fn is_snapshot(&self, build: &Build) -> bool { + self.stage == 0 && self.host == build.host_target + } + + /// Indicates whether the compiler was forced to use a specific stage. + pub(crate) fn is_forced_compiler(&self) -> bool { + self.forced_compiler + } +} diff --git a/src/bootstrap/src/core/mod.rs b/src/bootstrap/src/core/mod.rs index 4df2ed319da68..70962e16360bb 100644 --- a/src/bootstrap/src/core/mod.rs +++ b/src/bootstrap/src/core/mod.rs @@ -1,6 +1,7 @@ pub(crate) mod android; pub(crate) mod build_steps; pub(crate) mod builder; +pub(crate) mod compiler; pub(crate) mod config; pub(crate) mod debuggers; pub(crate) mod download; diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 61165cee13b40..e4d9388a6b959 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -37,6 +37,7 @@ use tracing::{instrument, span}; use crate::core::build_steps::format::InternalRustfmt; use crate::core::build_steps::vendor::VENDOR_DIR; use crate::core::builder::{Builder, Kind}; +use crate::core::compiler::Compiler; use crate::core::config::flags::{self, Subcommand}; use crate::core::config::{BootstrapOverrideLld, Config, DryRun, LlvmLibunwind, TargetSelection}; use crate::utils::build_stamp::BuildStamp; @@ -50,34 +51,6 @@ pub mod cli_main; mod core; mod utils; -/// A structure representing a Rust compiler. -/// -/// Each compiler has a `stage` that it is associated with and a `host` that -/// corresponds to the platform the compiler runs on. This structure is used as -/// a parameter to many methods below. -#[derive(Eq, PartialOrd, Ord, Clone, Copy, Debug)] -pub struct Compiler { - stage: u32, - host: TargetSelection, - /// Indicates whether the compiler was forced to use a specific stage. - /// This field is ignored in `Hash` and `PartialEq` implementations as only the `stage` - /// and `host` fields are relevant for those. - forced_compiler: bool, -} - -impl std::hash::Hash for Compiler { - fn hash(&self, state: &mut H) { - self.stage.hash(state); - self.host.hash(state); - } -} - -impl PartialEq for Compiler { - fn eq(&self, other: &Self) -> bool { - self.stage == other.stage && self.host == other.host - } -} - /// Represents a codegen backend. #[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] pub enum CodegenBackendKind { @@ -2003,26 +1976,6 @@ fn chmod(path: &Path, perms: u32) { #[cfg(windows)] fn chmod(_path: &Path, _perms: u32) {} -impl Compiler { - pub fn new(stage: u32, host: TargetSelection) -> Self { - Self { stage, host, forced_compiler: false } - } - - pub fn forced_compiler(&mut self, forced_compiler: bool) { - self.forced_compiler = forced_compiler; - } - - /// Returns `true` if this is a snapshot compiler for `build`'s configuration - pub fn is_snapshot(&self, build: &Build) -> bool { - self.stage == 0 && self.host == build.host_target - } - - /// Indicates whether the compiler was forced to use a specific stage. - pub fn is_forced_compiler(&self) -> bool { - self.forced_compiler - } -} - fn envify(s: &str) -> String { // Converting foo-bar to FOO_BAR is a fairly idomatic mapping to an environment variable name. // We also convert '.' to '_' to fix https://github.com/rust-lang/rust/issues/158090 diff --git a/src/bootstrap/src/utils/build_stamp.rs b/src/bootstrap/src/utils/build_stamp.rs index de7f4c7343c5e..3b122064d1639 100644 --- a/src/bootstrap/src/utils/build_stamp.rs +++ b/src/bootstrap/src/utils/build_stamp.rs @@ -8,9 +8,10 @@ use std::{fs, io}; use sha2::digest::Digest; use crate::core::builder::Builder; +use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; use crate::utils::helpers::{self, hex_encode, mtime, t}; -use crate::{CodegenBackendKind, Compiler, Mode}; +use crate::{CodegenBackendKind, Mode}; #[cfg(test)] mod tests; From 38c260e1f714571dcb7e1b8973069c6f7b36743e Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 14:53:17 +1000 Subject: [PATCH 43/49] Move `CodegenBackendKind` to its own module `crate::core::backend` --- src/bootstrap/src/core/backend.rs | 48 +++++++++++++++++ src/bootstrap/src/core/build_steps/check.rs | 3 +- src/bootstrap/src/core/build_steps/compile.rs | 3 +- src/bootstrap/src/core/build_steps/dist.rs | 3 +- src/bootstrap/src/core/build_steps/test.rs | 3 +- src/bootstrap/src/core/config/config.rs | 2 +- src/bootstrap/src/core/config/flags.rs | 3 +- src/bootstrap/src/core/config/toml/rust.rs | 3 +- src/bootstrap/src/core/config/toml/target.rs | 2 +- src/bootstrap/src/core/mod.rs | 1 + src/bootstrap/src/lib.rs | 54 ------------------- src/bootstrap/src/utils/build_stamp.rs | 3 +- 12 files changed, 65 insertions(+), 63 deletions(-) create mode 100644 src/bootstrap/src/core/backend.rs diff --git a/src/bootstrap/src/core/backend.rs b/src/bootstrap/src/core/backend.rs new file mode 100644 index 0000000000000..bc8c8eb650aef --- /dev/null +++ b/src/bootstrap/src/core/backend.rs @@ -0,0 +1,48 @@ +use std::str::FromStr; + +/// Represents a codegen backend. +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] +pub enum CodegenBackendKind { + #[default] + Llvm, + Cranelift, + Gcc, + Custom(String), +} + +impl CodegenBackendKind { + /// Name of the codegen backend, as identified in the `compiler` directory + /// (`rustc_codegen_`). + pub(crate) fn name(&self) -> &str { + match self { + CodegenBackendKind::Llvm => "llvm", + CodegenBackendKind::Cranelift => "cranelift", + CodegenBackendKind::Gcc => "gcc", + CodegenBackendKind::Custom(name) => name, + } + } + + /// Name of the codegen backend's crate, e.g. `rustc_codegen_cranelift`. + pub(crate) fn crate_name(&self) -> String { + format!("rustc_codegen_{}", self.name()) + } + + pub(crate) fn is_llvm(&self) -> bool { + matches!(self, Self::Llvm) + } +} + +/// FIXME(Zalathar): This is partly redundant with the parsing code in `parse_codegen_backends`. +impl FromStr for CodegenBackendKind { + type Err = &'static str; + + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "" => Err("Invalid empty backend name"), + "gcc" => Ok(Self::Gcc), + "llvm" => Ok(Self::Llvm), + "cranelift" => Ok(Self::Cranelift), + _ => Ok(Self::Custom(s.to_string())), + } + } +} diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index e72f1d05003b0..b8918ec12fd9f 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -3,6 +3,8 @@ use std::fs; use std::path::{Path, PathBuf}; +use crate::Mode; +use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::compile::{ ArtifactKeepMode, add_to_sysroot, run_cargo, rustc_cargo, rustc_cargo_env, std_cargo, std_crates_for_make_run, @@ -21,7 +23,6 @@ use crate::core::config::TargetSelection; use crate::core::config::flags::Subcommand; use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::helpers::t; -use crate::{CodegenBackendKind, Mode}; /// Allows individual check-step instances to keep track of whether they /// represent `cargo check` or `cargo fix`, independently of [`Builder::kind`]. diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 97c834cfaf666..51ef4e8684a80 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -19,6 +19,7 @@ use serde_derive::Deserialize; #[cfg(feature = "tracing")] use tracing::span; +use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::gcc::{Gcc, GccOutput, GccTargetPair}; use crate::core::build_steps::tool::{RustcPrivateCompilers, SourceType, copy_lld_artifacts}; use crate::core::build_steps::{dist, llvm}; @@ -37,7 +38,7 @@ use crate::utils::exec::command; use crate::utils::helpers::{ self, exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date, }; -use crate::{CLang, CodegenBackendKind, DependencyType, FileType, GitRepo, Mode, debug, trace}; +use crate::{CLang, DependencyType, FileType, GitRepo, Mode, debug, trace}; /// Build a standard library for the given `target` using the given `build_compiler`. #[derive(Debug, Clone, PartialEq, Eq, Hash)] diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index d45ddc4a4a257..b9abd8e5d33fe 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -19,6 +19,7 @@ use object::read::archive::ArchiveFile; #[cfg(feature = "tracing")] use tracing::instrument; +use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::compile::{ get_codegen_backend_file, libgccjit_path_relative_to_cg_dir, normalize_codegen_backend_name, }; @@ -41,7 +42,7 @@ use crate::utils::helpers::{ exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit, }; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; -use crate::{CodegenBackendKind, DependencyType, FileType, Mode, trace}; +use crate::{DependencyType, FileType, Mode, trace}; pub(crate) const LLVM_TOOLS: &[&str] = &[ "llvm-cov", // used to generate coverage report diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 7578a90d205c4..a69db6babaf8d 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -15,6 +15,7 @@ use std::{env, fs, iter}; use build_helper::git::get_closest_upstream_commit; +use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::compile::{ArtifactKeepMode, Std, run_cargo}; use crate::core::build_steps::doc::{DocumentationFormat, prepare_doc_compiler}; use crate::core::build_steps::format::InternalRustfmt; @@ -46,7 +47,7 @@ use crate::utils::helpers::{ up_to_date, }; use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; -use crate::{CLang, CodegenBackendKind, GitRepo, Mode, TestTarget, envify}; +use crate::{CLang, GitRepo, Mode, TestTarget, envify}; mod compiletest; pub mod failed_tests; diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index f4d8db99aaf69..f60c34bc7059b 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -28,7 +28,7 @@ use serde::Deserialize; #[cfg(feature = "tracing")] use tracing::{instrument, span}; -use crate::CodegenBackendKind; +use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::llvm; use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS; use crate::core::build_steps::test::failed_tests::collect_previously_failed_tests; diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index fa6225f6649e5..3bc5c9672b18c 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -10,13 +10,14 @@ use clap_complete::Generator; #[cfg(feature = "tracing")] use tracing::instrument; +use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::perf::PerfArgs; use crate::core::build_steps::setup::Profile; use crate::core::builder::{Builder, Kind}; use crate::core::config::Config; use crate::core::config::target_selection::{TargetSelectionList, target_selection_list}; use crate::utils::helpers; -use crate::{Build, CodegenBackendKind, TestTarget}; +use crate::{Build, TestTarget}; #[derive(Copy, Clone, Default, Debug, ValueEnum)] pub enum Color { diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index 86056d489911b..0c88a3d8d0172 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -7,7 +7,7 @@ use std::path::PathBuf; use build_helper::ci::CiEnv; use serde::{Deserialize, Deserializer}; -use crate::CodegenBackendKind; +use crate::core::backend::CodegenBackendKind; use crate::core::config::macros::define_config; use crate::core::config::toml::TomlConfig; use crate::core::config::{CompressDebuginfo, DebuginfoLevel, StringOrBool, TargetSelection}; @@ -430,6 +430,7 @@ pub fn check_incompatible_options_for_ci_rustc( pub(crate) const BUILTIN_CODEGEN_BACKENDS: &[&str] = &["llvm", "cranelift", "gcc"]; +/// FIXME(Zalathar): This is partly redundant with the parsing code in [`CodegenBackendKind`]. pub(crate) fn parse_codegen_backends( backends: Vec, section: &str, diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 32e0477f11853..090ccefe700ca 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -15,7 +15,7 @@ use std::path::PathBuf; use serde::de::Error; use serde::{Deserialize, Deserializer}; -use crate::CodegenBackendKind; +use crate::core::backend::CodegenBackendKind; use crate::core::config::macros::define_config; use crate::core::config::{ Allocator, CompilerBuiltins, CompressDebuginfo, LlvmLibunwind, SplitDebuginfo, StringOrBool, diff --git a/src/bootstrap/src/core/mod.rs b/src/bootstrap/src/core/mod.rs index 70962e16360bb..d6db6c701cc35 100644 --- a/src/bootstrap/src/core/mod.rs +++ b/src/bootstrap/src/core/mod.rs @@ -1,4 +1,5 @@ pub(crate) mod android; +pub(crate) mod backend; pub(crate) mod build_steps; pub(crate) mod builder; pub(crate) mod compiler; diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index e4d9388a6b959..6d810bed9b82b 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -51,60 +51,6 @@ pub mod cli_main; mod core; mod utils; -/// Represents a codegen backend. -#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] -pub enum CodegenBackendKind { - #[default] - Llvm, - Cranelift, - Gcc, - Custom(String), -} - -impl CodegenBackendKind { - /// Name of the codegen backend, as identified in the `compiler` directory - /// (`rustc_codegen_`). - pub fn name(&self) -> &str { - match self { - CodegenBackendKind::Llvm => "llvm", - CodegenBackendKind::Cranelift => "cranelift", - CodegenBackendKind::Gcc => "gcc", - CodegenBackendKind::Custom(name) => name, - } - } - - /// Name of the codegen backend's crate, e.g. `rustc_codegen_cranelift`. - pub fn crate_name(&self) -> String { - format!("rustc_codegen_{}", self.name()) - } - - pub fn is_llvm(&self) -> bool { - matches!(self, Self::Llvm) - } - - pub fn is_cranelift(&self) -> bool { - matches!(self, Self::Cranelift) - } - - pub fn is_gcc(&self) -> bool { - matches!(self, Self::Gcc) - } -} - -impl std::str::FromStr for CodegenBackendKind { - type Err = &'static str; - - fn from_str(s: &str) -> Result { - match s.to_lowercase().as_str() { - "" => Err("Invalid empty backend name"), - "gcc" => Ok(Self::Gcc), - "llvm" => Ok(Self::Llvm), - "cranelift" => Ok(Self::Cranelift), - _ => Ok(Self::Custom(s.to_string())), - } - } -} - #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum TestTarget { /// Run unit, integration and doc tests (default). diff --git a/src/bootstrap/src/utils/build_stamp.rs b/src/bootstrap/src/utils/build_stamp.rs index 3b122064d1639..d27d5fa2cf420 100644 --- a/src/bootstrap/src/utils/build_stamp.rs +++ b/src/bootstrap/src/utils/build_stamp.rs @@ -7,11 +7,12 @@ use std::{fs, io}; use sha2::digest::Digest; +use crate::Mode; +use crate::core::backend::CodegenBackendKind; use crate::core::builder::Builder; use crate::core::compiler::Compiler; use crate::core::config::TargetSelection; use crate::utils::helpers::{self, hex_encode, mtime, t}; -use crate::{CodegenBackendKind, Mode}; #[cfg(test)] mod tests; From 9ff48b214786950be57338f41d6e8711830479fc Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 15:06:04 +1000 Subject: [PATCH 44/49] Move `TestTarget` into `build_steps::test` --- src/bootstrap/src/core/build_steps/test.rs | 20 +++++++++++++++++++- src/bootstrap/src/core/config/flags.rs | 3 ++- src/bootstrap/src/lib.rs | 19 +------------------ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index a69db6babaf8d..fb7b85ee0bb85 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -47,11 +47,29 @@ use crate::utils::helpers::{ up_to_date, }; use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; -use crate::{CLang, GitRepo, Mode, TestTarget, envify}; +use crate::{CLang, GitRepo, Mode, envify}; mod compiletest; pub mod failed_tests; +#[derive(PartialEq, Eq, Copy, Clone, Debug)] +pub enum TestTarget { + /// Run unit, integration and doc tests (default). + Default, + /// Run unit, integration, doc tests, examples, bins, benchmarks (no doc tests). + AllTargets, + /// Only run doc tests. + DocOnly, + /// Only run unit and integration tests. + Tests, +} + +impl TestTarget { + pub(crate) fn runs_doctests(&self) -> bool { + matches!(self, TestTarget::DocOnly | TestTarget::Default) + } +} + /// Runs `cargo test` on various internal tools used by bootstrap. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateBootstrap { diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index 3bc5c9672b18c..c8dbf8d4c4edf 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -10,14 +10,15 @@ use clap_complete::Generator; #[cfg(feature = "tracing")] use tracing::instrument; +use crate::Build; use crate::core::backend::CodegenBackendKind; use crate::core::build_steps::perf::PerfArgs; use crate::core::build_steps::setup::Profile; +use crate::core::build_steps::test::TestTarget; use crate::core::builder::{Builder, Kind}; use crate::core::config::Config; use crate::core::config::target_selection::{TargetSelectionList, target_selection_list}; use crate::utils::helpers; -use crate::{Build, TestTarget}; #[derive(Copy, Clone, Default, Debug, ValueEnum)] pub enum Color { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 6d810bed9b82b..0bdfc3d22bb3f 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -35,6 +35,7 @@ use termcolor::{ColorChoice, StandardStream, WriteColor}; use tracing::{instrument, span}; use crate::core::build_steps::format::InternalRustfmt; +use crate::core::build_steps::test::TestTarget; use crate::core::build_steps::vendor::VENDOR_DIR; use crate::core::builder::{Builder, Kind}; use crate::core::compiler::Compiler; @@ -51,24 +52,6 @@ pub mod cli_main; mod core; mod utils; -#[derive(PartialEq, Eq, Copy, Clone, Debug)] -pub enum TestTarget { - /// Run unit, integration and doc tests (default). - Default, - /// Run unit, integration, doc tests, examples, bins, benchmarks (no doc tests). - AllTargets, - /// Only run doc tests. - DocOnly, - /// Only run unit and integration tests. - Tests, -} - -impl TestTarget { - fn runs_doctests(&self) -> bool { - matches!(self, TestTarget::DocOnly | TestTarget::Default) - } -} - pub enum GitRepo { Rustc, Llvm, From 57033a003353cb45347e1c01d3f7c7a1800c5fb4 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 17:35:33 +1000 Subject: [PATCH 45/49] Move `Crate` into `crate::core::metadata` --- src/bootstrap/src/core/builder/mod.rs | 3 ++- src/bootstrap/src/core/metadata.rs | 19 +++++++++++++++++-- src/bootstrap/src/lib.rs | 15 +-------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 0c57bbff1749a..be50f1dd2ac9d 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -24,12 +24,13 @@ pub use crate::core::builder::step_stack::StepStack; use crate::core::compiler::Compiler; use crate::core::config::flags::Subcommand; use crate::core::config::{DryRun, TargetSelection}; +use crate::core::metadata::Crate; use crate::utils::build_stamp::BuildStamp; use crate::utils::cache::Cache; use crate::utils::exec::{BootstrapCommand, ExecutionContext, command}; use crate::utils::helpers::{self, LldThreads, add_dylib_path, exe, libdir, linker_args, t}; use crate::utils::tracing::format_location; -use crate::{Build, Crate, trace}; +use crate::{Build, trace}; mod cargo; mod cli_paths; diff --git a/src/bootstrap/src/core/metadata.rs b/src/bootstrap/src/core/metadata.rs index 14f33ef9bdc5d..a3b52e1071d24 100644 --- a/src/bootstrap/src/core/metadata.rs +++ b/src/bootstrap/src/core/metadata.rs @@ -5,14 +5,29 @@ //! source, dependencies, targets, and available features. The collected metadata is then //! used to update the `Build` structure, ensuring proper dependency resolution and //! compilation flow. -use std::collections::BTreeMap; + +use std::collections::{BTreeMap, HashSet}; use std::path::PathBuf; use serde_derive::Deserialize; +use crate::Build; use crate::utils::exec::command; use crate::utils::helpers::t; -use crate::{Build, Crate}; + +#[derive(Debug, Clone)] +pub(crate) struct Crate { + pub(crate) name: String, + pub(crate) deps: HashSet, + pub(crate) path: PathBuf, + pub(crate) features: Vec, +} + +impl Crate { + pub(crate) fn local_path(&self, build: &Build) -> PathBuf { + self.path.strip_prefix(&build.config.src).unwrap().into() + } +} /// For more information, see the output of /// diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 0bdfc3d22bb3f..081197bc92f6b 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -41,6 +41,7 @@ use crate::core::builder::{Builder, Kind}; use crate::core::compiler::Compiler; use crate::core::config::flags::{self, Subcommand}; use crate::core::config::{BootstrapOverrideLld, Config, DryRun, LlvmLibunwind, TargetSelection}; +use crate::core::metadata::Crate; use crate::utils::build_stamp::BuildStamp; use crate::utils::channel::GitInfo; use crate::utils::exec::{BootstrapCommand, ExecutionContext, command}; @@ -127,20 +128,6 @@ pub struct Build { step_graph: std::cell::RefCell, } -#[derive(Debug, Clone)] -struct Crate { - name: String, - deps: HashSet, - path: PathBuf, - features: Vec, -} - -impl Crate { - fn local_path(&self, build: &Build) -> PathBuf { - self.path.strip_prefix(&build.config.src).unwrap().into() - } -} - /// When building Rust various objects are handled differently. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub enum DependencyType { From af768f68258ddb95da012fbd6d0fdda5e1e27ef5 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 13:43:53 +1000 Subject: [PATCH 46/49] Move `envify` into `crate::utils::helpers` and add a test --- src/bootstrap/src/core/build_steps/test.rs | 6 +++--- src/bootstrap/src/core/builder/cargo.rs | 6 +++--- src/bootstrap/src/lib.rs | 12 ------------ src/bootstrap/src/utils/helpers.rs | 19 +++++++++++++++++++ src/bootstrap/src/utils/helpers/tests.rs | 22 ++++++++++++++++++++-- 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index fb7b85ee0bb85..d816cb1989f9a 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -43,11 +43,11 @@ use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{ self, LldThreads, TestFilterCategory, add_dylib_path, add_rustdoc_cargo_linker_args, - dylib_path, dylib_path_var, linker_args, linker_flags, t, target_supports_cranelift_backend, - up_to_date, + dylib_path, dylib_path_var, envify, linker_args, linker_flags, t, + target_supports_cranelift_backend, up_to_date, }; use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; -use crate::{CLang, GitRepo, Mode, envify}; +use crate::{CLang, GitRepo, Mode}; mod compiletest; pub mod failed_tests; diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index d157610add218..f56fe4695d111 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -11,8 +11,8 @@ use crate::core::config::toml::pgo::PgoConfig; use crate::core::config::{CompressDebuginfo, Config, DryRun, SplitDebuginfo, TargetSelection}; use crate::utils::build_stamp; use crate::utils::exec::{BootstrapCommand, command}; -use crate::utils::helpers::{self, LldThreads, check_cfg_arg, linker_flags, t}; -use crate::{CLang, GitRepo, Mode, RemapScheme, envify, prepare_behaviour_dump_dir}; +use crate::utils::helpers::{self, LldThreads, check_cfg_arg, envify, linker_flags, t}; +use crate::{CLang, GitRepo, Mode, RemapScheme, prepare_behaviour_dump_dir}; /// Extra `--check-cfg` to add when building the compiler or tools /// (Mode restriction, config name, config values (if any)) @@ -56,7 +56,7 @@ impl Rustflags { self.env(prefix); // ... and also handle target-specific env RUSTFLAGS if they're configured. - let target_specific = format!("CARGO_TARGET_{}_{}", crate::envify(&self.1.triple), prefix); + let target_specific = format!("CARGO_TARGET_{}_{}", envify(&self.1.triple), prefix); self.env(&target_specific); } diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 081197bc92f6b..1f7cc994be938 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1892,18 +1892,6 @@ fn chmod(path: &Path, perms: u32) { #[cfg(windows)] fn chmod(_path: &Path, _perms: u32) {} -fn envify(s: &str) -> String { - // Converting foo-bar to FOO_BAR is a fairly idomatic mapping to an environment variable name. - // We also convert '.' to '_' to fix https://github.com/rust-lang/rust/issues/158090 - s.chars() - .map(|c| match c { - '-' | '.' => '_', - c => c, - }) - .flat_map(|c| c.to_uppercase()) - .collect() -} - /// Ensures that the behavior dump directory is properly initialized. pub fn prepare_behaviour_dump_dir(build: &Build) { static INITIALIZED: OnceLock = OnceLock::new(); diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 021763fdb371a..8e881f1bf7734 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -571,6 +571,25 @@ pub fn set_file_times>(path: P, times: fs::FileTimes) -> io::Resu f.set_times(times) } +/// Converts a target-tuple or other string into +/// [the form expected by cargo environment variable names][cargo-env]. +/// +/// For example: +/// - `x86_64-unknown-linux-gnu` => `X86_64_UNKNOWN_LINUX_GNU`. +/// +/// [cargo-env]: https://doc.rust-lang.org/cargo/reference/config.html#environment-variables +pub(crate) fn envify(s: &str) -> String { + // Converting foo-bar to FOO_BAR is a fairly idomatic mapping to an environment variable name. + // We also convert '.' to '_' to fix https://github.com/rust-lang/rust/issues/158090 + s.chars() + .map(|c| match c { + '-' | '.' => '_', + c => c, + }) + .flat_map(|c| c.to_uppercase()) + .collect() +} + /// Exits the process by calling [`std::process::exit`]. /// /// In CI, extra information will be printed to make failures easier to investigate. diff --git a/src/bootstrap/src/utils/helpers/tests.rs b/src/bootstrap/src/utils/helpers/tests.rs index cfb1dde2d6ea3..53d56169eb03e 100644 --- a/src/bootstrap/src/utils/helpers/tests.rs +++ b/src/bootstrap/src/utils/helpers/tests.rs @@ -3,8 +3,8 @@ use std::io::Write; use std::path::PathBuf; use crate::utils::helpers::{ - check_cfg_arg, extract_beta_rev, hex_encode, make, set_file_times, submodule_path_of_paths, - symlink_dir, + check_cfg_arg, envify, extract_beta_rev, hex_encode, make, set_file_times, + submodule_path_of_paths, symlink_dir, }; use crate::utils::tests::TestCtx; @@ -119,3 +119,21 @@ fn test_submodule_path_of() { // Make sure paths that only share a string prefix with a submodule are not matched. assert_eq!(submodule_path_of_paths(&submodules, "src/tools/cargo-vendor"), None); } + +#[test] +fn test_envify() { + struct Case { + input: &'static str, + expected: &'static str, + } + let cases = &[ + Case { input: "x86_64-unknown-linux-gnu", expected: "X86_64_UNKNOWN_LINUX_GNU" }, + // Arbitrary target containing `.` from the tier-3 target list. + Case { input: "thumbv8m.base-none-eabi", expected: "THUMBV8M_BASE_NONE_EABI" }, + ]; + + for &Case { input, expected } in cases { + let actual = envify(input); + assert_eq!(actual, expected, "input = {input:?}"); + } +} From d5a84642a4009b1617a4d28c4d899838315d8fc6 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 16 Aug 2026 16:38:05 +1000 Subject: [PATCH 47/49] Move/rename/adjust `prepare_behaviour_dump_dir` The destination is `crate::core::builder::cargo`, the new name is `prepare_shims_dump_dir`, and the adjustment is to take `&Builder<'_>` instead of `&Build`. --- src/bootstrap/src/core/builder/cargo.rs | 26 ++++++++++++++++++++++--- src/bootstrap/src/lib.rs | 19 ------------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index f56fe4695d111..a70d36d7aafe9 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1,6 +1,7 @@ -use std::env; use std::ffi::{OsStr, OsString}; use std::path::{Path, PathBuf}; +use std::sync::OnceLock; +use std::{env, fs}; use super::{Builder, Kind}; use crate::core::build_steps::test; @@ -12,7 +13,7 @@ use crate::core::config::{CompressDebuginfo, Config, DryRun, SplitDebuginfo, Tar use crate::utils::build_stamp; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{self, LldThreads, check_cfg_arg, envify, linker_flags, t}; -use crate::{CLang, GitRepo, Mode, RemapScheme, prepare_behaviour_dump_dir}; +use crate::{CLang, GitRepo, Mode, RemapScheme}; /// Extra `--check-cfg` to add when building the compiler or tools /// (Mode restriction, config name, config values (if any)) @@ -1220,7 +1221,7 @@ impl Builder<'_> { } if self.config.dump_bootstrap_shims { - prepare_behaviour_dump_dir(self.build); + prepare_shims_dump_dir(self); cargo .env("DUMP_BOOTSTRAP_SHIMS", self.build.out.join("bootstrap-shims-dump")) @@ -1588,3 +1589,22 @@ pub fn apply_pgo( )); } } + +/// Ensures that the behavior dump directory is properly initialized. +fn prepare_shims_dump_dir(builder: &Builder<'_>) { + static INITIALIZED: OnceLock = OnceLock::new(); + + let dump_path = builder.out.join("bootstrap-shims-dump"); + + let initialized = INITIALIZED.get().unwrap_or(&false); + if !initialized { + // clear old dumps + if dump_path.exists() { + t!(fs::remove_dir_all(&dump_path)); + } + + t!(fs::create_dir_all(&dump_path)); + + t!(INITIALIZED.set(true)); + } +} diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 1f7cc994be938..2fc9dc0115872 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -1891,22 +1891,3 @@ fn chmod(path: &Path, perms: u32) { } #[cfg(windows)] fn chmod(_path: &Path, _perms: u32) {} - -/// Ensures that the behavior dump directory is properly initialized. -pub fn prepare_behaviour_dump_dir(build: &Build) { - static INITIALIZED: OnceLock = OnceLock::new(); - - let dump_path = build.out.join("bootstrap-shims-dump"); - - let initialized = INITIALIZED.get().unwrap_or(&false); - if !initialized { - // clear old dumps - if dump_path.exists() { - t!(fs::remove_dir_all(&dump_path)); - } - - t!(fs::create_dir_all(&dump_path)); - - t!(INITIALIZED.set(true)); - } -} From d7bd2df6bbd84aca8ffe53cd2e06cef892b64ca8 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 16 Aug 2026 12:20:03 +0200 Subject: [PATCH 48/49] Add code comment explaining why we need this binutils version --- src/ci/docker/scripts/build-gcc.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ci/docker/scripts/build-gcc.sh b/src/ci/docker/scripts/build-gcc.sh index 29502ec56a767..c1c94a89d17e7 100755 --- a/src/ci/docker/scripts/build-gcc.sh +++ b/src/ci/docker/scripts/build-gcc.sh @@ -4,6 +4,8 @@ set -eux source shared.sh +# We have to build our own binutils for the GCC build, because the default CentOS 7 binutils are +# too old, and they do not support `SHF_GNU_RETAIN`. BINUTILS="2.47" curl https://ci-mirrors.rust-lang.org/rustc/gcc/binutils-$BINUTILS.tar.xz | xzcat | tar xf - mkdir binutils-build From b2e0185a3a4818955e2f996ea867318c78e60fee Mon Sep 17 00:00:00 2001 From: xonx <119700621+xonx4l@users.noreply.github.com> Date: Sun, 16 Aug 2026 11:59:05 +0000 Subject: [PATCH 49/49] add comment --- src/bootstrap/src/core/build_steps/test.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 3b5d801a31c61..178d6c29508d6 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -1200,6 +1200,9 @@ impl CommandLineStep for IntrinsicTest { } } +/// Runs stdarch's gen-checks (arm, loongarch, hexagon) to +/// verify the committed `core_arch` files are up to date with their specs. +/// With `--bless`, regenerates and writes them back instead. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct StdarchGenCheck { host: TargetSelection,