Skip to content

Commit e84c485

Browse files
Auto merge of #141993 - tgross35:use-in-tree-builtins, r=<try>
WIP: Use the in-tree compiler-builtins for the sysroot 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. Zulip discussion: [#t-compiler > Using in-tree compiler-builtins](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20in-tree.20compiler-builtins/with/522445336) try-job: x86_64-gnu try-job: x86_64-gnu-aux try-job: test-various
2 parents 4b27a04 + 145c702 commit e84c485

File tree

15 files changed

+42
-20
lines changed

15 files changed

+42
-20
lines changed

compiler/rustc_codegen_gcc/build_system/build_sysroot/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ resolver = "2"
66

77
[dependencies]
88
core = { path = "./sysroot_src/library/core" }
9-
compiler_builtins = "0.1"
109
alloc = { path = "./sysroot_src/library/alloc" }
1110
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
1211
test = { path = "./sysroot_src/library/test" }
@@ -16,6 +15,7 @@ proc_macro = { path = "./sysroot_src/library/proc_macro" }
1615
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
1716
rustc-std-workspace-alloc = { path = "./sysroot_src/library/rustc-std-workspace-alloc" }
1817
rustc-std-workspace-std = { path = "./sysroot_src/library/rustc-std-workspace-std" }
18+
compiler_builtins = { path = "./sysroot_src/library/compiler-builtins/compiler-builtins" }
1919

2020
# For compiler-builtins we always use a high number of codegen units.
2121
# The goal here is to place every single intrinsic into its own object

library/Cargo.lock

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ dependencies = [
6262
[[package]]
6363
name = "compiler_builtins"
6464
version = "0.1.160"
65-
source = "registry+https://github.com/rust-lang/crates.io-index"
66-
checksum = "6376049cfa92c0aa8b9ac95fae22184b981c658208d4ed8a1dc553cd83612895"
6765
dependencies = [
6866
"cc",
69-
"rustc-std-workspace-core",
67+
"core",
7068
]
7169

7270
[[package]]
@@ -304,6 +302,7 @@ dependencies = [
304302
name = "rustc-std-workspace-core"
305303
version = "1.99.0"
306304
dependencies = [
305+
"compiler_builtins",
307306
"core",
308307
]
309308

library/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ rustc-demangle.opt-level = "s"
5050
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
5151
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
5252
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
53+
compiler_builtins = { path = "compiler-builtins/compiler-builtins" }

library/alloc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ bench = false
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
compiler_builtins = { version = "=0.1.160", features = ['rustc-dep-of-std'] }
19+
compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["rustc-dep-of-std"] }
2020

2121
[features]
2222
compiler-builtins-mem = ['compiler_builtins/mem']

library/compiler-builtins/builtins-test-intrinsics/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ publish = false
66
license = "MIT OR Apache-2.0"
77

88
[dependencies]
9-
compiler_builtins = { path = "../compiler-builtins", features = ["compiler-builtins"]}
9+
compiler_builtins = { path = "../compiler-builtins", features = ["compiler-builtins"] }
1010
panic-handler = { path = "../crates/panic-handler" }
1111

1212
[features]

library/compiler-builtins/compiler-builtins/CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.160](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.159...compiler_builtins-v0.1.160) - 2025-05-29
11+
12+
### Other
13+
14+
- Change `compiler-builtins` to edition 2024
15+
- Remove unneeded C symbols
16+
- Reuse `libm`'s `Caat` and `CastFrom` in `compiler-builtins`
17+
- Reuse `MinInt` and `Int` from `libm` in `compiler-builtins`
18+
- Update `CmpResult` to use a pointer-sized return type
19+
- Enable `__powitf2` on MSVC
20+
- Fix `i256::MAX`
21+
- Add a note saying why we use `frintx` rather than `frintn`
22+
- Typo in README.md
23+
- Clean up unused files
24+
1025
## [0.1.159](https://github.com/rust-lang/compiler-builtins/compare/compiler_builtins-v0.1.158...compiler_builtins-v0.1.159) - 2025-05-12
1126

1227
### Other

library/compiler-builtins/compiler-builtins/Cargo.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
authors = ["Jorge Aparicio <japaricious@gmail.com>"]
33
name = "compiler_builtins"
4-
version = "0.1.159"
4+
version = "0.1.160"
55
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
66
readme = "README.md"
77
repository = "https://github.com/rust-lang/compiler-builtins"
@@ -19,14 +19,11 @@ test = false
1919
[dependencies]
2020
# For more information on this dependency see
2121
# https://github.com/rust-lang/rust/tree/master/library/rustc-std-workspace-core
22-
core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" }
22+
core = { path = "../../core", optional = true }
2323

2424
[build-dependencies]
2525
cc = { optional = true, version = "1.0" }
2626

27-
[dev-dependencies]
28-
panic-handler = { path = "../crates/panic-handler" }
29-
3027
[features]
3128
default = ["compiler-builtins"]
3229

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
//! This is needed for tests on targets that require a `#[panic_handler]` function
22
3-
#![feature(no_core)]
4-
#![no_core]
5-
6-
extern crate core;
3+
#![no_std]
74

85
#[panic_handler]
9-
fn panic(_: &core::panic::PanicInfo) -> ! {
6+
fn panic(_: &core::panic::PanicInfo<'_>) -> ! {
107
loop {}
118
}

library/panic_abort/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ doc = false
1313

1414
[dependencies]
1515
core = { path = "../core" }
16-
compiler_builtins = "0.1.0"
16+
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
1717

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

library/panic_unwind/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ doc = false
1515
alloc = { path = "../alloc" }
1616
core = { path = "../core" }
1717
unwind = { path = "../unwind" }
18-
compiler_builtins = "0.1.0"
18+
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
1919
cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
2020

2121
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]

library/rustc-std-workspace-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ path = "lib.rs"
1212

1313
[dependencies]
1414
core = { path = "../core" }
15+
compiler_builtins = { path = "../compiler-builtins/compiler-builtins", features = ["compiler-builtins"] }

library/rustc-std-workspace-core/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
#![no_core]
33

44
pub use core::*;
5+
6+
// Crate must be brought into scope so it appears in the crate graph for anything that
7+
// depends on `rustc-std-workspace-core`.
8+
use compiler_builtins as _;

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ 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 = { version = "=0.1.160" }
21+
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
2222
unwind = { path = "../unwind" }
2323
hashbrown = { version = "0.15", default-features = false, features = [
2424
'rustc-dep-of-std',

library/unwind/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ doc = false
1515

1616
[dependencies]
1717
core = { path = "../core" }
18-
compiler_builtins = "0.1.0"
18+
compiler_builtins = { path = "../compiler-builtins/compiler-builtins" }
1919
cfg-if = "1.0"
2020

2121
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]

src/tools/miri/cargo-miri/src/setup.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ pub fn setup(
128128
}
129129
}
130130

131+
dbg!(&sysroot_dir, &rust_src);
132+
133+
command.arg(&format!(
134+
"--config=patch.crates-io.compiler_builtins.path=\
135+
'{}/compiler-builtins/compiler-builtins'",
136+
rust_src.display(),
137+
));
138+
131139
command
132140
};
133141
// Disable debug assertions in the standard library -- Miri is already slow enough.

0 commit comments

Comments
 (0)