Skip to content

Commit 8a5b12f

Browse files
committed
[introduce CMake var EXTRA_DFLAGS_LDC for PGO flags]
As DFLAGS_LDC affect the ldc2-unittest executable too, which is built without optimizations (but with `-g -unittest`).
1 parent 45904ba commit 8a5b12f

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

.github/actions/2a-build-pgo/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ runs:
2222
-DBUILD_SHARED_LIBS=OFF
2323
"-DCMAKE_C_COMPILER=${{ runner.os != 'Windows' && '$PWD/../clang/bin/clang' || 'clang-cl' }}"
2424
"-DCMAKE_CXX_COMPILER=${{ runner.os != 'Windows' && '$PWD/../clang/bin/clang++' || 'clang-cl' }}"
25-
"-DDFLAGS_LDC=-fprofile-generate -vp-counters-per-site=1.5"
25+
"-DEXTRA_DFLAGS_LDC=-fprofile-generate -vp-counters-per-site=1.5"
2626
extra_d_flags: ${{ inputs.extra_d_flags }}
2727
extra_cxx_flags: -fprofile-generate -mllvm -vp-counters-per-site=1.5
2828
lto_mode: ${{ inputs.lto_mode }}

.github/actions/helper-build-ldc/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ runs:
5757
cxx_flags+=(-flto="$lto_mode")
5858
fi
5959
if [[ "$with_pgo" == true ]]; then
60-
flags+="-DDFLAGS_LDC=-fprofile-use=../pgo-ldc/merged.profdata "
60+
flags+="-DEXTRA_DFLAGS_LDC=-fprofile-use=../pgo-ldc/merged.profdata "
6161
cxx_flags+=(-fprofile-use=../pgo-ldc/merged.profdata)
6262
fi
6363

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ set(COMPILE_D_MODULES_SEPARATELY OFF CACHE BOOL "Compile each D module separatel
137137

138138
set(LDC_ENABLE_ASSERTIONS "${LLVM_ENABLE_ASSERTIONS}" CACHE BOOL "Enable LDC assertions. Defaults to the LLVM assertions mode; overriding may cause LDC segfaults!")
139139

140+
set(EXTRA_DFLAGS_LDC "" CACHE STRING "Extra D compiler flags for the ldc2 executable only, e.g., for PGO.")
141+
140142
# Allow user to specify mimalloc.o location, to be linked with `ldc2` only
141143
set(ALTERNATIVE_MALLOC_O "" CACHE STRING "If specified, adds ALTERNATIVE_MALLOC_O object file to LDC link, to override the CRT malloc.")
142144

@@ -677,7 +679,7 @@ build_d_executable(
677679
"${LDC_EXE}"
678680
"${LDC_EXE_FULL}"
679681
"${LDC_D_SOURCE_FILES}"
680-
"${DFLAGS_BUILD_TYPE} ${DFLAGS_LDC}"
682+
"${DFLAGS_BUILD_TYPE} ${DFLAGS_LDC} ${EXTRA_DFLAGS_LDC}"
681683
"${ALTERNATIVE_MALLOC_O};${LDC_LINKERFLAG_LIST}"
682684
"${FE_RES}"
683685
"${LDC_LIB}"

0 commit comments

Comments
 (0)