Files
scylladb/cmake/mode.common.cmake
Kefu Chai 56f68bcf1b build: cmake: compare CMAKE_SYSTEM_PROCESSOR using STREQUAL operator
`if (.. EQUAL ..)` is used to compare numbers so if the LHS is not
a number the condition is evaluated as false, this prevents us from
setting the -march when building for aarch64 targets. and because
crc32 implementation in utils/ always use the crypto extension
intrinsics, this also breaks the build like
```
In file included from /home/fedora/scylla/utils/gz/crc_combine.cc:40:
/home/fedora/scylla/utils/clmul.hh:60:12: error: always_inline function 'vmull_p64' requires target feature 'aes', but would be inlined into functi
on 'clmul_u32' that is compiled without support for 'aes'
    return vmull_p64(p1, p2);
           ^
```

so, in this change,

* compare two strings using `STREQUAL`.
* document the reason why we need to set the -march to the
  specfied argument.
  see also http://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#g_t-march-and--mcpu-Feature-Modifiers

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#15553
2023-09-27 13:58:51 +02:00

48 lines
1.7 KiB
CMake

set(disabled_warnings
c++11-narrowing
mismatched-tags
overloaded-virtual
unsupported-friend)
include(CheckCXXCompilerFlag)
foreach(warning ${disabled_warnings})
check_cxx_compiler_flag("-Wno-${warning}" _warning_supported_${warning})
if(_warning_supported_${warning})
list(APPEND _supported_warnings ${warning})
endif()
endforeach()
list(TRANSFORM _supported_warnings PREPEND "-Wno-")
string(JOIN " " CMAKE_CXX_FLAGS
"-Wall"
"-Werror"
"-Wno-error=deprecated-declarations"
"-Wimplicit-fallthrough"
${_supported_warnings})
function(default_target_arch arch)
set(x86_instruction_sets i386 i686 x86_64)
if(CMAKE_SYSTEM_PROCESSOR IN_LIST x86_instruction_sets)
set(${arch} "westmere" PARENT_SCOPE)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
# we always use intrinsics like vmull.p64 for speeding up crc32 calculations
# on the aarch64 architectures, and they require the crypto extension, so
# we have to add "+crypto" in the architecture flags passed to -march. the
# same applies to crc32 instructions, which need the ARMv8-A CRC32 extension
# please note, Seastar also sets -march when compiled with DPDK enabled.
set(${arch} "armv8-a+crc+crypto" PARENT_SCOPE)
else()
set(${arch} "" PARENT_SCOPE)
endif()
endfunction()
default_target_arch(target_arch)
if(target_arch)
string(APPEND CMAKE_CXX_FLAGS " -march=${target_arch}")
endif()
math(EXPR _stack_usage_threshold_in_bytes "${stack_usage_threshold_in_KB} * 1024")
set(_stack_usage_threshold_flag "-Wstack-usage=${_stack_usage_threshold_in_bytes}")
check_cxx_compiler_flag(${_stack_usage_threshold_flag} _stack_usage_flag_supported)
if(_stack_usage_flag_supported)
string(APPEND CMAKE_CXX_FLAGS " ${_stack_usage_threshold_flag}")
endif()