From 066e9567eead43c6dcdfc24f4362c69efb6f1691 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 4 Apr 2023 12:29:12 +0800 Subject: [PATCH 1/4] build: cmake: use -O0 on aarch64, otherwise -Og this addresses an oversight in b234c839e49e0f68845956bf2214639a27e3fda2, which is supposed to mirror the behavior of `configure.py`. Signed-off-by: Kefu Chai --- cmake/mode.DEBUG.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/mode.DEBUG.cmake b/cmake/mode.DEBUG.cmake index 15683ad47f..b68fc64962 100644 --- a/cmake/mode.DEBUG.cmake +++ b/cmake/mode.DEBUG.cmake @@ -1,8 +1,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") # -fasan -Og breaks some coroutines on aarch64, use -O0 instead - set(default_Seastar_OptimizationLevel_DEBUG "g") -else() set(default_Seastar_OptimizationLevel_DEBUG "0") +else() + set(default_Seastar_OptimizationLevel_DEBUG "g") endif() set(Seastar_OptimizationLevel_DEBUG ${default_Seastar_OptimizationLevel_DEBUG} From 6cc8800c854f6f102ad0823ccf09373a0c956f17 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 4 Apr 2023 13:41:44 +0800 Subject: [PATCH 2/4] build: cmake: pass -fvisibility=hidden to compiler this mirrors the behavior of `configure.py`. Signed-off-by: Kefu Chai --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c69098a0b3..474764ff9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ include(limit_jobs) # Configure Seastar compile options to align with Scylla set(CMAKE_CXX_STANDARD "20" CACHE INTERNAL "") set(CMAKE_CXX_EXTENSIONS ON CACHE INTERNAL "") +set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(Seastar_TESTING ON CACHE BOOL "" FORCE) add_subdirectory(seastar) From ecd5bf98d9e5bcbe38cb19098b207408d3968840 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 4 Apr 2023 13:45:02 +0800 Subject: [PATCH 3/4] build: cmake: set stack frame limits * transpose include(mode.common) and include (mode.${build_mode}), so the former can reference the value defined by the latter. * set stack_usage_threshold for supported build modes. please note, this compiler option (-Wstack-usage=) is only supported by GCC so far. Signed-off-by: Kefu Chai --- CMakeLists.txt | 2 +- cmake/mode.DEBUG.cmake | 2 ++ cmake/mode.DEV.cmake | 2 ++ cmake/mode.RELEASE.cmake | 2 ++ cmake/mode.common.cmake | 7 +++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 474764ff9a..041bbf563a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,8 +14,8 @@ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Dev" "Sanitize") string(TOUPPER "${CMAKE_BUILD_TYPE}" build_mode) -include(mode.common) include(mode.${build_mode}) +include(mode.common) add_compile_definitions( ${Seastar_DEFINITIONS_${build_mode}} FMT_DEPRECATED_OSTREAM) diff --git a/cmake/mode.DEBUG.cmake b/cmake/mode.DEBUG.cmake index b68fc64962..cf69dd2f44 100644 --- a/cmake/mode.DEBUG.cmake +++ b/cmake/mode.DEBUG.cmake @@ -19,3 +19,5 @@ set(Seastar_DEFINITIONS_DEBUG set(CMAKE_CXX_FLAGS_DEBUG " -O${Seastar_OptimizationLevel_DEBUG} -g -gz") + +set(stack_usage_threshold_in_KB 40) diff --git a/cmake/mode.DEV.cmake b/cmake/mode.DEV.cmake index ec706ae228..ff7825a4d0 100644 --- a/cmake/mode.DEV.cmake +++ b/cmake/mode.DEV.cmake @@ -12,3 +12,5 @@ set(Seastar_DEFINITIONS_DEV DEVEL SEASTAR_ENABLE_ALLOC_FAILURE_INJECTION SCYLLA_ENABLE_ERROR_INJECTION) + +set(stack_usage_threshold_in_KB 21) diff --git a/cmake/mode.RELEASE.cmake b/cmake/mode.RELEASE.cmake index 2ae825e887..aa8a8f29b7 100644 --- a/cmake/mode.RELEASE.cmake +++ b/cmake/mode.RELEASE.cmake @@ -23,3 +23,5 @@ set(Seastar_DEFINITIONS_DEBUG set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "-Wl,--gc-sections") + +set(stack_usage_threshold_in_KB 13) diff --git a/cmake/mode.common.cmake b/cmake/mode.common.cmake index 076cf9f431..ec8c36cec7 100644 --- a/cmake/mode.common.cmake +++ b/cmake/mode.common.cmake @@ -30,3 +30,10 @@ 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() From dceb364c5c5a61c6d050e5c4db670286f87ef4c1 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 4 Apr 2023 14:36:10 +0800 Subject: [PATCH 4/4] build: cmake: include cxx.h with relative path before this change, the wasm binding source files includes the cxxbridge header file of `cxx.h` with its full path. to better mirror the behavior of configure.py, let's just include this header file with relative path. Signed-off-by: Kefu Chai --- rust/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rust/CMakeLists.txt b/rust/CMakeLists.txt index 0a916c5c4f..21a71f69e8 100644 --- a/rust/CMakeLists.txt +++ b/rust/CMakeLists.txt @@ -40,7 +40,7 @@ function(generate_cxxbridge name) set(outputs ${header} ${source}) set(command ${CXXBRIDGE} ${input} --include ${parsed_args_INCLUDE}) add_custom_command( - DEPENDS ${input} ${include} + DEPENDS ${input} OUTPUT ${outputs} COMMAND ${command} --header --output ${header} COMMAND ${command} --output ${source}) @@ -59,7 +59,7 @@ add_custom_command( COMMAND ${CXXBRIDGE} --header --output ${cxx_header}) generate_cxxbridge(wasmtime_bindings INPUT wasmtime_bindings/src/lib.rs - INCLUDE ${cxx_header} + INCLUDE rust/cxx.h OUTPUT_DIR "${binding_gen_build_dir}" SOURCES wasmtime_bindings_sources) @@ -72,7 +72,7 @@ target_sources(wasmtime_bindings ${cxx_header} ${wasmtime_bindings_sources}) target_include_directories(wasmtime_bindings - INTERFACE + PUBLIC ${scylla_gen_build_dir}) target_link_libraries(wasmtime_bindings INTERFACE Rust::rust_combined) @@ -80,7 +80,7 @@ target_link_libraries(wasmtime_bindings # only for testing generate_cxxbridge(inc INPUT inc/src/lib.rs - INCLUDE ${cxx_header} + INCLUDE rust/cxx.h OUTPUT_DIR "${binding_gen_build_dir}" SOURCES inc_sources) @@ -90,7 +90,7 @@ target_sources(inc ${cxx_header} ${inc_sources}) target_include_directories(inc - INTERFACE + PUBLIC ${scylla_gen_build_dir}) target_link_libraries(inc INTERFACE Rust::rust_combined)