@@ -298,15 +298,25 @@ impl Step for Llvm {
298
298
// This flag makes sure `FileCheck` is copied in the final binaries directory.
299
299
cfg. define ( "LLVM_INSTALL_UTILS" , "ON" ) ;
300
300
301
+ let mut cxxflags = "" . to_string ( ) ;
301
302
if builder. config . llvm_profile_generate {
302
- cfg. define ( "LLVM_BUILD_INSTRUMENTED" , "IR" ) ;
303
303
if let Ok ( llvm_profile_dir) = std:: env:: var ( "LLVM_PROFILE_DIR" ) {
304
304
cfg. define ( "LLVM_PROFILE_DATA_DIR" , llvm_profile_dir) ;
305
305
}
306
+
307
+ //cfg.define("LLVM_BUILD_INSTRUMENTED", "IR");
308
+ if std:: env:: var ( "LLVM_USE_CS_PGO" ) . is_ok ( ) {
309
+ cxxflags. push_str ( "-fcs-profile-generate=/tmp/llvm2" ) ;
310
+ // cfg.define("LLVM_VP_COUNTERS_PER_SITE", "8");
311
+ cxxflags. push_str ( " -mllvm -vp-counters-per-site=10" ) ;
312
+ } else {
313
+ cxxflags. push_str ( "-fprofile-generate=/tmp/llvm1" ) ;
314
+ }
306
315
cfg. define ( "LLVM_BUILD_RUNTIME" , "No" ) ;
307
316
}
308
317
if let Some ( path) = builder. config . llvm_profile_use . as_ref ( ) {
309
- cfg. define ( "LLVM_PROFDATA_FILE" , & path) ;
318
+ // cfg.define("LLVM_PROFDATA_FILE", &path);
319
+ cxxflags. push_str ( & format ! ( " -fprofile-use={path}" ) ) ;
310
320
}
311
321
312
322
if target != "aarch64-apple-darwin" && !target. contains ( "windows" ) {
@@ -442,7 +452,7 @@ impl Step for Llvm {
442
452
cfg. define ( "LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN" , "YES" ) ;
443
453
}
444
454
445
- configure_cmake ( builder, target, & mut cfg, true , ldflags) ;
455
+ configure_cmake ( builder, target, & mut cfg, true , ldflags, cxxflags ) ;
446
456
447
457
for ( key, val) in & builder. config . llvm_build_config {
448
458
cfg. define ( key, val) ;
@@ -491,6 +501,7 @@ fn configure_cmake(
491
501
cfg : & mut cmake:: Config ,
492
502
use_compiler_launcher : bool ,
493
503
mut ldflags : LdFlags ,
504
+ cxxflags2 : String ,
494
505
) {
495
506
// Do not print installation messages for up-to-date files.
496
507
// LLVM and LLD builds can produce a lot of those and hit CI limits on log size.
@@ -624,6 +635,9 @@ fn configure_cmake(
624
635
if builder. config . llvm_clang_cl . is_some ( ) {
625
636
cxxflags. push ( & format ! ( " --target={}" , target) ) ;
626
637
}
638
+ if !cxxflags2. is_empty ( ) {
639
+ cxxflags. push ( & format ! ( " {cxxflags2}" ) ) ;
640
+ }
627
641
cfg. define ( "CMAKE_CXX_FLAGS" , cxxflags) ;
628
642
if let Some ( ar) = builder. ar ( target) {
629
643
if ar. is_absolute ( ) {
@@ -717,7 +731,7 @@ impl Step for Lld {
717
731
t ! ( fs:: create_dir_all( & out_dir) ) ;
718
732
719
733
let mut cfg = cmake:: Config :: new ( builder. src . join ( "src/llvm-project/lld" ) ) ;
720
- configure_cmake ( builder, target, & mut cfg, true , LdFlags :: default ( ) ) ;
734
+ configure_cmake ( builder, target, & mut cfg, true , LdFlags :: default ( ) , "" . to_string ( ) ) ;
721
735
722
736
// This is an awful, awful hack. Discovered when we migrated to using
723
737
// clang-cl to compile LLVM/LLD it turns out that LLD, when built out of
@@ -919,7 +933,14 @@ impl Step for Sanitizers {
919
933
// Unfortunately sccache currently lacks support to build them successfully.
920
934
// Disable compiler launcher on Darwin targets to avoid potential issues.
921
935
let use_compiler_launcher = !self . target . contains ( "apple-darwin" ) ;
922
- configure_cmake ( builder, self . target , & mut cfg, use_compiler_launcher, LdFlags :: default ( ) ) ;
936
+ configure_cmake (
937
+ builder,
938
+ self . target ,
939
+ & mut cfg,
940
+ use_compiler_launcher,
941
+ LdFlags :: default ( ) ,
942
+ "" . to_string ( ) ,
943
+ ) ;
923
944
924
945
t ! ( fs:: create_dir_all( & out_dir) ) ;
925
946
cfg. out_dir ( out_dir) ;
0 commit comments