Skip to content

Commit a320965

Browse files
committed
Move the builtins for in-tree use to a separate crate
1 parent a2357f8 commit a320965

File tree

4 files changed

+73
-5
lines changed

4 files changed

+73
-5
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
"crates/symbol-check",
1111
"crates/util",
1212
"libm",
13-
"libm-test",
13+
"libm-test"
1414
]
1515

1616
default-members = [
@@ -26,6 +26,7 @@ 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+
"rustc-std-workspace-compiler-builtins",
2930
]
3031

3132
[profile.release]

compiler-builtins/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ bench = false
1616
doctest = false
1717
test = false
1818

19-
[dependencies]
20-
core = { path = "../../core", optional = true }
21-
2219
[build-dependencies]
2320
cc = { optional = true, version = "1.2" }
2421

@@ -48,7 +45,7 @@ mem = []
4845
mangled-names = []
4946

5047
# Only used in the compiler's build system
51-
rustc-dep-of-std = ["compiler-builtins", "dep:core"]
48+
rustc-dep-of-std = ["compiler-builtins"]
5249

5350
# This makes certain traits and function specializations public that
5451
# are not normally public but are required by the `builtins-test`
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[package]
2+
name = "compiler_builtins"
3+
version = "0.1.160"
4+
license = "MIT AND Apache-2.0 WITH LLVM-exception AND (MIT OR Apache-2.0)"
5+
edition = "2024"
6+
publish = false
7+
links = "compiler-rt"
8+
include = ["../compiler-builtins/src"]
9+
build = "../compiler-builtins/build.rs"
10+
11+
[lib]
12+
bench = false
13+
doctest = false
14+
test = false
15+
16+
[dependencies]
17+
core = { path = "../../core", optional = true }
18+
19+
[build-dependencies]
20+
cc = { optional = true, version = "1.2" }
21+
22+
[features]
23+
default = ["compiler-builtins"]
24+
25+
# Enable compilation of C code in compiler-rt, filling in some more optimized
26+
# implementations and also filling in unimplemented intrinsics
27+
c = ["dep:cc"]
28+
29+
# Workaround for the Cranelift codegen backend. Disables any implementations
30+
# which use inline assembly and fall back to pure Rust versions (if available).
31+
no-asm = []
32+
33+
# Workaround for codegen backends which haven't yet implemented `f16` and
34+
# `f128` support. Disabled any intrinsics which use those types.
35+
no-f16-f128 = []
36+
37+
# Flag this library as the unstable compiler-builtins lib
38+
compiler-builtins = []
39+
40+
# Generate memory-related intrinsics like memcpy
41+
mem = []
42+
43+
# Mangle all names so this can be linked in with other versions or other
44+
# compiler-rt implementations. Also used for testing
45+
mangled-names = []
46+
47+
# Only used in the compiler's build system
48+
rustc-dep-of-std = ["compiler-builtins"]
49+
50+
# This makes certain traits and function specializations public that
51+
# are not normally public but are required by the `builtins-test`
52+
unstable-public-internals = []
53+
54+
[lints.rust]
55+
# The cygwin config can be dropped after our benchmark toolchain is bumped
56+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)', 'cfg(target_os, values("cygwin"))'] }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: u64, right: u64) -> u64 {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

0 commit comments

Comments
 (0)