Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with clang 19 #11834

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions bindings/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,30 @@ 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.
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
Expand Down
45 changes: 45 additions & 0 deletions bindings/c/test/fdb_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,51 @@
// introduce the option enums
#include <fdb_c_options.g.h>

namespace std {
template <>
struct char_traits<uint8_t> {
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<const char*>(s)); }

static const char_type* find(const char_type* s, size_t n, const char_type& a) {
return reinterpret_cast<const char_type*>(memchr(s, a, n));
}

static char_type* move(char_type* s1, const char_type* s2, size_t n) {
return reinterpret_cast<char_type*>(memmove(s1, s2, n));
}

static char_type* copy(char_type* s1, const char_type* s2, size_t n) {
return reinterpret_cast<char_type*>(memcpy(s1, s2, n));
}

static char_type* assign(char_type* s, size_t n, char_type a) {
return reinterpret_cast<char_type*>(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<char_type>(c); }

static int_type to_int_type(char_type c) noexcept { return static_cast<int_type>(c); }

static bool eq_int_type(int_type c1, int_type c2) noexcept { return c1 == c2; }

static int_type eof() noexcept { return static_cast<int_type>(EOF); }
};
} // namespace std

namespace fdb {

// hide C API to discourage mixing C/C++ API
Expand Down
4 changes: 4 additions & 0 deletions cmake/ConfigureCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -485,6 +488,7 @@ else()
# Needed for gcc 13
#add_compile_options($<${is_cxx_compile}:-Wno-missing-template-keyword>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-missing-template-keyword>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-free-nonheap-object>)
endif()
add_compile_options(
$<${is_cxx_compile}:-Wno-error=format>
Expand Down
1 change: 0 additions & 1 deletion fdbserver/KeyValueStoreShardedRocksDB.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct.

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-";
Expand Down
2 changes: 1 addition & 1 deletion fdbserver/worker.actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4209,7 +4209,7 @@ ACTOR Future<Void> serveProcess() {

std::vector<SerializedSample> 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);
Expand Down