Skip to content

Commit 7222fa6

Browse files
committed
Work around out-of-tree testing with a shim crate
Out-of-tree testing is broken with the most recent update from rust-lang/rust because it makes `compiler-builtins` depend on `core` by path, which isn't usually available. In order to enable testing outside of rust-lang/rust, add a new crate `builtins-shim` that uses the same source as `compiler-builtins` but drops the `core` dependency. This has replaced `compiler-builtins` as the workspace member and entrypoint for tests.
1 parent c1cd1ef commit 7222fa6

File tree

5 files changed

+77
-4
lines changed

5 files changed

+77
-4
lines changed

library/compiler-builtins/Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[workspace]
22
resolver = "2"
33
members = [
4+
"builtins-shim",
45
"builtins-test",
5-
"compiler-builtins",
66
"crates/josh-sync",
77
"crates/libm-macros",
88
"crates/musl-math-sys",
@@ -14,8 +14,8 @@ members = [
1414
]
1515

1616
default-members = [
17+
"builtins-shim",
1718
"builtins-test",
18-
"compiler-builtins",
1919
"crates/libm-macros",
2020
"libm",
2121
"libm-test",
@@ -26,6 +26,10 @@ exclude = [
2626
# and `mangled-names` disabled, which is the opposite of what is needed for
2727
# other tests, so it makes sense to keep it out of the workspace.
2828
"builtins-test-intrinsics",
29+
# We test via the `builtins-shim` crate, so exclude the `compiler-builtins`
30+
# that has a dependency on `core`. See `builtins-shim/Cargo.toml` for more
31+
# details.
32+
"compiler-builtins",
2933
]
3034

3135
[profile.release]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# NOTE: Must be kept in sync with `../compiler-builtins/Cargo.toml`.
2+
#
3+
# The manifest at `../compiler-builtins` is what actually gets used in the
4+
# rust-lang/rust tree; however, we can't build it out of tree because it
5+
# depends on `core` by path, and even optional Cargo dependencies need to be
6+
# available at build time. So, we work around this by having this "shim"
7+
# manifest that is identical except for the `core` dependency and forwards
8+
# to the same sources, which acts as the `compiler-builtins` Cargo entrypoint
9+
# for out of tree testing
10+
11+
[package]
12+
name = "compiler_builtins"
13+
version = "0.1.160"
14+
authors = ["Jorge Aparicio <japaricious@gmail.com>"]
15+
description = "Compiler intrinsics used by the Rust compiler."
16+
repository = "https://github.com/rust-lang/compiler-builtins"
17+
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
18+
edition = "2024"
19+
publish = false
20+
links = "compiler-rt"
21+
22+
build = "../compiler-builtins/build.rs"
23+
24+
[lib]
25+
path = "../compiler-builtins/src/lib.rs"
26+
bench = false
27+
doctest = false
28+
test = false
29+
30+
[build-dependencies]
31+
cc = { optional = true, version = "1.2" }
32+
33+
[features]
34+
default = ["compiler-builtins"]
35+
36+
# Enable compilation of C code in compiler-rt, filling in some more optimized
37+
# implementations and also filling in unimplemented intrinsics
38+
c = ["dep:cc"]
39+
40+
# Workaround for the Cranelift codegen backend. Disables any implementations
41+
# which use inline assembly and fall back to pure Rust versions (if available).
42+
no-asm = []
43+
44+
# Workaround for codegen backends which haven't yet implemented `f16` and
45+
# `f128` support. Disabled any intrinsics which use those types.
46+
no-f16-f128 = []
47+
48+
# Flag this library as the unstable compiler-builtins lib
49+
compiler-builtins = []
50+
51+
# Generate memory-related intrinsics like memcpy
52+
mem = []
53+
54+
# Mangle all names so this can be linked in with other versions or other
55+
# compiler-rt implementations. Also used for testing
56+
mangled-names = []
57+
58+
# Only used in the compiler's build system
59+
rustc-dep-of-std = ["compiler-builtins"]
60+
61+
# This makes certain traits and function specializations public that
62+
# are not normally public but are required by the `builtins-test`
63+
unstable-public-internals = []

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 = "../builtins-shim", features = ["compiler-builtins"] }
1010
panic-handler = { path = "../crates/panic-handler" }
1111

1212
[features]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rustc_apfloat = "0.2.2"
1717
iai-callgrind = { version = "0.14.1", optional = true }
1818

1919
[dependencies.compiler_builtins]
20-
path = "../compiler-builtins"
20+
path = "../builtins-shim"
2121
default-features = false
2222
features = ["unstable-public-internals"]
2323

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# NOTE: Must be kept in sync with `../builtins-shim/Cargo.toml`.
2+
#
3+
# This manifest is actually used in-tree by rust-lang/rust,
4+
# `../builtins-shim/Cargo.toml` is used by out-of-tree testing. See the other
5+
# manifest for further details.
6+
17
[package]
28
name = "compiler_builtins"
39
version = "0.1.160"

0 commit comments

Comments
 (0)