When BUILD_SHARED_LIBS is set, seastar inherits this setting from the
parent CMake project, causing crimson to link against libseastar.so.
While this works in development environments, it breaks package
installation because libseastar.so is not included in the distribution:
```
can't install ceph-crimson-osd:
- nothing provides libseastar.so()(64bit) needed by
ceph-crimson-osd-2:20.2.0-2.fc44.x86_64
can't install ceph-osd:
- nothing provides libseastar.so()(64bit) needed by
ceph-osd-2:20.2.0-2.fc44.x86_64
can't install ceph-test:
- nothing provides libseastar.so()(64bit) needed by
ceph-test-2:20.2.0-2.fc44.x86_64
```
Force seastar to build as a static library regardless of the parent
project's BUILD_SHARED_LIBS setting. This fixes the packaging issue
and provides a modest performance improvement by eliminating PLT/GOT
indirection overhead for seastar function calls.
Fixes: https://tracker.ceph.com/issues/74138
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
(cherry picked from commit
2cf8e4b095c8cdc3d583bcd570f8a5a5a27e459a)
build_dpdk(${CMAKE_BINARY_DIR}/src/dpdk)
endif()
endif()
+ set(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+ if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+ # - Debug: shared seastar for faster development iteration
+ # shared seastar is allowed for faster linking and smaller executables during
+ # development.
+ # Note: shared seastar won't be packaged, so this is for developers only
+ # - RelWithDebInfo/Release/MinSizeRel: static seastar for production packages
+ # This ensures packages don't depend on libseastar.so, and avoids the performance penalty
+ # of calling functions in shared library.
+ set(BUILD_SHARED_LIBS FALSE)
+ endif()
add_subdirectory(seastar)
+ set(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS})
+ unset(old_BUILD_SHARED_LIBS)
+
# create the directory so cmake won't complain when looking at the imported
# target: Seastar exports this directory created at build-time
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/seastar/gen/include")