From 4054d81298550c5fc94ac351a5f58b4208991ed7 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 19 May 2024 11:51:47 +0800 Subject: [PATCH 1/3] build: move add_subdirectory(src) down so we can have access to the Seastar_PRIVATE_CXX_FLAGS when defining the `seastar-module` target. we will do this in another commit. Signed-off-by: Kefu Chai --- CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08abba8a10b..07d4880fa9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -877,13 +877,6 @@ endif () set( MEMORYCHECK_COMMAND_OPTIONS "--error-exitcode=1 --leak-check=no --trace-children=yes" ) include (CTest) -if (Seastar_MODULE) - if (POLICY CMP0155) - cmake_policy (SET CMP0155 NEW) - endif () - include (CxxModulesRules) - add_subdirectory (src) -endif () # # We want asserts enabled on all modes, but cmake defaults to passing # -DNDEBUG in some modes. We add -UNDEBUG to our private options to @@ -1184,6 +1177,14 @@ if (Seastar_INSTALL OR Seastar_TESTING) endif () +if (Seastar_MODULE) + if (POLICY CMP0155) + cmake_policy (SET CMP0155 NEW) + endif () + include (CxxModulesRules) + add_subdirectory (src) +endif () + # # The tests themselves. # From bc2f324396762916bc9a3dbfdbe77e8f7b20e149 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 19 May 2024 12:13:05 +0800 Subject: [PATCH 2/3] treewide: include required header files before this change, when building with C++20 modules enabled, some symbols are not accessible, when compiling source files like src/core/resource.cc if some features are enabled using macros like SEASTAR_HAVE_HWLOC and SEASTAR_HAVE_URING. in this change, we include the missing headers or move the include precessor directives, so that the .cc files can have access to the used declaration of the used symbols. please note, this change not only enables us to build C++20 modules with SEASTAR_HAVE_HWLOC and/or SEASTAR_HAVE_URING defined, it is also necessary also from the correctness point of view. Signed-off-by: Kefu Chai --- src/core/reactor_backend.cc | 1 + src/core/resource.cc | 8 ++++---- src/seastar.cc | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core/reactor_backend.cc b/src/core/reactor_backend.cc index 123d4e0c1c0..b0dc1be9fdc 100644 --- a/src/core/reactor_backend.cc +++ b/src/core/reactor_backend.cc @@ -36,6 +36,7 @@ module; #include #include #include +#include #ifdef SEASTAR_HAVE_URING #include diff --git a/src/core/resource.cc b/src/core/resource.cc index 70294f488e7..7dc64163a49 100644 --- a/src/core/resource.cc +++ b/src/core/resource.cc @@ -35,6 +35,10 @@ module; #include #include #include +#include +#if SEASTAR_HAVE_HWLOC +#include +#endif #ifdef SEASTAR_MODULE module seastar; @@ -49,10 +53,6 @@ module seastar; #include #include "cgroup.hh" -#if SEASTAR_HAVE_HWLOC -#include -#endif - #endif namespace seastar { diff --git a/src/seastar.cc b/src/seastar.cc index 416faa97c75..8e16732ad6c 100644 --- a/src/seastar.cc +++ b/src/seastar.cc @@ -118,7 +118,9 @@ module; #include #include #include - +#ifdef SEASTAR_HAVE_HWLOC +#include +#endif #if defined(__x86_64__) || defined(__i386__) #include #endif From 8005611475075f3e8fdad387d6228f1f3403af40 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 19 May 2024 11:58:53 +0800 Subject: [PATCH 3/3] build: support enabled options when building seastar-module before this change, when building seastar-module, we don't check for the enabled features. so, for instance io uring backend is not enabled even `Seastar_IO_URING` is set. in this change we * check for the enabled options, * link against the related libraries, and * add the required macro definitions this should enable seastar-module to build with, for instance, io_uring backend enabled. as `SEASTAR_HAVE_URING` enables this backend when building `src/core/reactor_backend.cc`. Fixes #2249 Signed-off-by: Kefu Chai --- src/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8848782c5ca..b99ebb19b6d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -96,7 +96,8 @@ target_compile_definitions (seastar-module SEASTAR_SCHEDULING_GROUPS_COUNT=${Seastar_SCHEDULING_GROUPS_COUNT} SEASTAR_COROUTINES_ENABLED PRIVATE - SEASTAR_MODULE) + SEASTAR_MODULE + ${Seastar_PRIVATE_COMPILE_DEFINITIONS}) target_compile_options (seastar-module PUBLIC -U_FORTIFY_SOURCE) @@ -126,6 +127,18 @@ target_link_libraries (seastar-module yaml-cpp::yaml-cpp "$" Threads::Threads) +if (Seastar_NUMA) + target_link_libraries (seastar-module + PRIVATE numactl::numactl) +endif () +if (Seastar_HWLOC) + target_link_libraries (seastar-module + PRIVATE hwloc::hwloc) +endif () +if (Seastar_IO_URING) + target_link_libraries (seastar-module + PRIVATE URING::uring) +endif () install ( TARGETS seastar-module