Skip to content

Commit 9817ee8

Browse files
committed
Respect aarch64 -march=|-mcpu= flag and check whether -mcpu=native works
Packagers may specify a target system up front, which should be respected. The CRC extensions are not strictly necessary as there is a software fallback. Otherwise, use -mcpu=native if it works (it won't when cross-compiling) or -mcpu=generic+crc. Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
1 parent de68119 commit 9817ee8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/overlaybd/zfile/CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ target_include_directories(crc32_lib PUBLIC
1111
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
1212
target_compile_options(crc32_lib PUBLIC -msse4.2 -mcrc32)
1313
else()
14-
target_compile_options(crc32_lib PRIVATE -march=native -mcpu=generic+crc)
14+
if (NOT CMAKE_CXX_FLAGS MATCHES "-march=|-mcpu=")
15+
check_cxx_compiler_flag(-mcpu=native COMPILER_HAS_NATIVE_FLAG)
16+
if (COMPILER_HAS_NATIVE_FLAG)
17+
target_compile_options(crc32_lib PRIVATE -mcpu=native)
18+
else ()
19+
target_compile_options(crc32_lib PRIVATE -mcpu=generic+crc)
20+
endif ()
21+
endif ()
1522
endif()
1623

1724
if(ENABLE_DSA OR ENABLE_ISAL)

0 commit comments

Comments
 (0)