Skip to content

Commit 3affb05

Browse files
authoredOct 31, 2022
Rollup merge of #103732 - Mark-Simulacrum:revert-compiler-builtins, r=jyn514
Revert "Make the `c` feature for `compiler-builtins` opt-in instead of inferred" This reverts commit 3acb505 (PR #101833). The changes in this commit caused several bugs/incompatibilities (#101833 (comment), #102560). For now we're reverting this commit and will re-land it alongside fixes for those bugs. Re-opens #101172 cc #102560 cc #102579
2 parents c1c2922 + 5984b1d commit 3affb05

File tree

9 files changed

+22
-44
lines changed

9 files changed

+22
-44
lines changed
 

‎config.toml.example

-4
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ changelog-seen = 2
291291
# on this runtime, such as `-C profile-generate` or `-C instrument-coverage`).
292292
#profiler = false
293293

294-
# Use the optimized LLVM C intrinsics for `compiler_builtins`, rather than Rust intrinsics.
295-
# Requires the LLVM submodule to be managed by bootstrap (i.e. not external).
296-
#optimized-compiler-builtins = false
297-
298294
# Indicates whether the native libraries linked into Cargo will be statically
299295
# linked or not.
300296
#cargo-native-static = false

‎src/bootstrap/compile.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
299299

300300
// Determine if we're going to compile in optimized C intrinsics to
301301
// the `compiler-builtins` crate. These intrinsics live in LLVM's
302-
// `compiler-rt` repository.
302+
// `compiler-rt` repository, but our `src/llvm-project` submodule isn't
303+
// always checked out, so we need to conditionally look for this. (e.g. if
304+
// an external LLVM is used we skip the LLVM submodule checkout).
303305
//
304306
// Note that this shouldn't affect the correctness of `compiler-builtins`,
305307
// but only its speed. Some intrinsics in C haven't been translated to Rust
@@ -310,15 +312,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car
310312
// If `compiler-rt` is available ensure that the `c` feature of the
311313
// `compiler-builtins` crate is enabled and it's configured to learn where
312314
// `compiler-rt` is located.
313-
let compiler_builtins_c_feature = if builder.config.optimized_compiler_builtins {
314-
if !builder.is_rust_llvm(target) {
315-
panic!(
316-
"need a managed LLVM submodule for optimized intrinsics support; unset `llvm-config` or `optimized-compiler-builtins`"
317-
);
318-
}
319-
320-
builder.update_submodule(&Path::new("src").join("llvm-project"));
321-
let compiler_builtins_root = builder.src.join("src/llvm-project/compiler-rt");
315+
let compiler_builtins_root = builder.src.join("src/llvm-project/compiler-rt");
316+
let compiler_builtins_c_feature = if compiler_builtins_root.exists() {
322317
// Note that `libprofiler_builtins/build.rs` also computes this so if
323318
// you're changing something here please also change that.
324319
cargo.env("RUST_COMPILER_RT_ROOT", &compiler_builtins_root);

‎src/bootstrap/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ pub struct Config {
7373
pub color: Color,
7474
pub patch_binaries_for_nix: bool,
7575
pub stage0_metadata: Stage0Metadata,
76-
/// Whether to use the `c` feature of the `compiler_builtins` crate.
77-
pub optimized_compiler_builtins: bool,
7876

7977
pub on_fail: Option<String>,
8078
pub stage: u32,
@@ -624,7 +622,6 @@ define_config! {
624622
bench_stage: Option<u32> = "bench-stage",
625623
patch_binaries_for_nix: Option<bool> = "patch-binaries-for-nix",
626624
metrics: Option<bool> = "metrics",
627-
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
628625
}
629626
}
630627

@@ -1013,7 +1010,6 @@ impl Config {
10131010
set(&mut config.print_step_timings, build.print_step_timings);
10141011
set(&mut config.print_step_rusage, build.print_step_rusage);
10151012
set(&mut config.patch_binaries_for_nix, build.patch_binaries_for_nix);
1016-
set(&mut config.optimized_compiler_builtins, build.optimized_compiler_builtins);
10171013

10181014
config.verbose = cmp::max(config.verbose, flags.verbose);
10191015

‎src/bootstrap/dist.rs

+17-15
Original file line numberDiff line numberDiff line change
@@ -1847,21 +1847,23 @@ fn add_env(builder: &Builder<'_>, cmd: &mut Command, target: TargetSelection) {
18471847
///
18481848
/// Returns whether the files were actually copied.
18491849
fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir: &Path) -> bool {
1850-
if !builder.is_rust_llvm(target) {
1851-
// If the LLVM was externally provided, then we don't currently copy
1852-
// artifacts into the sysroot. This is not necessarily the right
1853-
// choice (in particular, it will require the LLVM dylib to be in
1854-
// the linker's load path at runtime), but the common use case for
1855-
// external LLVMs is distribution provided LLVMs, and in that case
1856-
// they're usually in the standard search path (e.g., /usr/lib) and
1857-
// copying them here is going to cause problems as we may end up
1858-
// with the wrong files and isn't what distributions want.
1859-
//
1860-
// This behavior may be revisited in the future though.
1861-
//
1862-
// If the LLVM is coming from ourselves (just from CI) though, we
1863-
// still want to install it, as it otherwise won't be available.
1864-
return false;
1850+
if let Some(config) = builder.config.target_config.get(&target) {
1851+
if config.llvm_config.is_some() && !builder.config.llvm_from_ci {
1852+
// If the LLVM was externally provided, then we don't currently copy
1853+
// artifacts into the sysroot. This is not necessarily the right
1854+
// choice (in particular, it will require the LLVM dylib to be in
1855+
// the linker's load path at runtime), but the common use case for
1856+
// external LLVMs is distribution provided LLVMs, and in that case
1857+
// they're usually in the standard search path (e.g., /usr/lib) and
1858+
// copying them here is going to cause problems as we may end up
1859+
// with the wrong files and isn't what distributions want.
1860+
//
1861+
// This behavior may be revisited in the future though.
1862+
//
1863+
// If the LLVM is coming from ourselves (just from CI) though, we
1864+
// still want to install it, as it otherwise won't be available.
1865+
return false;
1866+
}
18651867
}
18661868

18671869
// On macOS, rustc (and LLVM tools) link to an unversioned libLLVM.dylib

‎src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,4 @@ ENV RUST_CONFIGURE_ARGS --disable-jemalloc \
4747
--set=$TARGET.cc=x86_64-unknown-haiku-gcc \
4848
--set=$TARGET.cxx=x86_64-unknown-haiku-g++ \
4949
--set=$TARGET.llvm-config=/bin/llvm-config-haiku
50-
ENV EXTERNAL_LLVM 1
51-
5250
ENV SCRIPT python3 ../x.py dist --host=$HOST --target=$HOST

‎src/ci/docker/host-x86_64/dist-various-2/Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,4 @@ ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
129129
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
130130
--musl-root-armv7=/musl-armv7
131131

132-
ENV EXTERNAL_LLVM 1
133-
134132
ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS

‎src/ci/docker/host-x86_64/x86_64-gnu-llvm-13-stage1/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ RUN sh /scripts/sccache.sh
2929
# We are disabling CI LLVM since this builder is intentionally using a host
3030
# LLVM, rather than the typical src/llvm-project LLVM.
3131
ENV NO_DOWNLOAD_CI_LLVM 1
32-
ENV EXTERNAL_LLVM 1
3332

3433
# Using llvm-link-shared due to libffi issues -- see #34486
3534
ENV RUST_CONFIGURE_ARGS \

‎src/ci/docker/host-x86_64/x86_64-gnu-llvm-13/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ RUN sh /scripts/sccache.sh
4040
# We are disabling CI LLVM since this builder is intentionally using a host
4141
# LLVM, rather than the typical src/llvm-project LLVM.
4242
ENV NO_DOWNLOAD_CI_LLVM 1
43-
ENV EXTERNAL_LLVM 1
4443

4544
# Using llvm-link-shared due to libffi issues -- see #34486
4645
ENV RUST_CONFIGURE_ARGS \

‎src/ci/run.sh

-5
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
6969
# space required for CI artifacts.
7070
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --dist-compression-formats=xz"
7171

72-
# Enable the `c` feature for compiler_builtins, but only when the `compiler-rt` source is available.
73-
if [ "$EXTERNAL_LLVM" = "" ]; then
74-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.optimized-compiler-builtins"
75-
fi
76-
7772
if [ "$DIST_SRC" = "" ]; then
7873
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
7974
fi

0 commit comments

Comments
 (0)