Skip to content

Commit 1ddf250

Browse files
authored
Rollup merge of #69104 - tmiasko:configure-cmake, r=Mark-Simulacrum
bootstrap: Configure cmake when building sanitizer runtimes Configure cmake before building sanitizer runtimes in similar way it is already configured elsewhere, to ensure that they are built with expected compiler flags. Previously this step has been intentionally omitted since sanitizer runtimes are built as universal binaries on Darwin targets, which in turn are unsupported by sccache which is also configured there. To avoid the issue everything but the compiler launcher is configured. Helps with #68863.
2 parents ec5bf15 + 33e2c1d commit 1ddf250

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/bootstrap/native.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl Step for Llvm {
262262
cfg.define("PYTHON_EXECUTABLE", python);
263263
}
264264

265-
configure_cmake(builder, target, &mut cfg);
265+
configure_cmake(builder, target, &mut cfg, true);
266266

267267
// FIXME: we don't actually need to build all LLVM tools and all LLVM
268268
// libraries here, e.g., we just want a few components and a few
@@ -301,7 +301,12 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
301301
panic!("\n\nbad LLVM version: {}, need >=7.0\n\n", version)
302302
}
303303

304-
fn configure_cmake(builder: &Builder<'_>, target: Interned<String>, cfg: &mut cmake::Config) {
304+
fn configure_cmake(
305+
builder: &Builder<'_>,
306+
target: Interned<String>,
307+
cfg: &mut cmake::Config,
308+
use_compiler_launcher: bool,
309+
) {
305310
// Do not print installation messages for up-to-date files.
306311
// LLVM and LLD builds can produce a lot of those and hit CI limits on log size.
307312
cfg.define("CMAKE_INSTALL_MESSAGE", "LAZY");
@@ -372,9 +377,11 @@ fn configure_cmake(builder: &Builder<'_>, target: Interned<String>, cfg: &mut cm
372377
} else {
373378
// If ccache is configured we inform the build a little differently how
374379
// to invoke ccache while also invoking our compilers.
375-
if let Some(ref ccache) = builder.config.ccache {
376-
cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
377-
.define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
380+
if use_compiler_launcher {
381+
if let Some(ref ccache) = builder.config.ccache {
382+
cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache)
383+
.define("CMAKE_CXX_COMPILER_LAUNCHER", ccache);
384+
}
378385
}
379386
cfg.define("CMAKE_C_COMPILER", sanitize_cc(cc))
380387
.define("CMAKE_CXX_COMPILER", sanitize_cc(cxx));
@@ -458,7 +465,7 @@ impl Step for Lld {
458465
t!(fs::create_dir_all(&out_dir));
459466

460467
let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
461-
configure_cmake(builder, target, &mut cfg);
468+
configure_cmake(builder, target, &mut cfg, true);
462469

463470
// This is an awful, awful hack. Discovered when we migrated to using
464471
// clang-cl to compile LLVM/LLD it turns out that LLD, when built out of
@@ -595,10 +602,7 @@ impl Step for Sanitizers {
595602
let _time = util::timeit(&builder);
596603

597604
let mut cfg = cmake::Config::new(&compiler_rt_dir);
598-
cfg.target(&self.target);
599-
cfg.host(&builder.config.build);
600605
cfg.profile("Release");
601-
602606
cfg.define("CMAKE_C_COMPILER_TARGET", self.target);
603607
cfg.define("COMPILER_RT_BUILD_BUILTINS", "OFF");
604608
cfg.define("COMPILER_RT_BUILD_CRT", "OFF");
@@ -610,6 +614,12 @@ impl Step for Sanitizers {
610614
cfg.define("COMPILER_RT_USE_LIBCXX", "OFF");
611615
cfg.define("LLVM_CONFIG_PATH", &llvm_config);
612616

617+
// On Darwin targets the sanitizer runtimes are build as universal binaries.
618+
// Unfortunately sccache currently lacks support to build them successfully.
619+
// Disable compiler launcher on Darwin targets to avoid potential issues.
620+
let use_compiler_launcher = !self.target.contains("apple-darwin");
621+
configure_cmake(builder, self.target, &mut cfg, use_compiler_launcher);
622+
613623
t!(fs::create_dir_all(&out_dir));
614624
cfg.out_dir(out_dir);
615625

0 commit comments

Comments
 (0)