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.
This commit is contained in:
Trevor Gross 2025-06-14 06:23:24 +00:00
parent c1cd1ef5fc
commit 7222fa6f34
5 changed files with 77 additions and 4 deletions

View file

@ -1,8 +1,8 @@
[workspace]
resolver = "2"
members = [
"builtins-shim",
"builtins-test",
"compiler-builtins",
"crates/josh-sync",
"crates/libm-macros",
"crates/musl-math-sys",
@ -14,8 +14,8 @@ members = [
]
default-members = [
"builtins-shim",
"builtins-test",
"compiler-builtins",
"crates/libm-macros",
"libm",
"libm-test",
@ -26,6 +26,10 @@ exclude = [
# and `mangled-names` disabled, which is the opposite of what is needed for
# other tests, so it makes sense to keep it out of the workspace.
"builtins-test-intrinsics",
# We test via the `builtins-shim` crate, so exclude the `compiler-builtins`
# that has a dependency on `core`. See `builtins-shim/Cargo.toml` for more
# details.
"compiler-builtins",
]
[profile.release]

View file

@ -0,0 +1,63 @@
# NOTE: Must be kept in sync with `../compiler-builtins/Cargo.toml`.
#
# The manifest at `../compiler-builtins` is what actually gets used in the
# rust-lang/rust tree; however, we can't build it out of tree because it
# depends on `core` by path, and even optional Cargo dependencies need to be
# available at build time. So, we work around this by having this "shim"
# manifest that is identical except for the `core` dependency and forwards
# to the same sources, which acts as the `compiler-builtins` Cargo entrypoint
# for out of tree testing
[package]
name = "compiler_builtins"
version = "0.1.160"
authors = ["Jorge Aparicio <japaricious@gmail.com>"]
description = "Compiler intrinsics used by the Rust compiler."
repository = "https://github.com/rust-lang/compiler-builtins"
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
edition = "2024"
publish = false
links = "compiler-rt"
build = "../compiler-builtins/build.rs"
[lib]
path = "../compiler-builtins/src/lib.rs"
bench = false
doctest = false
test = false
[build-dependencies]
cc = { optional = true, version = "1.2" }
[features]
default = ["compiler-builtins"]
# Enable compilation of C code in compiler-rt, filling in some more optimized
# implementations and also filling in unimplemented intrinsics
c = ["dep:cc"]
# Workaround for the Cranelift codegen backend. Disables any implementations
# which use inline assembly and fall back to pure Rust versions (if available).
no-asm = []
# Workaround for codegen backends which haven't yet implemented `f16` and
# `f128` support. Disabled any intrinsics which use those types.
no-f16-f128 = []
# Flag this library as the unstable compiler-builtins lib
compiler-builtins = []
# Generate memory-related intrinsics like memcpy
mem = []
# Mangle all names so this can be linked in with other versions or other
# compiler-rt implementations. Also used for testing
mangled-names = []
# Only used in the compiler's build system
rustc-dep-of-std = ["compiler-builtins"]
# This makes certain traits and function specializations public that
# are not normally public but are required by the `builtins-test`
unstable-public-internals = []

View file

@ -6,7 +6,7 @@ publish = false
license = "MIT OR Apache-2.0"
[dependencies]
compiler_builtins = { path = "../compiler-builtins", features = ["compiler-builtins"] }
compiler_builtins = { path = "../builtins-shim", features = ["compiler-builtins"] }
panic-handler = { path = "../crates/panic-handler" }
[features]

View file

@ -17,7 +17,7 @@ rustc_apfloat = "0.2.2"
iai-callgrind = { version = "0.14.1", optional = true }
[dependencies.compiler_builtins]
path = "../compiler-builtins"
path = "../builtins-shim"
default-features = false
features = ["unstable-public-internals"]

View file

@ -1,3 +1,9 @@
# NOTE: Must be kept in sync with `../builtins-shim/Cargo.toml`.
#
# This manifest is actually used in-tree by rust-lang/rust,
# `../builtins-shim/Cargo.toml` is used by out-of-tree testing. See the other
# manifest for further details.
[package]
name = "compiler_builtins"
version = "0.1.160"