Skip to content

Commit e6206ce

Browse files
authored
Merge pull request #225 from FeignClaims/fix/disable_stack_clash_protection_on_m1
2 parents 999c559 + c27cb7c commit e6206ce

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/Hardening.cmake

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ function(
1919
endif()
2020

2121
if(${ENABLE_STACK_PROTECTION})
22-
list(APPEND HARDENING_COMPILE_OPTIONS -fstack-protector-strong -fstack-clash-protection)
22+
set(_enable_stack_clash_protection TRUE)
23+
if (APPLE)
24+
# `-fstack-clash-protection` dosen't work on MacOS M1 with clang
25+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
26+
set(_enable_stack_clash_protection FALSE)
27+
endif()
28+
endif()
29+
30+
if (_enable_stack_clash_protection)
31+
list(APPEND HARDENING_COMPILE_OPTIONS -fstack-clash-protection)
32+
endif()
33+
34+
list(APPEND HARDENING_COMPILE_OPTIONS -fstack-protector-strong)
2335
endif()
2436

2537
if(${ENABLE_OVERFLOW_PROTECTION})

0 commit comments

Comments
 (0)