From 936252524e9059ad90c8ba140ca45e7ff2f31105 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Tue, 11 Apr 2023 08:39:10 +0000 Subject: [PATCH] cmake: avoid duplicate symbols Some symbols from the crc32, arch and fmt libs are re-exported by libceph-common: FAILED: bin/unittest_time.exe ld.lld: error: fmt::v9::format_error::~format_error() was replaced llvm throws errors because of the duplicate symbols. One workaround is to use objects instead of static libs for the libs. For libfmt we'll use the header-only version. Signed-off-by: Lucian Petrut --- src/arch/CMakeLists.txt | 2 +- src/common/CMakeLists.txt | 3 ++- src/crimson/CMakeLists.txt | 2 +- win32_build.sh | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/arch/CMakeLists.txt b/src/arch/CMakeLists.txt index ba1157358a7..e849e4896f4 100644 --- a/src/arch/CMakeLists.txt +++ b/src/arch/CMakeLists.txt @@ -9,4 +9,4 @@ elseif(HAVE_PPC64LE OR HAVE_PPC64 OR HAVE_PPC) list(APPEND arch_srcs ppc.c) endif() -add_library(arch STATIC ${arch_srcs}) +add_library(arch OBJECT ${arch_srcs}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 1297df32405..695ea7a68b3 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -229,7 +229,8 @@ elseif(HAVE_ARMV8_CRC) crc32c_aarch64.c) endif(HAVE_INTEL) -add_library(crc32 STATIC ${crc32_srcs}) +add_library(crc32 OBJECT ${crc32_srcs}) + if(HAVE_ARMV8_CRC) set_target_properties(crc32 PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARMV8_CRC_COMPILE_FLAGS}") diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index e2b37fac9cb..6b1b086db33 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -148,7 +148,7 @@ target_link_libraries(crimson-common PUBLIC ${crimson_common_public_deps} PRIVATE - crc32 + crc32 arch ${crimson_common_deps} OpenSSL::Crypto) diff --git a/win32_build.sh b/win32_build.sh index 3644074ef44..c29b5849172 100755 --- a/win32_build.sh +++ b/win32_build.sh @@ -161,6 +161,7 @@ fi cmake -D CMAKE_PREFIX_PATH=$depsDirs \ -D MINGW_LINK_DIRECTORIES="$linkDirs" \ -D CMAKE_TOOLCHAIN_FILE="$MINGW_CMAKE_FILE" \ + -D WITH_FMT_HEADER_ONLY=ON \ -D WITH_LIBCEPHSQLITE=OFF \ -D WITH_RDMA=OFF -D WITH_OPENLDAP=OFF \ -D WITH_GSSAPI=OFF -D WITH_XFS=OFF \ -- 2.47.3