Skip to content

Commit 34e0169

Browse files
committed
Unrolled build for #165275 in rollup 165510
Rollup merge of #165275 - TechnoPorg:push-wrpxssqqoxqw, r=ZuseZ4 Build TPDE with local Clang when available As noted in #164108 (review), TPDE requires a clang with a major version <= the LLVM major version, and performance tends to be better when built with clang. This PR makes TPDE compilation and encodegen use the locally built clang if it's available. I haven't added any sort of warning if `llvm.clang` is _not_ set as TPDE will throw its own error if the major version is too high. Maybe it's worth doing so, though? This also includes the TPDE compilation fix commit from #164108. We will see which ones makes it in first. r? @ZuseZ4
2 parents 712e1d3 + 1b5a973 commit 34e0169

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

  • src/bootstrap/src/core/build_steps

‎src/bootstrap/src/core/build_steps/llvm.rs‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,13 +2333,14 @@ fn get_locally_built_tpde_build_status(
23332333
tpde_root_dir: out_dir,
23342334
};
23352335

2336+
// TPDE links against LLVM.
2337+
// By including the LLVM hash as well as the TPDE hash we force a rebuild of TPDE when updating LLVM.
2338+
let tpde_hash_input = builder.in_tree_llvm_info.sha().unwrap_or_default().to_owned()
2339+
+ builder.in_tree_tpde_info.sha().unwrap_or_default();
2340+
23362341
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
23372342
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
2338-
generate_smart_stamp_hash(
2339-
builder,
2340-
&builder.config.src.join("src/tpde"),
2341-
builder.in_tree_tpde_info.sha().unwrap_or_default(),
2342-
)
2343+
generate_smart_stamp_hash(builder, &builder.config.src.join("src/tpde"), &tpde_hash_input)
23432344
});
23442345

23452346
// Rebuild if build options change
@@ -2348,7 +2349,8 @@ fn get_locally_built_tpde_build_status(
23482349
.add_stamp(smart_stamp_hash)
23492350
.add_stamp(builder.config.llvm_assertions)
23502351
.add_stamp(builder.config.llvm_optimize)
2351-
.add_stamp(builder.config.llvm_release_debuginfo);
2352+
.add_stamp(builder.config.llvm_release_debuginfo)
2353+
.add_stamp(builder.config.llvm_clang);
23522354

23532355
if stamp.is_up_to_date() {
23542356
if smart_stamp_hash.is_empty() {
@@ -2436,17 +2438,29 @@ impl CommandLineStep for Tpde {
24362438
.define("TPDE_ENABLE_COVERAGE", "OFF")
24372439
.define("TPDE_BUILD_DOCS", "OFF")
24382440
.define("TPDE_ENABLE_EH", "OFF")
2441+
.define("CMAKE_INSTALL_LIBDIR", "lib")
24392442
.define("LLVM_DIR", llvm.cmake_dir());
24402443

24412444
let mut ldflags = LdFlags::default();
24422445
try_link_with_in_tree_lld(builder, target, &llvm, &mut cfg, &mut ldflags);
24432446
configure_cmake(builder, target, &mut cfg, true, ldflags, CcFlags::default(), &[]);
24442447

2448+
if builder.config.llvm_clang {
2449+
let clang_bin_dir = llvm.llvm_config().parent().map(Path::to_path_buf).unwrap();
2450+
let clang = clang_bin_dir.join(exe("clang", target));
2451+
let clangxx = clang_bin_dir.join(exe("clang++", target));
2452+
2453+
cfg.define("CMAKE_C_COMPILER", &clang)
2454+
.define("CMAKE_CXX_COMPILER", &clangxx)
2455+
.define("CMAKE_ASM_COMPILER", &clang);
2456+
}
2457+
24452458
if builder.config.dry_run() {
24462459
return output;
24472460
}
24482461

24492462
cfg.build_target("tpde-plugin.so");
2463+
cfg.build();
24502464

24512465
// When building TPDE as a shared library on linux, it can contain unexpected debuginfo:
24522466
// some can come from the C++ standard library. Unless we're explicitly requesting TPDE to

0 commit comments

Comments
 (0)