Skip to content

Commit

Permalink
Merge 'build: support enabled options when building seastar-module' f…
Browse files Browse the repository at this point in the history
…rom Kefu Chai

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 series we

* move `add_subdirectory(src)` down
* `#include` the used header files
* 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 scylladb#2249

Closes scylladb#2252

* github.com:scylladb/seastar:
  build: support enabled options when building seastar-module
  treewide: include required header files
  build: move add_subdirectory(src) down
  • Loading branch information
avikivity committed May 19, 2024
2 parents 397f1de + 8005611 commit 855fc4b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
#
Expand Down
15 changes: 14 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ target_compile_definitions (seastar-module
SEASTAR_API_LEVEL=${Seastar_API_LEVEL}
SEASTAR_SCHEDULING_GROUPS_COUNT=${Seastar_SCHEDULING_GROUPS_COUNT}
PRIVATE
SEASTAR_MODULE)
SEASTAR_MODULE
${Seastar_PRIVATE_COMPILE_DEFINITIONS})
target_compile_options (seastar-module
PUBLIC
-U_FORTIFY_SOURCE)
Expand Down Expand Up @@ -125,6 +126,18 @@ target_link_libraries (seastar-module
yaml-cpp::yaml-cpp
"$<BUILD_INTERFACE:Valgrind::valgrind>"
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
Expand Down
1 change: 1 addition & 0 deletions src/core/reactor_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module;
#include <sys/syscall.h>
#include <sys/resource.h>
#include <boost/container/small_vector.hpp>
#include <fmt/core.h>

#ifdef SEASTAR_HAVE_URING
#include <liburing.h>
Expand Down
8 changes: 4 additions & 4 deletions src/core/resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ module;
#include <limits>
#include <filesystem>
#include <unordered_map>
#include <fmt/core.h>
#if SEASTAR_HAVE_HWLOC
#include <hwloc/glibc-sched.h>
#endif

#ifdef SEASTAR_MODULE
module seastar;
Expand All @@ -49,10 +53,6 @@ module seastar;
#include <seastar/core/print.hh>
#include "cgroup.hh"

#if SEASTAR_HAVE_HWLOC
#include <hwloc/glibc-sched.h>
#endif

#endif

namespace seastar {
Expand Down
4 changes: 3 additions & 1 deletion src/seastar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ module;
#include <fmt/ostream.h>
#include <fmt/printf.h>
#include <gnutls/crypto.h>

#ifdef SEASTAR_HAVE_HWLOC
#include <hwloc.h>
#endif
#if defined(__x86_64__) || defined(__i386__)
#include <xmmintrin.h>
#endif
Expand Down

0 comments on commit 855fc4b

Please sign in to comment.