From 5e51bc4463605adcbe6c8342063f4426c9754347 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 27 Apr 2024 19:58:26 +0800 Subject: [PATCH] cmake: targets against legacy-option-headers when appropriate legacy-option-headers provides the headers included by `src/common/options/legacy_config_opts.h`. these headers are generated from corresponding .yaml.in file. because these headers file are generated at build time, we need to construct the file-level dependencies between the targets using them and these headers, otherwise the compiler could fail to compile the tree if any of the headers are not generated yet, when compiling .cc file which (indirectly) includes it. in order to address this, in this change, we 1. search for all .cc files which have `#include "common/config.h"` in it 2. and find out the targets building the .cc file, then 3. add `legacy-option-headers` to its linkage using CMake this should partially address the above race condition we've been running into on slow build hosts. because we have not audited the .h files including `common/config.h`, this change should be considered a partial fix. Signed-off-by: Kefu Chai --- src/client/CMakeLists.txt | 4 +++- src/compressor/lz4/CMakeLists.txt | 4 +++- src/compressor/snappy/CMakeLists.txt | 4 +++- src/crimson/osd/CMakeLists.txt | 1 + src/dokan/CMakeLists.txt | 1 + src/librados/CMakeLists.txt | 3 ++- src/mds/CMakeLists.txt | 1 + src/mon/CMakeLists.txt | 1 + src/msg/CMakeLists.txt | 3 +++ src/os/CMakeLists.txt | 4 +++- src/osd/CMakeLists.txt | 4 +++- src/rgw/CMakeLists.txt | 11 +++++++++-- src/tools/CMakeLists.txt | 8 ++++++-- src/tools/cephfs/CMakeLists.txt | 8 ++++++-- src/tools/immutable_object_cache/CMakeLists.txt | 1 + src/tools/rbd_mirror/CMakeLists.txt | 1 + src/tools/rbd_wnbd/CMakeLists.txt | 4 +++- 17 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 8897ada7b59..ddc77c66147 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -10,4 +10,6 @@ set(libclient_srcs posix_acl.cc Delegation.cc) add_library(client STATIC ${libclient_srcs}) -target_link_libraries(client osdc) +target_link_libraries(client + legacy-option-headers + osdc) diff --git a/src/compressor/lz4/CMakeLists.txt b/src/compressor/lz4/CMakeLists.txt index 316493435aa..689baa37525 100644 --- a/src/compressor/lz4/CMakeLists.txt +++ b/src/compressor/lz4/CMakeLists.txt @@ -7,7 +7,9 @@ set(lz4_sources add_library(ceph_lz4 SHARED ${lz4_sources}) target_link_libraries(ceph_lz4 - PRIVATE LZ4::LZ4 compressor $<$:ceph-common>) + PRIVATE + legacy-option-headers + LZ4::LZ4 compressor $<$:ceph-common>) if(HAVE_QATZIP AND HAVE_QAT) target_link_libraries(ceph_lz4 PRIVATE qat_compressor) endif() diff --git a/src/compressor/snappy/CMakeLists.txt b/src/compressor/snappy/CMakeLists.txt index d1ba3b2e746..5f12f6a806d 100644 --- a/src/compressor/snappy/CMakeLists.txt +++ b/src/compressor/snappy/CMakeLists.txt @@ -6,7 +6,9 @@ set(snappy_sources add_library(ceph_snappy SHARED ${snappy_sources}) target_link_libraries(ceph_snappy - PRIVATE snappy::snappy compressor $<$:ceph-common>) + PRIVATE + legacy-option-headers + snappy::snappy compressor $<$:ceph-common>) set_target_properties(ceph_snappy PROPERTIES VERSION 2.0.0 SOVERSION 2 diff --git a/src/crimson/osd/CMakeLists.txt b/src/crimson/osd/CMakeLists.txt index c77da7575a5..50011adbcec 100644 --- a/src/crimson/osd/CMakeLists.txt +++ b/src/crimson/osd/CMakeLists.txt @@ -63,6 +63,7 @@ if(HAS_VTA) PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments) endif() target_link_libraries(crimson-osd + legacy-option-headers crimson-admin crimson-common crimson-os diff --git a/src/dokan/CMakeLists.txt b/src/dokan/CMakeLists.txt index 2a61d38bb8d..90e2e1a7be9 100644 --- a/src/dokan/CMakeLists.txt +++ b/src/dokan/CMakeLists.txt @@ -7,6 +7,7 @@ set(ceph_dokan_srcs add_executable(ceph-dokan ${ceph_dokan_srcs}) target_link_libraries(ceph-dokan ${DOKAN_LIBRARIES} ${GSSAPI_LIBRARIES} + legacy-option-headers cephfs ceph-common global ${EXTRALIBS}) set_target_properties(ceph-dokan PROPERTIES COMPILE_FLAGS "-I${DOKAN_INCLUDE_DIRS}") diff --git a/src/librados/CMakeLists.txt b/src/librados/CMakeLists.txt index 9e469eb17ff..e464a2fe633 100644 --- a/src/librados/CMakeLists.txt +++ b/src/librados/CMakeLists.txt @@ -4,7 +4,8 @@ add_library(librados_impl STATIC RadosClient.cc librados_util.cc librados_tp.cc) - +target_link_libraries(librados_impl + PRIVATE legacy-option-headers) # C/C++ API add_library(librados ${CEPH_SHARED} librados_c.cc diff --git a/src/mds/CMakeLists.txt b/src/mds/CMakeLists.txt index 0c6c31a3c51..ffa9dc28d8a 100644 --- a/src/mds/CMakeLists.txt +++ b/src/mds/CMakeLists.txt @@ -52,5 +52,6 @@ set(mds_srcs ${CMAKE_SOURCE_DIR}/src/mgr/MDSPerfMetricTypes.cc) add_library(mds STATIC ${mds_srcs}) target_link_libraries(mds PRIVATE + legacy-option-headers heap_profiler cpu_profiler osdc ${LUA_LIBRARIES}) target_include_directories(mds PRIVATE "${LUA_INCLUDE_DIR}") diff --git a/src/mon/CMakeLists.txt b/src/mon/CMakeLists.txt index 3f2b8605344..4019f854c99 100644 --- a/src/mon/CMakeLists.txt +++ b/src/mon/CMakeLists.txt @@ -38,6 +38,7 @@ endif() add_library(mon STATIC ${lib_mon_srcs}) target_link_libraries(mon + legacy-option-headers kv heap_profiler ${FMT_LIB}) diff --git a/src/msg/CMakeLists.txt b/src/msg/CMakeLists.txt index ff2d47276f2..20c2b9ff430 100644 --- a/src/msg/CMakeLists.txt +++ b/src/msg/CMakeLists.txt @@ -48,6 +48,9 @@ add_library(common-msg-objs OBJECT ${msg_srcs}) target_compile_definitions(common-msg-objs PRIVATE $) target_include_directories(common-msg-objs PRIVATE ${OPENSSL_INCLUDE_DIR}) +target_link_libraries(common-msg-objs + PUBLIC + legacy-option-headers) if(WITH_DPDK) set(async_dpdk_srcs diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index 1cd85d3b213..a27b64688d8 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -47,7 +47,9 @@ if(HAVE_LIBZFS) endif() add_library(os STATIC ${libos_srcs}) -target_link_libraries(os blk) +target_link_libraries(os + legacy-option-headers + blk) target_link_libraries(os heap_profiler kv) diff --git a/src/osd/CMakeLists.txt b/src/osd/CMakeLists.txt index 5f1e96573c3..56cfc8b8210 100644 --- a/src/osd/CMakeLists.txt +++ b/src/osd/CMakeLists.txt @@ -58,7 +58,9 @@ endif() add_library(osd STATIC ${osd_srcs}) target_link_libraries(osd PUBLIC dmclock::dmclock Boost::MPL - PRIVATE os heap_profiler cpu_profiler ${FMT_LIB} ${CMAKE_DL_LIBS}) + PRIVATE + legacy-option-headers + os heap_profiler cpu_profiler ${FMT_LIB} ${CMAKE_DL_LIBS}) if(WITH_LTTNG) add_dependencies(osd osd-tp pg-tp) endif() diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index cf214b39c95..bc0af9c8716 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -275,6 +275,7 @@ endif() target_link_libraries(rgw_common PRIVATE + legacy-option-headers global cls_2pc_queue_client cls_cmpomap_client @@ -426,6 +427,7 @@ endif() target_link_libraries(rgw_a PRIVATE + legacy-option-headers common_utf8 global ${CRYPTO_LIBS} ${ARROW_LIBRARIES} @@ -474,6 +476,7 @@ target_include_directories(radosgw target_include_directories(radosgw SYSTEM PUBLIC "../rapidjson/include") target_link_libraries(radosgw PRIVATE + legacy-option-headers ${rgw_libs} rgw_schedulers kmip @@ -493,7 +496,9 @@ if(WITH_RADOSGW_ARROW_FLIGHT) endif(WITH_RADOSGW_ARROW_FLIGHT) add_executable(radosgw-admin ${radosgw_admin_srcs}) -target_link_libraries(radosgw-admin ${rgw_libs} librados +target_link_libraries(radosgw-admin + legacy-option-headers + ${rgw_libs} librados cls_rgw_client cls_otp_client cls_lock_client cls_refcount_client cls_log_client cls_timeindex_client cls_version_client cls_user_client @@ -523,7 +528,9 @@ install(TARGETS radosgw-es DESTINATION bin) set(radosgw_token_srcs rgw_token.cc) add_executable(radosgw-token ${radosgw_token_srcs}) -target_link_libraries(radosgw-token librados +target_link_libraries(radosgw-token + legacy-option-headers + librados global) install(TARGETS radosgw-token DESTINATION bin) diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index 92fd41f1cd1..0d6acc6a0c6 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -78,7 +78,9 @@ endif(WITH_LIBCEPHFS) add_executable(ceph-kvstore-tool kvstore_tool.cc ceph_kvstore_tool.cc) -target_link_libraries(ceph-kvstore-tool os global) +target_link_libraries(ceph-kvstore-tool + legacy-option-headers + os global) install(TARGETS ceph-kvstore-tool DESTINATION bin) set(ceph_conf_srcs ceph_conf.cc) @@ -88,7 +90,9 @@ install(TARGETS ceph-conf DESTINATION bin) set(crushtool_srcs crushtool.cc) add_executable(crushtool ${crushtool_srcs}) -target_link_libraries(crushtool global) +target_link_libraries(crushtool + legacy-option-headers + global) install(TARGETS crushtool DESTINATION bin) set(monmaptool_srcs monmaptool.cc) diff --git a/src/tools/cephfs/CMakeLists.txt b/src/tools/cephfs/CMakeLists.txt index 5d40f8ffb17..6bac749a6bc 100644 --- a/src/tools/cephfs/CMakeLists.txt +++ b/src/tools/cephfs/CMakeLists.txt @@ -9,7 +9,9 @@ set(cephfs_journal_tool_srcs RoleSelector.cc MDSUtility.cc) add_executable(cephfs-journal-tool ${cephfs_journal_tool_srcs}) -target_link_libraries(cephfs-journal-tool librados mds osdc global +target_link_libraries(cephfs-journal-tool + legacy-option-headers + librados mds osdc global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) set(cephfs-meta-injection_srcs @@ -18,7 +20,9 @@ set(cephfs-meta-injection_srcs RoleSelector.cc MDSUtility.cc) add_executable(cephfs-meta-injection ${cephfs-meta-injection_srcs}) -target_link_libraries(cephfs-meta-injection librados mds osdc global +target_link_libraries(cephfs-meta-injection + legacy-option-headers + librados mds osdc global ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS}) set(cephfs_table_tool_srcs diff --git a/src/tools/immutable_object_cache/CMakeLists.txt b/src/tools/immutable_object_cache/CMakeLists.txt index ed118ed6fba..91dea37b328 100644 --- a/src/tools/immutable_object_cache/CMakeLists.txt +++ b/src/tools/immutable_object_cache/CMakeLists.txt @@ -12,6 +12,7 @@ add_library(ceph_immutable_object_cache_lib STATIC ${ceph_immutable_object_cache add_executable(ceph-immutable-object-cache main.cc) target_link_libraries(ceph-immutable-object-cache + legacy-option-headers ceph_immutable_object_cache_lib librados StdFilesystem::filesystem diff --git a/src/tools/rbd_mirror/CMakeLists.txt b/src/tools/rbd_mirror/CMakeLists.txt index 43a6f03fe96..42a8fcc1886 100644 --- a/src/tools/rbd_mirror/CMakeLists.txt +++ b/src/tools/rbd_mirror/CMakeLists.txt @@ -71,6 +71,7 @@ add_library(rbd_mirror_internal STATIC add_executable(rbd-mirror main.cc) target_link_libraries(rbd-mirror + legacy-option-headers rbd_mirror_internal rbd_mirror_types rbd_api diff --git a/src/tools/rbd_wnbd/CMakeLists.txt b/src/tools/rbd_wnbd/CMakeLists.txt index 12a54986fba..bb256bf9eba 100644 --- a/src/tools/rbd_wnbd/CMakeLists.txt +++ b/src/tools/rbd_wnbd/CMakeLists.txt @@ -8,7 +8,9 @@ set_target_properties( rbd-wnbd PROPERTIES COMPILE_FLAGS "-fpermissive -I${WNBD_INCLUDE_DIRS}") target_link_libraries( - rbd-wnbd setupapi rpcrt4 + rbd-wnbd + legacy-option-headers + setupapi rpcrt4 wbemuuid oleaut32 ${WNBD_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY} -- 2.47.3