Files
scylladb/cmake/mode.Debug.cmake
Kefu Chai 4f361b73c4 build: cmake: consolidate the setting of cxx_flags
before this change, we define the CMAKE_CXX_FLAGS_${CONFIG} directly.
and some of the configurations are supposed to generate debugging info with
"-g -gz" options, but they failed to include these options in the cxx
flags.

in this change:

* a macro named `update_cxx_flags` is introduced to set this option.
* this macro also sets -O option

instead of using function, this facility is implemented as a macro so
that we can update the CMAKE_CXX_FLAGS_${CONFIG} without setting
this variable with awkward syntax like set

```cmake
set(${flags} "${${flags}}" PARENT_SCOPE)
```

this mirrors the behavior in configure.py in sense that the latter
sets the option on a per-mode basis, and interprets the option to
compiling option.

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

Closes scylladb/scylladb#16043
2023-11-14 11:21:52 +02:00

29 lines
748 B
CMake

if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# -fasan -Og breaks some coroutines on aarch64, use -O0 instead
set(default_Seastar_OptimizationLevel_DEBUG "0")
else()
set(default_Seastar_OptimizationLevel_DEBUG "g")
endif()
set(Seastar_OptimizationLevel_DEBUG
${default_Seastar_OptimizationLevel_DEBUG}
CACHE
INTERNAL
"")
set(Seastar_DEFINITIONS_DEBUG
SCYLLA_BUILD_MODE=debug
DEBUG
SANITIZE
DEBUG_LSA_SANITIZER
SCYLLA_ENABLE_ERROR_INJECTION)
foreach(definition ${Seastar_DEFINITIONS_DEBUG})
add_compile_definitions(
$<$<CONFIG:Debug>:${definition}>)
endforeach()
update_cxx_flags(CMAKE_CXX_FLAGS_DEBUG
WITH_DEBUG_INFO
OPTIMIZATION_LEVEL ${Seastar_OptimizationLevel_DEBUG})
maybe_limit_stack_usage_in_KB(40 Debug)