Skip to content

Commit

Permalink
Check if compiler supports -fstack-clash-protection
Browse files Browse the repository at this point in the history
Similar to #2202, check if the host compiler supports the
`-fstack-clash-protection` flag rather than using version ranges.
  • Loading branch information
kbenzie committed Oct 17, 2024
1 parent d68fc55 commit dbc3ff8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ macro(add_sanitizer_flag flag)
endmacro()

check_cxx_compiler_flag("-fcf-protection=full" CXX_HAS_FCF_PROTECTION_FULL)
check_cxx_compiler_flag("-fstack-clash-protection" CXX_HAS_FSTACK_CLASH_PROTECTION)

function(add_ur_target_compile_options name)
if(NOT MSVC)
Expand All @@ -81,9 +82,7 @@ function(add_ur_target_compile_options name)
# -flto
# $<$<CXX_COMPILER_ID:Clang,AppleClang>:-fsanitize=cfi>
$<$<BOOL:${CXX_HAS_FCF_PROTECTION_FULL}>:-fcf-protection=full>
# -fstack-clash-protection is not supported in apple clang or GCC < 8
$<$<AND:$<CXX_COMPILER_ID:GNU>,$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,8>>:-fstack-clash-protection>
$<$<CXX_COMPILER_ID:Clang>:-fstack-clash-protection>
$<$<BOOL:${CXX_HAS_FSTACK_CLASH_PROTECTION}>:-fstack-clash-protection>

# Colored output
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
Expand Down

0 comments on commit dbc3ff8

Please sign in to comment.