Skip to content

Commit 7815ae3

Browse files
hawkinswarichardson
authored andcommitted
[llvm][CMake] Respect LIBCXX_HARDENING_MODE on command-line (#68541)
When the user specifies `LIBCXX_HARDENING_MODE` on the command line in a bootstrapping build, it should override the setting implied by `LLVM_ENABLE_ASSERTIONS`. (cherry picked from commit 4aae538)
1 parent 5e84b5c commit 7815ae3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ if( LLVM_ENABLE_ASSERTIONS )
8585
endif()
8686
# Enable assertions in libstdc++.
8787
add_compile_definitions(_GLIBCXX_ASSERTIONS)
88-
# Enable the hardened mode in libc++.
89-
add_compile_definitions(_LIBCPP_ENABLE_HARDENED_MODE)
88+
# Cautiously enable the safe hardened mode in libc++.
89+
if((DEFINED LIBCXX_HARDENING_MODE) AND
90+
(NOT LIBCXX_HARDENING_MODE STREQUAL "safe"))
91+
message(WARNING "LLVM_ENABLE_ASSERTIONS implies LIBCXX_HARDENING_MODE \"safe\" but is overriden from command line with value \"${LIBCXX_HARDENING_MODE}\".")
92+
else()
93+
set(LIBCXX_HARDENING_MODE "safe")
94+
endif()
9095
endif()
9196

9297
if(LLVM_ENABLE_EXPENSIVE_CHECKS)

0 commit comments

Comments
 (0)