Skip to content

Commit 4aae538

Browse files
authored
[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`.
1 parent d36ddaa commit 4aae538

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
@@ -111,8 +111,13 @@ if( LLVM_ENABLE_ASSERTIONS )
111111
endif()
112112
# Enable assertions in libstdc++.
113113
add_compile_definitions(_GLIBCXX_ASSERTIONS)
114-
# Enable the hardened mode in libc++.
115-
add_compile_definitions(_LIBCPP_ENABLE_HARDENED_MODE)
114+
# Cautiously enable the safe hardened mode in libc++.
115+
if((DEFINED LIBCXX_HARDENING_MODE) AND
116+
(NOT LIBCXX_HARDENING_MODE STREQUAL "safe"))
117+
message(WARNING "LLVM_ENABLE_ASSERTIONS implies LIBCXX_HARDENING_MODE \"safe\" but is overriden from command line with value \"${LIBCXX_HARDENING_MODE}\".")
118+
else()
119+
set(LIBCXX_HARDENING_MODE "safe")
120+
endif()
116121
endif()
117122

118123
if(LLVM_ENABLE_EXPENSIVE_CHECKS)

0 commit comments

Comments
 (0)