Skip to content

Commit f455832

Browse files
authored
Merge pull request #2205 from kbenzie/benie/check-fstack-clash-protection
Check if compiler supports -fstack-clash-protection
2 parents bb28fc6 + 879bf9a commit f455832

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cmake/helpers.cmake

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ macro(add_sanitizer_flag flag)
5858
set(CMAKE_REQUIRED_LIBRARIES ${SAVED_CMAKE_REQUIRED_LIBRARIES})
5959
endmacro()
6060

61-
check_cxx_compiler_flag("-fcf-protection=full" CXX_HAS_FCF_PROTECTION_FULL)
61+
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
62+
check_cxx_compiler_flag("-fcf-protection=full" CXX_HAS_FCF_PROTECTION_FULL)
63+
check_cxx_compiler_flag("-fstack-clash-protection" CXX_HAS_FSTACK_CLASH_PROTECTION)
64+
endif()
6265

6366
function(add_ur_target_compile_options name)
6467
if(NOT MSVC)
@@ -81,9 +84,7 @@ function(add_ur_target_compile_options name)
8184
# -flto
8285
# $<$<CXX_COMPILER_ID:Clang,AppleClang>:-fsanitize=cfi>
8386
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
84-
# -fstack-clash-protection is not supported in apple clang or GCC < 8
85-
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,8>>:-fstack-clash-protection>
86-
$<$<CXX_COMPILER_ID:Clang>:-fstack-clash-protection>
87+
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>
8788

8889
# Colored output
8990
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>

0 commit comments

Comments
 (0)