Skip to content

Commit 29b7295

Browse files
[clang][cmake] Sanitize CLANG_BOLT values (llvm#126768)
This avoids failing later in the build process.
1 parent c1b7037 commit 29b7295

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

clang/tools/driver/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ if(CLANG_PLUGIN_SUPPORT)
2323
set(support_plugins SUPPORT_PLUGINS)
2424
endif()
2525

26+
set(CLANG_BOLT_ALLOWLIST INSTRUMENT PERF LBR)
2627
set(CLANG_BOLT OFF CACHE STRING "Apply BOLT optimization to Clang. \
27-
May be specified as Instrument or Perf or LBR to use a particular profiling \
28+
May be specified as one of ${CLANG_BOLT_ALLOWLIST} to use a particular profiling \
2829
mechanism.")
2930
string(TOUPPER "${CLANG_BOLT}" CLANG_BOLT)
31+
if (CLANG_BOLT AND NOT CLANG_BOLT IN_LIST CLANG_BOLT_ALLOWLIST)
32+
message(FATAL_ERROR "Specified CLANG_BOLT value '${CLANG_BOLT}' is not one of ${CLANG_BOLT_ALLOWLIST}.")
33+
endif()
3034

3135
if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
3236
set(CLANG_BOLT_DEPS clear-bolt-fdata llvm-bolt llvm-readobj)

0 commit comments

Comments
 (0)