Skip to content

Commit 89f7628

Browse files
authored
Rollup merge of rust-lang#60981 - alexcrichton:update-compiler-builtins, r=cuviper
Bump compiler-builtins to 0.1.15 This commit bumps the `compiler-builtins` dependency to 0.1.15 which expects to have the source for `compiler-rt` provided externally if the `c` feature is enabled. This then plumbs through the necessary support in the build system to ensure that if the `llvm-project` directory is checked out and present that we enable the `c` feature of `compiler-builtins` and compile in all the C intrinsics.
2 parents 5bc84d2 + 69c6326 commit 89f7628

File tree

4 files changed

+51
-24
lines changed

4 files changed

+51
-24
lines changed

Cargo.lock

+17-17
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
name = "alloc"
2626
version = "0.0.0"
2727
dependencies = [
28-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
28+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
2929
"core 0.0.0",
3030
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
3131
"rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -123,7 +123,7 @@ version = "0.1.27"
123123
source = "registry+https://github.com/rust-lang/crates.io-index"
124124
dependencies = [
125125
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
126-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
126+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
127127
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
128128
"rustc-std-workspace-core 1.0.0",
129129
]
@@ -462,7 +462,7 @@ dependencies = [
462462

463463
[[package]]
464464
name = "compiler_builtins"
465-
version = "0.1.14"
465+
version = "0.1.15"
466466
source = "registry+https://github.com/rust-lang/crates.io-index"
467467
dependencies = [
468468
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -744,7 +744,7 @@ name = "dlmalloc"
744744
version = "0.1.3"
745745
source = "registry+https://github.com/rust-lang/crates.io-index"
746746
dependencies = [
747-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
747+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
748748
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
749749
"rustc-std-workspace-core 1.0.0",
750750
]
@@ -910,7 +910,7 @@ name = "fortanix-sgx-abi"
910910
version = "0.3.2"
911911
source = "registry+https://github.com/rust-lang/crates.io-index"
912912
dependencies = [
913-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
913+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
914914
"rustc-std-workspace-core 1.0.0",
915915
]
916916

@@ -1071,7 +1071,7 @@ name = "hashbrown"
10711071
version = "0.3.0"
10721072
source = "registry+https://github.com/rust-lang/crates.io-index"
10731073
dependencies = [
1074-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
1074+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
10751075
"rustc-std-workspace-alloc 1.0.0",
10761076
"rustc-std-workspace-core 1.0.0",
10771077
]
@@ -1772,7 +1772,7 @@ dependencies = [
17721772
name = "panic_abort"
17731773
version = "0.0.0"
17741774
dependencies = [
1775-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
1775+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
17761776
"core 0.0.0",
17771777
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
17781778
]
@@ -1782,7 +1782,7 @@ name = "panic_unwind"
17821782
version = "0.0.0"
17831783
dependencies = [
17841784
"alloc 0.0.0",
1785-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
1785+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
17861786
"core 0.0.0",
17871787
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
17881788
"unwind 0.0.0",
@@ -1967,7 +1967,7 @@ name = "profiler_builtins"
19671967
version = "0.0.0"
19681968
dependencies = [
19691969
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
1970-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
1970+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
19711971
"core 0.0.0",
19721972
]
19731973

@@ -2492,7 +2492,7 @@ name = "rustc-demangle"
24922492
version = "0.1.10"
24932493
source = "registry+https://github.com/rust-lang/crates.io-index"
24942494
dependencies = [
2495-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
2495+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
24962496
"rustc-std-workspace-core 1.0.0",
24972497
]
24982498

@@ -2620,7 +2620,7 @@ dependencies = [
26202620
"alloc 0.0.0",
26212621
"build_helper 0.1.0",
26222622
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
2623-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
2623+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
26242624
"core 0.0.0",
26252625
]
26262626

@@ -2850,7 +2850,7 @@ dependencies = [
28502850
"alloc 0.0.0",
28512851
"build_helper 0.1.0",
28522852
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
2853-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
2853+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
28542854
"core 0.0.0",
28552855
]
28562856

@@ -2912,7 +2912,7 @@ dependencies = [
29122912
"alloc 0.0.0",
29132913
"build_helper 0.1.0",
29142914
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
2915-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
2915+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
29162916
"core 0.0.0",
29172917
]
29182918

@@ -3029,7 +3029,7 @@ dependencies = [
30293029
"alloc 0.0.0",
30303030
"build_helper 0.1.0",
30313031
"cmake 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
3032-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
3032+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
30333033
"core 0.0.0",
30343034
]
30353035

@@ -3298,7 +3298,7 @@ dependencies = [
32983298
"alloc 0.0.0",
32993299
"backtrace-sys 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)",
33003300
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
3301-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
3301+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
33023302
"core 0.0.0",
33033303
"dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
33043304
"fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3889,7 +3889,7 @@ name = "unwind"
38893889
version = "0.0.0"
38903890
dependencies = [
38913891
"cc 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
3892-
"compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
3892+
"compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
38933893
"core 0.0.0",
38943894
"libc 0.2.54 (registry+https://github.com/rust-lang/crates.io-index)",
38953895
]
@@ -4087,7 +4087,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
40874087
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
40884088
"checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007"
40894089
"checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2"
4090-
"checksum compiler_builtins 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "e3f235c329e5cb9fa3d2ca2cc36256ba9a7f23fa76e0f4db6f68c23b73b2ac69"
4090+
"checksum compiler_builtins 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "e899b947d7e71c3d35c0b6194d64025b84946640510e215090c815b20828964e"
40914091
"checksum compiletest_rs 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "f40ecc9332b68270998995c00f8051ee856121764a0d3230e64c9efd059d27b6"
40924092
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
40934093
"checksum core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e2640d6d0bf22e82bed1b73c6aef8d5dd31e5abe6666c57e6d45e2649f4f887"

src/bootstrap/compile.rs

+28-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,33 @@ pub fn std_cargo(builder: &Builder<'_>,
161161
cargo.env("MACOSX_DEPLOYMENT_TARGET", target);
162162
}
163163

164+
// Determine if we're going to compile in optimized C intrinsics to
165+
// the `compiler-builtins` crate. These intrinsics live in LLVM's
166+
// `compiler-rt` repository, but our `src/llvm-project` submodule isn't
167+
// always checked out, so we need to conditionally look for this. (e.g. if
168+
// an external LLVM is used we skip the LLVM submodule checkout).
169+
//
170+
// Note that this shouldn't affect the correctness of `compiler-builtins`,
171+
// but only its speed. Some intrinsics in C haven't been translated to Rust
172+
// yet but that's pretty rare. Other intrinsics have optimized
173+
// implementations in C which have only had slower versions ported to Rust,
174+
// so we favor the C version where we can, but it's not critical.
175+
//
176+
// If `compiler-rt` is available ensure that the `c` feature of the
177+
// `compiler-builtins` crate is enabled and it's configured to learn where
178+
// `compiler-rt` is located.
179+
let compiler_builtins_root = builder.src.join("src/llvm-project/compiler-rt");
180+
let compiler_builtins_c_feature = if compiler_builtins_root.exists() {
181+
cargo.env("RUST_COMPILER_RT_ROOT", &compiler_builtins_root);
182+
" compiler-builtins-c".to_string()
183+
} else {
184+
String::new()
185+
};
186+
164187
if builder.no_std(target) == Some(true) {
188+
let mut features = "compiler-builtins-mem".to_string();
189+
features.push_str(&compiler_builtins_c_feature);
190+
165191
// for no-std targets we only compile a few no_std crates
166192
cargo
167193
.args(&["-p", "alloc"])
@@ -170,7 +196,8 @@ pub fn std_cargo(builder: &Builder<'_>,
170196
.arg("--features")
171197
.arg("compiler-builtins-mem compiler-builtins-c");
172198
} else {
173-
let features = builder.std_features();
199+
let mut features = builder.std_features();
200+
features.push_str(&compiler_builtins_c_feature);
174201

175202
if compiler.stage != 0 && builder.config.sanitizers {
176203
// This variable is used by the sanitizer runtime crates, e.g.

src/build_helper/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str)
288288
} else {
289289
format!("static={}", link_name)
290290
};
291-
// The source for `compiler-rt` comes from the `compiler-builtins` crate, so
292-
// load our env var set by cargo to find the source code.
293-
let dir = env::var_os("DEP_COMPILER_RT_COMPILER_RT").unwrap();
291+
// This env var is provided by rustbuild to tell us where `compiler-rt`
292+
// lives.
293+
let dir = env::var_os("RUST_COMPILER_RT_ROOT").unwrap();
294294
let lib = native_lib_boilerplate(
295295
dir.as_ref(),
296296
sanitizer_name,

src/libstd/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ panic_unwind = { path = "../libpanic_unwind", optional = true }
1919
panic_abort = { path = "../libpanic_abort" }
2020
core = { path = "../libcore" }
2121
libc = { version = "0.2.51", default-features = false, features = ['rustc-dep-of-std'] }
22-
compiler_builtins = { version = "0.1.14" }
22+
compiler_builtins = { version = "0.1.15" }
2323
profiler_builtins = { path = "../libprofiler_builtins", optional = true }
2424
unwind = { path = "../libunwind" }
2525
hashbrown = { version = "0.3.0", features = ['rustc-dep-of-std'] }
@@ -49,12 +49,12 @@ fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
4949
cc = "1.0"
5050

5151
[features]
52-
default = ["compiler_builtins_c", "std_detect_file_io", "std_detect_dlsym_getauxval"]
52+
default = ["std_detect_file_io", "std_detect_dlsym_getauxval"]
5353

5454
backtrace = ["backtrace-sys"]
5555
panic-unwind = ["panic_unwind"]
5656
profiler = ["profiler_builtins"]
57-
compiler_builtins_c = ["alloc/compiler-builtins-c"]
57+
compiler-builtins-c = ["alloc/compiler-builtins-c"]
5858
llvm-libunwind = ["unwind/llvm-libunwind"]
5959

6060
# Make panics and failed asserts immediately abort without formatting any message

0 commit comments

Comments
 (0)