Skip to content

Commit cc1d4e3

Browse files
tchaikovfacebook-github-bot
authored andcommitted
gcc-11 and cmake related cleanup (facebook#9286)
Summary: in hope to get rockdb compiled with GCC-11 without warning * util/bloom_test: init a variable before using it to silence the GCC warning like ``` util/bloom_test.cc:1253:31: error: ‘<anonymous>’ may be used uninitialized [-Werror=maybe-uninitialized] 1253 | Slice key_slice{key_bytes, 8}; | ^ ... include/rocksdb/slice.h:41:3: note: by argument 2 of type ‘const char*’ to ‘rocksdb::Slice::Slice(const char*, size_t)’ declared here 41 | Slice(const char* d, size_t n) : data_(d), size_(n) {} | ^~~~~ util/bloom_test.cc:1249:3: note: ‘<anonymous>’ declared here 1249 | }; | ^ cc1plus: all warnings being treated as errors ``` * cmake: add find_package(uring ...) find liburing in a more consistent way. also it is the encouraged way for finding a library. Pull Request resolved: facebook#9286 Reviewed By: mrambacher Differential Revision: D33165241 Pulled By: jay-zhuang fbshipit-source-id: 9f3487e11b4e40fd8f1c97c8facb24a190e5ce31
1 parent 7bfad07 commit cc1d4e3

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

CMakeLists.txt

+7-15
Original file line numberDiff line numberDiff line change
@@ -352,25 +352,17 @@ int main() {
352352
return 0;
353353
}
354354
" BUILTIN_ATOMIC)
355-
if (NOT BUILTIN_ATOMIC)
356-
#TODO: Check if -latomic exists
357-
list(APPEND THIRDPARTY_LIBS atomic)
358-
endif()
355+
if (NOT BUILTIN_ATOMIC)
356+
#TODO: Check if -latomic exists
357+
list(APPEND THIRDPARTY_LIBS atomic)
358+
endif()
359359
endif()
360360

361361
if (WITH_LIBURING)
362-
set(CMAKE_REQUIRED_FLAGS "-luring")
363-
CHECK_CXX_SOURCE_COMPILES("
364-
#include <liburing.h>
365-
int main() {
366-
struct io_uring ring;
367-
io_uring_queue_init(1, &ring, 0);
368-
return 0;
369-
}
370-
" HAS_LIBURING)
371-
if (HAS_LIBURING)
362+
find_package(uring)
363+
if (uring_FOUND)
372364
add_definitions(-DROCKSDB_IOURING_PRESENT)
373-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -luring")
365+
list(APPEND THIRDPARTY_LIBS uring::uring)
374366
endif()
375367
endif()
376368

cmake/modules/Finduring.cmake

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# - Find liburing
2+
#
3+
# uring_INCLUDE_DIR - Where to find liburing.h
4+
# uring_LIBRARIES - List of libraries when using uring.
5+
# uring_FOUND - True if uring found.
6+
7+
find_path(uring_INCLUDE_DIR
8+
NAMES liburing.h)
9+
find_library(uring_LIBRARIES
10+
NAMES liburing.a liburing)
11+
12+
include(FindPackageHandleStandardArgs)
13+
find_package_handle_standard_args(uring
14+
DEFAULT_MSG uring_LIBRARIES uring_INCLUDE_DIR)
15+
16+
mark_as_advanced(
17+
uring_INCLUDE_DIR
18+
uring_LIBRARIES)
19+
20+
if(uring_FOUND AND NOT TARGET uring::uring)
21+
add_library(uring::uring UNKNOWN IMPORTED)
22+
set_target_properties(uring::uring PROPERTIES
23+
INTERFACE_INCLUDE_DIRECTORIES "${uring_INCLUDE_DIR}"
24+
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
25+
IMPORTED_LOCATION "${uring_LIBRARIES}")
26+
endif()

util/bloom_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ INSTANTIATE_TEST_CASE_P(Full, FullBloomTest,
12441244

12451245
static double GetEffectiveBitsPerKey(FilterBitsBuilder* builder) {
12461246
union {
1247-
uint64_t key_value;
1247+
uint64_t key_value = 0;
12481248
char key_bytes[8];
12491249
};
12501250

0 commit comments

Comments
 (0)