Skip to content

Commit b34f911

Browse files
authored
Unrolled build for #144683
Rollup merge of #144683 - tgross35:builtins-via-std-workspace, r=bjorn3,Noratrieb Simplify library dependencies on `compiler-builtins` The three panic-related library crates need to have access to `core`, and `compiler-builtins` needs to be in the crate graph. Rather than specifying both dependencies, switch these crates to use `rustc-std-workspace-core` which already does this. This means there is now a single place that the `compiler-builtins` dependency needs to get configured, for everything other than `alloc` and `std`. The second commit removes `compiler-builtins` from `std` (more details in the message).
2 parents 6c02dd4 + 42bf044 commit b34f911

File tree

8 files changed

+35
-37
lines changed

8 files changed

+35
-37
lines changed

library/Cargo.lock

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ name = "panic_abort"
183183
version = "0.0.0"
184184
dependencies = [
185185
"alloc",
186-
"compiler_builtins",
187-
"core",
188186
"libc",
187+
"rustc-std-workspace-core",
189188
]
190189

191190
[[package]]
@@ -194,9 +193,8 @@ version = "0.0.0"
194193
dependencies = [
195194
"alloc",
196195
"cfg-if",
197-
"compiler_builtins",
198-
"core",
199196
"libc",
197+
"rustc-std-workspace-core",
200198
"unwind",
201199
]
202200

@@ -313,7 +311,6 @@ dependencies = [
313311
"addr2line",
314312
"alloc",
315313
"cfg-if",
316-
"compiler_builtins",
317314
"core",
318315
"dlmalloc",
319316
"fortanix-sgx-abi",
@@ -380,9 +377,8 @@ name = "unwind"
380377
version = "0.0.0"
381378
dependencies = [
382379
"cfg-if",
383-
"compiler_builtins",
384-
"core",
385380
"libc",
381+
"rustc-std-workspace-core",
386382
"unwinding",
387383
]
388384

library/panic_abort/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ bench = false
1212
doc = false
1313

1414
[dependencies]
15-
core = { path = "../core" }
16-
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
15+
core = { path = "../rustc-std-workspace-core", package = "rustc-std-workspace-core" }
1716

1817
[target.'cfg(target_os = "android")'.dependencies]
1918
libc = { version = "0.2", default-features = false }

library/panic_unwind/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ doc = false
1313

1414
[dependencies]
1515
alloc = { path = "../alloc" }
16-
core = { path = "../core" }
17-
unwind = { path = "../unwind" }
18-
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
1916
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
17+
core = { path = "../rustc-std-workspace-core", package = "rustc-std-workspace-core" }
18+
unwind = { path = "../unwind" }
2019

2120
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
2221
libc = { version = "0.2", default-features = false }

library/rustc-std-workspace-core/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ on crates.io will draw a dependency edge to `libcore`, the version defined in
1111
this repository. That should draw all the dependency edges to ensure Cargo
1212
builds crates successfully!
1313

14+
`rustc-std-workspace-core` also ensures `compiler-builtins` is in the crate
15+
graph. This crate is used by other crates in `library/`, other than `std` and
16+
`alloc`, so the `compiler-builtins` setup only needs to be configured in a
17+
single place. (Otherwise these crates would just need to depend on `core` and
18+
`compiler-builtins` separately.)
19+
1420
Note that crates on crates.io need to depend on this crate with the name `core`
1521
for everything to work correctly. To do that they can use:
1622

library/std/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1818
panic_unwind = { path = "../panic_unwind", optional = true }
1919
panic_abort = { path = "../panic_abort" }
2020
core = { path = "../core", public = true }
21-
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
2221
unwind = { path = "../unwind" }
2322
hashbrown = { version = "0.15", default-features = false, features = [
2423
'rustc-dep-of-std',

library/std/src/sys/pal/uefi/helpers.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -444,17 +444,17 @@ impl<'a> DevicePathNode<'a> {
444444

445445
impl<'a> PartialEq for DevicePathNode<'a> {
446446
fn eq(&self, other: &Self) -> bool {
447-
let self_len = self.length();
448-
let other_len = other.length();
449-
450-
self_len == other_len
451-
&& unsafe {
452-
compiler_builtins::mem::memcmp(
453-
self.protocol.as_ptr().cast(),
454-
other.protocol.as_ptr().cast(),
455-
usize::from(self_len),
456-
) == 0
457-
}
447+
// Compare as a single buffer rather than by field since it optimizes better.
448+
//
449+
// SAFETY: `Protocol` is followed by a buffer of `length - sizeof::<Protocol>()`. `Protocol`
450+
// has no padding so it is sound to interpret as a slice.
451+
unsafe {
452+
let s1 =
453+
slice::from_raw_parts(self.protocol.as_ptr().cast::<u8>(), self.length().into());
454+
let s2 =
455+
slice::from_raw_parts(other.protocol.as_ptr().cast::<u8>(), other.length().into());
456+
s1 == s2
457+
}
458458
}
459459
}
460460

library/unwind/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ bench = false
1414
doc = false
1515

1616
[dependencies]
17-
core = { path = "../core" }
18-
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
1917
cfg-if = "1.0"
18+
core = { path = "../rustc-std-workspace-core", package = "rustc-std-workspace-core" }
2019

2120
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
2221
libc = { version = "0.2.140", features = ['rustc-dep-of-std'], default-features = false }

src/bootstrap/src/core/builder/tests.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -999,7 +999,7 @@ mod snapshot {
999999
[build] llvm <host>
10001000
[build] rustc 0 <host> -> rustc 1 <host>
10011001
[build] rustdoc 0 <host>
1002-
[doc] std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1002+
[doc] std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
10031003
");
10041004
}
10051005

@@ -1048,7 +1048,7 @@ mod snapshot {
10481048
[build] rustc 1 <host> -> std 1 <host>
10491049
[build] rustc 1 <host> -> rustc 2 <host>
10501050
[build] rustdoc 1 <host>
1051-
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1051+
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
10521052
[build] rustc 2 <host> -> std 2 <host>
10531053
[build] rustc 0 <host> -> LintDocs 1 <host>
10541054
[build] rustc 0 <host> -> RustInstaller 1 <host>
@@ -1090,7 +1090,7 @@ mod snapshot {
10901090
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
10911091
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <host>
10921092
[build] rustdoc 1 <host>
1093-
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1093+
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
10941094
[build] rustc 2 <host> -> std 2 <host>
10951095
[build] rustc 0 <host> -> LintDocs 1 <host>
10961096
[build] rustc 0 <host> -> RustInstaller 1 <host>
@@ -1126,8 +1126,8 @@ mod snapshot {
11261126
[build] rustc 1 <host> -> std 1 <host>
11271127
[build] rustc 1 <host> -> rustc 2 <host>
11281128
[build] rustdoc 1 <host>
1129-
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1130-
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1129+
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
1130+
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
11311131
[build] rustc 2 <host> -> std 2 <host>
11321132
[build] rustc 0 <host> -> LintDocs 1 <host>
11331133
[build] rustc 0 <host> -> RustInstaller 1 <host>
@@ -1163,7 +1163,7 @@ mod snapshot {
11631163
[build] rustc 1 <host> -> std 1 <host>
11641164
[build] rustc 1 <host> -> rustc 2 <host>
11651165
[build] rustdoc 1 <host>
1166-
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1166+
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
11671167
[build] rustc 2 <host> -> std 2 <host>
11681168
[build] rustc 0 <host> -> LintDocs 1 <host>
11691169
[build] rustc 1 <host> -> std 1 <target1>
@@ -1200,8 +1200,8 @@ mod snapshot {
12001200
[build] rustc 1 <host> -> std 1 <host>
12011201
[build] rustc 1 <host> -> rustc 2 <host>
12021202
[build] rustdoc 1 <host>
1203-
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1204-
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1203+
[doc] std 2 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
1204+
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
12051205
[build] rustc 2 <host> -> std 2 <host>
12061206
[build] rustc 0 <host> -> LintDocs 1 <host>
12071207
[build] rustc 1 <host> -> std 1 <target1>
@@ -1242,7 +1242,7 @@ mod snapshot {
12421242
[build] rustc 1 <host> -> std 1 <host>
12431243
[build] rustc 1 <host> -> rustc 2 <host>
12441244
[build] rustdoc 1 <host>
1245-
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1245+
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
12461246
[build] rustc 2 <host> -> std 2 <host>
12471247
[build] rustc 0 <host> -> RustInstaller 1 <host>
12481248
[dist] docs <target1>
@@ -1274,7 +1274,7 @@ mod snapshot {
12741274
[build] rustc 1 <host> -> rustc 2 <host>
12751275
[build] rustc 1 <host> -> WasmComponentLd 2 <host>
12761276
[build] rustdoc 1 <host>
1277-
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1277+
[doc] std 2 <target1> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
12781278
[build] rustc 2 <host> -> std 2 <host>
12791279
[build] rustc 1 <host> -> std 1 <target1>
12801280
[build] rustc 2 <host> -> std 2 <target1>
@@ -1620,7 +1620,7 @@ mod snapshot {
16201620
[build] llvm <host>
16211621
[build] rustc 0 <host> -> rustc 1 <host>
16221622
[build] rustdoc 0 <host>
1623-
[doc] std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,std,std_detect,sysroot,test,unwind]
1623+
[doc] std 1 <host> crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]
16241624
");
16251625
}
16261626

0 commit comments

Comments
 (0)