Skip to content

Commit 21d4c2d

Browse files
committed
Try using flags directly
1 parent aeb7b54 commit 21d4c2d

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

src/bootstrap/llvm.rs

+28-13
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,34 @@ impl Step for Llvm {
331331
// This flag makes sure `FileCheck` is copied in the final binaries directory.
332332
cfg.define("LLVM_INSTALL_UTILS", "ON");
333333

334-
let mut cxxflags = vec![];
334+
let mut cxxflags: Vec<String> = Vec::new();
335335
if builder.config.llvm_profile_generate {
336336
if std::env::var("LLVM_USE_CS_PGO").is_ok() {
337-
cfg.define("LLVM_BUILD_INSTRUMENTED", "CSIR");
338-
if let Ok(llvm_profile_dir) = std::env::var("LLVM_PROFILE_DIR") {
339-
cfg.define("LLVM_CSPROFILE_DATA_DIR", llvm_profile_dir);
340-
}
337+
//cfg.define("LLVM_BUILD_INSTRUMENTED", "CSIR");
338+
cxxflags.push(format!(
339+
"-fcs-profile-generate={}",
340+
std::env::var("LLVM_PROFILE_DIR").unwrap()
341+
));
342+
//if let Ok(llvm_profile_dir) = std::env::var("LLVM_PROFILE_DIR") {
343+
// cfg.define("LLVM_CSPROFILE_DATA_DIR", llvm_profile_dir);
344+
//}
345+
cxxflags.push("-mllvm".to_string());
346+
cxxflags.push("-vp-counters-per-site=10".to_string());
341347
} else {
342-
cfg.define("LLVM_BUILD_INSTRUMENTED", "IR");
343-
if let Ok(llvm_profile_dir) = std::env::var("LLVM_PROFILE_DIR") {
344-
cfg.define("LLVM_PROFILE_DATA_DIR", llvm_profile_dir);
345-
}
348+
//cfg.define("LLVM_BUILD_INSTRUMENTED", "IR");
349+
//if let Ok(llvm_profile_dir) = std::env::var("LLVM_PROFILE_DIR") {
350+
// cfg.define("LLVM_PROFILE_DATA_DIR", llvm_profile_dir);
351+
//}
352+
cxxflags.push(format!(
353+
"-fprofile-generate={}",
354+
std::env::var("LLVM_PROFILE_DIR").unwrap()
355+
));
346356
}
347-
cxxflags.push("-mllvm");
348-
cxxflags.push("-vp-counters-per-site=10");
349357
cfg.define("LLVM_BUILD_RUNTIME", "No");
350358
}
351359
if let Some(path) = builder.config.llvm_profile_use.as_ref() {
352360
// cfg.define("LLVM_PROFDATA_FILE", &path);
353-
cxxflags.push(&format!("-fprofile-use={path}"));
361+
cxxflags.push(format!("-fprofile-use={path}"));
354362
}
355363
if builder.config.llvm_bolt_profile_generate
356364
|| builder.config.llvm_bolt_profile_use.is_some()
@@ -485,7 +493,14 @@ impl Step for Llvm {
485493
cfg.define("LLVM_VERSION_SUFFIX", suffix);
486494
}
487495

488-
configure_cmake(builder, target, &mut cfg, true, ldflags, &[]);
496+
configure_cmake(
497+
builder,
498+
target,
499+
&mut cfg,
500+
true,
501+
ldflags,
502+
&cxxflags.iter().map(|s| s.as_str()).collect::<Vec<_>>(),
503+
);
489504
configure_llvm(builder, target, &mut cfg);
490505

491506
for (key, val) in &builder.config.llvm_build_config {

src/ci/stage-build.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, runner: BenchmarkRu
810810
build_rustc(pipeline, args=[
811811
"--llvm-profile-generate"
812812
], env=dict(
813-
LLVM_PROFILE_DIR=str(pipeline.llvm_profile_dir_root() / "prof-%p")
813+
LLVM_PROFILE_DIR=str(pipeline.llvm_profile_dir_root() / "profiles")
814814
))
815815
record_metrics(pipeline, rustc_build)
816816

@@ -829,8 +829,7 @@ def execute_build_pipeline(timer: Timer, pipeline: Pipeline, runner: BenchmarkRu
829829
pipeline.llvm_profile_merged_file_intermediate()
830830
], env=dict(
831831
LLVM_USE_CS_PGO="1",
832-
LLVM_PROFILE_DIR=str(pipeline.llvm_profile_dir_root() / "%4m.profraw"),
833-
# LLVM_PROFILE_DIR=str(pipeline.llvm_profile_dir_root() / "prof-%p"),
832+
LLVM_PROFILE_DIR=str(pipeline.llvm_profile_dir_root() / "profiles2"),
834833
))
835834
record_metrics(pipeline, rustc_build)
836835

0 commit comments

Comments
 (0)