From b00fa7e17f64e9f57931d49150dc4df75dd7b967 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Thu, 12 Dec 2024 21:29:34 -0800 Subject: [PATCH 1/3] Fix issues with clang 19 --- bindings/c/CMakeLists.txt | 15 ++++- bindings/c/test/fdb_api.hpp | 60 +++++++++++++++++++ cmake/ConfigureCompiler.cmake | 4 ++ .../KeyValueStoreShardedRocksDB.actor.cpp | 1 - fdbserver/worker.actor.cpp | 2 +- 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 181259fb236..6852ba9d73a 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -425,8 +425,19 @@ target_link_libraries(cpp_workloads PUBLIC fdb_c) target_include_directories(c_workloads PUBLIC ${CMAKE_SOURCE_DIR}/bindings/c) if(NOT WIN32 AND NOT APPLE AND NOT OPEN_FOR_IDE) - target_link_options(cpp_workloads PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map,-z,nodelete") - target_link_options(c_workloads PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map,-z,nodelete") + # Add the -Wl,--undefined-version flag to the linker command to allow + # undefined symbols in version scripts. Clang 19 doesn't allow this and would + # complain with "symbol not defined" errors. + target_link_options(cpp_workloads PRIVATE + "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" + "LINKER:-z,nodelete" + "LINKER:--undefined-version" + ) + target_link_options(c_workloads PRIVATE + "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" + "LINKER:-z,nodelete" + "LINKER:--undefined-version" + ) endif() # Generate shim library in Linux builds diff --git a/bindings/c/test/fdb_api.hpp b/bindings/c/test/fdb_api.hpp index 0f041ee8f02..43d6dadac5f 100644 --- a/bindings/c/test/fdb_api.hpp +++ b/bindings/c/test/fdb_api.hpp @@ -39,6 +39,66 @@ // introduce the option enums #include +namespace std { +template <> +struct char_traits { + using char_type = uint8_t; + using int_type = int; + using off_type = streamoff; + using pos_type = streampos; + using state_type = mbstate_t; + + static void assign(char_type& c1, const char_type& c2) noexcept { c1 = c2; } + static bool eq(char_type c1, char_type c2) noexcept { return c1 == c2; } + static bool lt(char_type c1, char_type c2) noexcept { return c1 < c2; } + + static int compare(const char_type* s1, const char_type* s2, size_t n) { + return memcmp(s1, s2, n); + } + + static size_t length(const char_type* s) { + return strlen(reinterpret_cast(s)); + } + + static const char_type* find(const char_type* s, size_t n, const char_type& a) { + return reinterpret_cast(memchr(s, a, n)); + } + + static char_type* move(char_type* s1, const char_type* s2, size_t n) { + return reinterpret_cast(memmove(s1, s2, n)); + } + + static char_type* copy(char_type* s1, const char_type* s2, size_t n) { + return reinterpret_cast(memcpy(s1, s2, n)); + } + + static char_type* assign(char_type* s, size_t n, char_type a) { + return reinterpret_cast(memset(s, a, n)); + } + + static int_type not_eof(int_type c) noexcept { + return (c == eof()) ? 0 : c; + } + + static char_type to_char_type(int_type c) noexcept { + return static_cast(c); + } + + static int_type to_int_type(char_type c) noexcept { + return static_cast(c); + } + + static bool eq_int_type(int_type c1, int_type c2) noexcept { + return c1 == c2; + } + + static int_type eof() noexcept { + return static_cast(EOF); + } +}; +} + + namespace fdb { // hide C API to discourage mixing C/C++ API diff --git a/cmake/ConfigureCompiler.cmake b/cmake/ConfigureCompiler.cmake index f5296670f2c..fa032869a9b 100644 --- a/cmake/ConfigureCompiler.cmake +++ b/cmake/ConfigureCompiler.cmake @@ -96,6 +96,7 @@ set(CMAKE_REQUIRED_INCLUDES stdlib.h malloc.h) set(CMAKE_REQUIRED_LIBRARIES c) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED ON) @@ -436,6 +437,8 @@ else() $<${is_cxx_compile}:-Wno-unused-command-line-argument> # Disable C++ 20 warning for ambiguous operator. $<${is_cxx_compile}:-Wno-ambiguous-reversed-operator> + # Disable for clang 19 + $<${is_cxx_compile}:-Wno-vla-cxx-extension> ) # These need to be disabled for FDB's RocksDB storage server implementation add_compile_options( @@ -485,6 +488,7 @@ else() # Needed for gcc 13 #add_compile_options($<${is_cxx_compile}:-Wno-missing-template-keyword>) add_compile_options($<$:-Wno-missing-template-keyword>) + add_compile_options($<$:-Wno-free-nonheap-object>) endif() add_compile_options( $<${is_cxx_compile}:-Wno-error=format> diff --git a/fdbserver/KeyValueStoreShardedRocksDB.actor.cpp b/fdbserver/KeyValueStoreShardedRocksDB.actor.cpp index fad285b72df..03de4da64f3 100644 --- a/fdbserver/KeyValueStoreShardedRocksDB.actor.cpp +++ b/fdbserver/KeyValueStoreShardedRocksDB.actor.cpp @@ -54,7 +54,6 @@ static_assert((ROCKSDB_MAJOR == FDB_ROCKSDB_MAJOR && ROCKSDB_MINOR == FDB_ROCKSD ROCKSDB_PATCH == FDB_ROCKSDB_PATCH), "Unsupported rocksdb version."); -const std::string rocksDataFolderSuffix = "-data"; const std::string METADATA_SHARD_ID = "kvs-metadata"; const std::string DEFAULT_CF_NAME = "default"; // `specialKeys` is stored in this culoumn family. const std::string manifestFilePrefix = "MANIFEST-"; diff --git a/fdbserver/worker.actor.cpp b/fdbserver/worker.actor.cpp index a50d38f52f6..9af32be70f5 100644 --- a/fdbserver/worker.actor.cpp +++ b/fdbserver/worker.actor.cpp @@ -4209,7 +4209,7 @@ ACTOR Future serveProcess() { std::vector serializedSamples; for (const auto& samplePtr : samples) { - auto serialized = SerializedSample{ .time = samplePtr->time }; + auto serialized = SerializedSample{ .time = samplePtr->time, .data = {} }; for (const auto& [waitState, pair] : samplePtr->data) { if (waitState >= req.waitStateStart && waitState <= req.waitStateEnd) { serialized.data[waitState] = std::string(pair.first, pair.second); From 485b4b7af816a1d49319fade2a0122948dc8b8f1 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Fri, 13 Dec 2024 09:01:33 -0800 Subject: [PATCH 2/3] Fix format --- bindings/c/test/fdb_api.hpp | 95 ++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/bindings/c/test/fdb_api.hpp b/bindings/c/test/fdb_api.hpp index 43d6dadac5f..f7997c7c2a8 100644 --- a/bindings/c/test/fdb_api.hpp +++ b/bindings/c/test/fdb_api.hpp @@ -42,62 +42,47 @@ namespace std { template <> struct char_traits { - using char_type = uint8_t; - using int_type = int; - using off_type = streamoff; - using pos_type = streampos; - using state_type = mbstate_t; - - static void assign(char_type& c1, const char_type& c2) noexcept { c1 = c2; } - static bool eq(char_type c1, char_type c2) noexcept { return c1 == c2; } - static bool lt(char_type c1, char_type c2) noexcept { return c1 < c2; } - - static int compare(const char_type* s1, const char_type* s2, size_t n) { - return memcmp(s1, s2, n); - } - - static size_t length(const char_type* s) { - return strlen(reinterpret_cast(s)); - } - - static const char_type* find(const char_type* s, size_t n, const char_type& a) { - return reinterpret_cast(memchr(s, a, n)); - } - - static char_type* move(char_type* s1, const char_type* s2, size_t n) { - return reinterpret_cast(memmove(s1, s2, n)); - } - - static char_type* copy(char_type* s1, const char_type* s2, size_t n) { - return reinterpret_cast(memcpy(s1, s2, n)); - } - - static char_type* assign(char_type* s, size_t n, char_type a) { - return reinterpret_cast(memset(s, a, n)); - } - - static int_type not_eof(int_type c) noexcept { - return (c == eof()) ? 0 : c; - } - - static char_type to_char_type(int_type c) noexcept { - return static_cast(c); - } - - static int_type to_int_type(char_type c) noexcept { - return static_cast(c); - } - - static bool eq_int_type(int_type c1, int_type c2) noexcept { - return c1 == c2; - } - - static int_type eof() noexcept { - return static_cast(EOF); - } -}; -} + using char_type = uint8_t; + using int_type = int; + using off_type = streamoff; + using pos_type = streampos; + using state_type = mbstate_t; + + static void assign(char_type& c1, const char_type& c2) noexcept { c1 = c2; } + static bool eq(char_type c1, char_type c2) noexcept { return c1 == c2; } + static bool lt(char_type c1, char_type c2) noexcept { return c1 < c2; } + + static int compare(const char_type* s1, const char_type* s2, size_t n) { return memcmp(s1, s2, n); } + + static size_t length(const char_type* s) { return strlen(reinterpret_cast(s)); } + + static const char_type* find(const char_type* s, size_t n, const char_type& a) { + return reinterpret_cast(memchr(s, a, n)); + } + + static char_type* move(char_type* s1, const char_type* s2, size_t n) { + return reinterpret_cast(memmove(s1, s2, n)); + } + static char_type* copy(char_type* s1, const char_type* s2, size_t n) { + return reinterpret_cast(memcpy(s1, s2, n)); + } + + static char_type* assign(char_type* s, size_t n, char_type a) { + return reinterpret_cast(memset(s, a, n)); + } + + static int_type not_eof(int_type c) noexcept { return (c == eof()) ? 0 : c; } + + static char_type to_char_type(int_type c) noexcept { return static_cast(c); } + + static int_type to_int_type(char_type c) noexcept { return static_cast(c); } + + static bool eq_int_type(int_type c1, int_type c2) noexcept { return c1 == c2; } + + static int_type eof() noexcept { return static_cast(EOF); } +}; +} // namespace std namespace fdb { From 86bfcf272c400b171f188e497c4b112701ad5783 Mon Sep 17 00:00:00 2001 From: Jingyu Zhou Date: Fri, 13 Dec 2024 10:38:42 -0800 Subject: [PATCH 3/3] Ignore --undefined-version for gcc --- bindings/c/CMakeLists.txt | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/bindings/c/CMakeLists.txt b/bindings/c/CMakeLists.txt index 6852ba9d73a..1b2fb0208b7 100644 --- a/bindings/c/CMakeLists.txt +++ b/bindings/c/CMakeLists.txt @@ -428,16 +428,27 @@ if(NOT WIN32 AND NOT APPLE AND NOT OPEN_FOR_IDE) # Add the -Wl,--undefined-version flag to the linker command to allow # undefined symbols in version scripts. Clang 19 doesn't allow this and would # complain with "symbol not defined" errors. - target_link_options(cpp_workloads PRIVATE - "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" - "LINKER:-z,nodelete" - "LINKER:--undefined-version" - ) - target_link_options(c_workloads PRIVATE - "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" - "LINKER:-z,nodelete" - "LINKER:--undefined-version" - ) + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.0.0") + target_link_options(cpp_workloads PRIVATE + "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" + "LINKER:-z,nodelete" + "LINKER:--undefined-version" + ) + target_link_options(c_workloads PRIVATE + "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" + "LINKER:-z,nodelete" + "LINKER:--undefined-version" + ) + else() + target_link_options(cpp_workloads PRIVATE + "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" + "LINKER:-z,nodelete" + ) + target_link_options(c_workloads PRIVATE + "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/external_workload.map" + "LINKER:-z,nodelete" + ) + endif() endif() # Generate shim library in Linux builds