Use the in-tree compiler-builtins

Many of `std`'s dependency have a dependency on the crates.io
`compiler-builtins` when used with the feature
`rustc-std-workspace-core`. Use a Cargo patch to select the in-tree
version instead.

`compiler-builtins` is also added as a dependency of
`rustc-std-workspace-core` so these crates can remove their crates.io
dependency in the future.
This commit is contained in:
Trevor Gross 2025-06-04 20:56:35 +00:00
parent 076ec59ff1
commit cc3e57147e
15 changed files with 62 additions and 19 deletions

View file

@ -3118,11 +3118,12 @@ dependencies = [
[[package]]
name = "rustc-build-sysroot"
version = "0.5.7"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10edc2e4393515193bd766e2f6c050b0536a68e56f2b6d56c07ababfdc114ff0"
checksum = "16d115ad7e26e0d1337f64ae6598f758194696afc2e9f34c8a6f24582529c3dc"
dependencies = [
"anyhow",
"regex",
"rustc_version",
"tempfile",
"walkdir",

View file

@ -6,7 +6,6 @@ resolver = "2"
[dependencies]
core = { path = "./sysroot_src/library/core" }
compiler_builtins = "0.1"
alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
@ -16,6 +15,7 @@ proc_macro = { path = "./sysroot_src/library/proc_macro" }
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
compiler_builtins = { path = "./sysroot_src/library/compiler-builtins/compiler-builtins" }
# For compiler-builtins we always use a high number of codegen units.
# The goal here is to place every single intrinsic into its own object

View file

@ -62,11 +62,9 @@ dependencies = [
[[package]]
name = "compiler_builtins"
version = "0.1.160"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6376049cfa92c0aa8b9ac95fae22184b981c658208d4ed8a1dc553cd83612895"
dependencies = [
"cc",
"rustc-std-workspace-core",
"core",
]
[[package]]
@ -304,6 +302,7 @@ dependencies = [
name = "rustc-std-workspace-core"
version = "1.99.0"
dependencies = [
"compiler_builtins",
"core",
]

View file

@ -50,3 +50,4 @@ rustc-demangle.opt-level = "s"
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
compiler_builtins = { path = "compiler-builtins/compiler-builtins" }

View file

@ -16,7 +16,7 @@ bench = false
[dependencies]
core = { path = "../core", public = true }
compiler_builtins = { version = "=0.1.160", features = ['rustc-dep-of-std'] }
compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["rustc-dep-of-std"] }
[features]
compiler-builtins-mem = ['compiler_builtins/mem']

View file

@ -17,9 +17,7 @@ doctest = false
test = false
[dependencies]
# For more information on this dependency see
# https://github.com/rust-lang/rust/tree/master/library/rustc-std-workspace-core
core = { version = "1.0.1", optional = true, package = "rustc-std-workspace-core" }
core = { path = "../../core", optional = true }
[build-dependencies]
cc = { optional = true, version = "1.2" }

View file

@ -13,7 +13,7 @@ doc = false
[dependencies]
core = { path = "../core" }
compiler_builtins = "0.1.0"
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
[target.'cfg(target_os = "android")'.dependencies]
libc = { version = "0.2", default-features = false }

View file

@ -15,7 +15,7 @@ doc = false
alloc = { path = "../alloc" }
core = { path = "../core" }
unwind = { path = "../unwind" }
compiler_builtins = "0.1.0"
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]

View file

@ -12,3 +12,4 @@ path = "lib.rs"
[dependencies]
core = { path = "../core" }
compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["compiler-builtins"] }

View file

@ -2,3 +2,7 @@
#![no_core]
pub use core::*;
// Crate must be brought into scope so it appears in the crate graph for anything that
// depends on `rustc-std-workspace-core`.
use compiler_builtins as _;

View file

@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
panic_unwind = { path = "../panic_unwind", optional = true }
panic_abort = { path = "../panic_abort" }
core = { path = "../core", public = true }
compiler_builtins = { version = "=0.1.160" }
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
unwind = { path = "../unwind" }
hashbrown = { version = "0.15", default-features = false, features = [
'rustc-dep-of-std',

View file

@ -15,7 +15,7 @@ doc = false
[dependencies]
core = { path = "../core" }
compiler_builtins = "0.1.0"
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
cfg-if = "1.0"
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]

View file

@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.97"
@ -207,12 +216,42 @@ dependencies = [
]
[[package]]
name = "rustc-build-sysroot"
version = "0.5.7"
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10edc2e4393515193bd766e2f6c050b0536a68e56f2b6d56c07ababfdc114ff0"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "rustc-build-sysroot"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16d115ad7e26e0d1337f64ae6598f758194696afc2e9f34c8a6f24582529c3dc"
dependencies = [
"anyhow",
"regex",
"rustc_version",
"tempfile",
"walkdir",

View file

@ -18,7 +18,7 @@ directories = "6"
rustc_version = "0.4"
serde_json = "1.0.40"
cargo_metadata = "0.19"
rustc-build-sysroot = "0.5.7"
rustc-build-sysroot = "0.5.8"
# Enable some feature flags that dev-dependencies need but dependencies
# do not. This makes `./miri install` after `./miri build` faster.

View file

@ -1,6 +1,6 @@
error: linking with `./fake-linker` failed: exit status: 1
|
= note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error"
= note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note: error: baz