Skip to content

Commit 19ef223

Browse files
committed
build: cmake: sdl: check for endbr64
1 parent 262fb02 commit 19ef223

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cmake/SDL.cmake

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ macro(sdl_gnu_common_ccxx_flags var gnu_version)
3636
else()
3737
append(${var} "-fstack-protector-strong")
3838
if(NOT (${gnu_version} VERSION_LESS 8.0) AND (DNNL_TARGET_ARCH STREQUAL "X64"))
39-
append(${var} "-fcf-protection=full")
39+
check_toolchain_for_endbr64()
40+
if(ENDBR64_SUPPORT_FLAG)
41+
append(${var} "-fcf-protection=full")
42+
endif()
4043
endif()
4144
endif()
4245
endmacro()

cmake/utils.cmake

+5
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,8 @@ function(find_libm var)
174174
find_library(${var} m REQUIRED)
175175
endif()
176176
endfunction()
177+
178+
include(CheckCXXSourceCompiles)
179+
function(check_toolchain_for_endbr64)
180+
check_cxx_source_compiles("int main() { asm volatile(\"endbr64\"); return 0; }" ENDBR64_SUPPORT_FLAG)
181+
endfunction()

0 commit comments

Comments
 (0)