From 227cdd4d612a0ec183081c0d6544b90a49210787 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 14 Oct 2019 12:05:01 +0800 Subject: [PATCH 01/12] cmake: disable WITH_TESTS for Release builds cmake pass '-DNDEBUG' to compiler when compiling non-Debug builds. and rocksdb's tests are short-circuited if the "NDEBUG" macro is defined, so the "Release" builds fail when building tests. in this change, cmake disables `WITH_TESTS` option if `CMAKE_BUILD_TYPE` is `Release`. this also maps how `Makefile` defines `dbg` and `release` targets. in `Makefile`, `release` target does not depend on `$(TESTS)`, while `dbg` does. fixes #2445 Signed-off-by: Kefu Chai --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a540a9e1ba4..665bc020c30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -895,10 +895,11 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) ) endif() -option(WITH_TESTS "build with tests" ON) -# For test libraries, utilities, and exes that are build iff WITH_TESTS=ON and -# in Debug mode. Add test only code that is not #ifdefed for Release here. -if(WITH_TESTS AND CMAKE_BUILD_TYPE STREQUAL "Debug") +# Tests are excluded from Release builds +include(CMakeDependentOption) +CMAKE_DEPENDENT_OPTION(WITH_TESTS "build with tests" ON + "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) +if(WITH_TESTS) add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest) set(TESTS cache/cache_test.cc From 7d1de894e0aefdf8efeb18a5dad49c0ab999b9ab Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Dec 2019 11:14:27 +0800 Subject: [PATCH 02/12] cmake: compile testharness as a static library so we can reference it without worrying about its dependencies like gtest. testharness is used by table_reader_bench. Signed-off-by: Kefu Chai --- CMakeLists.txt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 665bc020c30..1c046f0fb69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -895,12 +895,16 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) ) endif() +add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest) +add_library(testharness STATIC + test_util/testharness.cc) +target_link_libraries(testharness gtest) + # Tests are excluded from Release builds include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(WITH_TESTS "build with tests" ON "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) if(WITH_TESTS) - add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest) set(TESTS cache/cache_test.cc cache/lru_cache_test.cc @@ -1078,15 +1082,14 @@ if(WITH_TESTS) set(TEST_EXES ${TESTS}) foreach(sourcefile ${TEST_EXES}) get_filename_component(exename ${sourcefile} NAME_WE) - add_executable(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} ${sourcefile} - $) + add_executable(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} ${sourcefile}) set_target_properties(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1 EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1 EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1 OUTPUT_NAME ${exename}${ARTIFACT_SUFFIX} ) - target_link_libraries(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX} gtest ${ROCKSDB_LIB}) + target_link_libraries(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} testutillib${ARTIFACT_SUFFIX} testharness gtest ${ROCKSDB_LIB}) if(NOT "${exename}" MATCHES "db_sanity_test") add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX}) add_dependencies(check ${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX}) @@ -1126,9 +1129,6 @@ endif() option(WITH_BENCHMARK_TOOLS "build with benchmarks" ON) if(WITH_BENCHMARK_TOOLS) - if(NOT TARGET gtest) - add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest) - endif() set(BENCHMARKS cache/cache_bench.cc memtable/memtablerep_bench.cc @@ -1137,7 +1137,6 @@ if(WITH_BENCHMARK_TOOLS) util/filter_bench.cc utilities/persistent_cache/hash_table_bench.cc ) - add_library(testharness OBJECT test_util/testharness.cc) foreach(sourcefile ${BENCHMARKS}) get_filename_component(exename ${sourcefile} NAME_WE) add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile} From 9e33443120f8eb8363e21b360e642b7201404394 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 14 Oct 2019 12:46:36 +0800 Subject: [PATCH 03/12] cmake: use CMAKE_DEPENDENT_OPTION() to conditionalize option definition `WITH_GFLAGS` is enabled/disabled depending on the building system, so it'd be simpler if we could define it using `CMAKE_DEPENDENT_OPTION`. Signed-off-by: Kefu Chai --- CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c046f0fb69..d822cbba9c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ if (WITH_WINDOWS_UTF8_FILENAMES) endif() # third-party/folly is only validated to work on Linux and Windows for now. # So only turn it on there by default. -if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Windows") +if(CMAKE_SYSTEM_NAME MATCHES "Linux|Windows") if(MSVC AND MSVC_VERSION LESS 1910) # Folly does not compile with MSVC older than VS2017 option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF) @@ -72,10 +72,14 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "Windows") else() option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF) endif() + +# Defaults currently different for GFLAGS. +# We will address find_package work a little later +include(CMakeDependentOption) +CMAKE_DEPENDENT_OPTION(WITH_GFLAGS "build with GFlags" ON + "NOT MSVC;NOT MINGW" OFF) + if(MSVC) - # Defaults currently different for GFLAGS. - # We will address find_package work a little later - option(WITH_GFLAGS "build with GFlags" OFF) option(WITH_XPRESS "build with windows built in compression" OFF) include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc) else() @@ -92,7 +96,6 @@ else() endif() # No config file for this - option(WITH_GFLAGS "build with GFlags" ON) if(WITH_GFLAGS) find_package(gflags) if(gflags_FOUND) @@ -901,7 +904,6 @@ add_library(testharness STATIC target_link_libraries(testharness gtest) # Tests are excluded from Release builds -include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(WITH_TESTS "build with tests" ON "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) if(WITH_TESTS) From 3d65227f3c160f3fb1713f65c193ae0eb6dbed15 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 14 Oct 2019 12:49:00 +0800 Subject: [PATCH 04/12] cmake: add benchmark tools without a loop unfold the loop, and remove the unused dependencies from linked libraries. Signed-off-by: Kefu Chai --- CMakeLists.txt | 53 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d822cbba9c9..a7fa0f16687 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1131,26 +1131,41 @@ endif() option(WITH_BENCHMARK_TOOLS "build with benchmarks" ON) if(WITH_BENCHMARK_TOOLS) - set(BENCHMARKS - cache/cache_bench.cc - memtable/memtablerep_bench.cc - db/range_del_aggregator_bench.cc - table/table_reader_bench.cc - util/filter_bench.cc - utilities/persistent_cache/hash_table_bench.cc - ) - foreach(sourcefile ${BENCHMARKS}) - get_filename_component(exename ${sourcefile} NAME_WE) - add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile} - $) - target_link_libraries(${exename}${ARTIFACT_SUFFIX} gtest ${ROCKSDB_LIB}) - endforeach(sourcefile ${BENCHMARKS}) - - add_executable(db_bench${ARTIFACT_SUFFIX} + add_executable(db_bench tools/db_bench.cc - tools/db_bench_tool.cc - $) - target_link_libraries(db_bench${ARTIFACT_SUFFIX} gtest ${ROCKSDB_LIB}) + tools/db_bench_tool.cc) + target_link_libraries(db_bench + ${ROCKSDB_LIB}) + + add_executable(cache_bench + cache/cache_bench.cc) + target_link_libraries(cache_bench + ${ROCKSDB_LIB}) + + add_executable(memtablerep_bench + memtable/memtablerep_bench.cc) + target_link_libraries(memtablerep_bench + ${ROCKSDB_LIB}) + + add_executable(range_del_aggregator_bench + db/range_del_aggregator_bench.cc) + target_link_libraries(range_del_aggregator_bench + ${ROCKSDB_LIB}) + + add_executable(table_reader_bench + table/table_reader_bench.cc) + target_link_libraries(table_reader_bench + ${ROCKSDB_LIB} testharness) + + add_executable(filter_bench + util/filter_bench.cc) + target_link_libraries(filter_bench + ${ROCKSDB_LIB}) + + add_executable(hash_table_bench + utilities/persistent_cache/hash_table_bench.cc) + target_link_libraries(hash_table_bench + ${ROCKSDB_LIB}) endif() option(WITH_TOOLS "build with tools" ON) From 49d3a255d0bffc5167590ba7f3df74cb2f075b3b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 14 Oct 2019 13:48:09 +0800 Subject: [PATCH 05/12] cmake: remove alias variables TEST_EXES and C_TEST_EXES are just aliases, so remove them Signed-off-by: Kefu Chai --- CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7fa0f16687..a91f321971b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1081,8 +1081,7 @@ if(WITH_TESTS) EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1 ) - set(TEST_EXES ${TESTS}) - foreach(sourcefile ${TEST_EXES}) + foreach(sourcefile ${TESTS}) get_filename_component(exename ${sourcefile} NAME_WE) add_executable(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} ${sourcefile}) set_target_properties(${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX} @@ -1096,7 +1095,7 @@ if(WITH_TESTS) add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX}) add_dependencies(check ${CMAKE_PROJECT_NAME}_${exename}${ARTIFACT_SUFFIX}) endif() - endforeach(sourcefile ${TEST_EXES}) + endforeach(sourcefile ${TESTS}) if(WIN32) # C executables must link to a shared object @@ -1111,9 +1110,8 @@ if(WITH_TESTS) if(ROCKSDB_LIB_FOR_C) set(C_TESTS db/c_test.c) - set(C_TEST_EXES ${C_TESTS}) - foreach(sourcefile ${C_TEST_EXES}) + foreach(sourcefile ${C_TESTS}) string(REPLACE ".c" "" exename ${sourcefile}) string(REGEX REPLACE "^((.+)/)+" "" exename ${exename}) add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile}) @@ -1125,7 +1123,7 @@ if(WITH_TESTS) target_link_libraries(${exename}${ARTIFACT_SUFFIX} ${ROCKSDB_LIB_FOR_C} testutillib${ARTIFACT_SUFFIX}) add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX}) add_dependencies(check ${exename}${ARTIFACT_SUFFIX}) - endforeach(sourcefile ${C_TEST_EXES}) + endforeach(sourcefile ${C_TESTS}) endif() endif() From a0599beef049d1c09b3f665bec753baa5e2a93e6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 14 Oct 2019 13:59:22 +0800 Subject: [PATCH 06/12] cmake: simplify db/c_test.c build * no need to use a loop for building it * no need to set properties like `EXCLUDE_FROM_DEFAULT_BUILD_RELEASE`, these properties are not read by anybody * no need to link against testutillib Signed-off-by: Kefu Chai --- CMakeLists.txt | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a91f321971b..11864b31751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1110,20 +1110,11 @@ if(WITH_TESTS) if(ROCKSDB_LIB_FOR_C) set(C_TESTS db/c_test.c) - - foreach(sourcefile ${C_TESTS}) - string(REPLACE ".c" "" exename ${sourcefile}) - string(REGEX REPLACE "^((.+)/)+" "" exename ${exename}) - add_executable(${exename}${ARTIFACT_SUFFIX} ${sourcefile}) - set_target_properties(${exename}${ARTIFACT_SUFFIX} - PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD_RELEASE 1 - EXCLUDE_FROM_DEFAULT_BUILD_MINRELEASE 1 - EXCLUDE_FROM_DEFAULT_BUILD_RELWITHDEBINFO 1 - ) - target_link_libraries(${exename}${ARTIFACT_SUFFIX} ${ROCKSDB_LIB_FOR_C} testutillib${ARTIFACT_SUFFIX}) - add_test(NAME ${exename} COMMAND ${exename}${ARTIFACT_SUFFIX}) - add_dependencies(check ${exename}${ARTIFACT_SUFFIX}) - endforeach(sourcefile ${C_TESTS}) + # C executables must link to a shared object + add_executable(c_test db/c_test.c) + target_link_libraries(c_test ${ROCKSDB_SHARED_LIB} testharness) + add_test(NAME c_test COMMAND c_test${ARTIFACT_SUFFIX}) + add_dependencies(check c_test) endif() endif() From b77534d27eff6614b8465d180a8df3d9ba9d2d71 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 15 Oct 2019 01:22:43 +0800 Subject: [PATCH 07/12] cmake: default to Debug Signed-off-by: Kefu Chai --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11864b31751..fcc6a1687d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,16 @@ if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) endif() +if(NOT CMAKE_BUILD_TYPE) + if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + set(default_build_type "Debug") + else() + set(default_build_type "RelWithDebInfo") + endif() + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING + "Default BUILD_TYPE is ${default_build_type}" FORCE) +endif() + find_program(CCACHE_FOUND ccache) if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) From 2117e9ad443f127f96c242d9792487c62bdf1a5e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Dec 2019 11:40:59 +0800 Subject: [PATCH 08/12] cmake: add Findgflags.cmake newer libgflags-dev ships with cmake support, but libgflags-dev 2.1.2-3 shipped by xenial does not. let's add the find_package() support. so our CI can build with gflags Signed-off-by: Kefu Chai --- CMakeLists.txt | 9 ++------- cmake/modules/Findgflags.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 cmake/modules/Findgflags.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fcc6a1687d1..64844487ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,6 @@ else() option(WITH_FOLLY_DISTRIBUTED_MUTEX "build with folly::DistributedMutex" OFF) endif() -# Defaults currently different for GFLAGS. -# We will address find_package work a little later include(CMakeDependentOption) CMAKE_DEPENDENT_OPTION(WITH_GFLAGS "build with GFlags" ON "NOT MSVC;NOT MINGW" OFF) @@ -108,11 +106,8 @@ else() # No config file for this if(WITH_GFLAGS) find_package(gflags) - if(gflags_FOUND) - add_definitions(-DGFLAGS=1) - include_directories(${gflags_INCLUDE_DIR}) - list(APPEND THIRDPARTY_LIBS ${gflags_LIBRARIES}) - endif() + add_definitions(-DGFLAGS=1) + list(APPEND THIRDPARTY_LIBS gflags::gflags) endif() if(WITH_SNAPPY) diff --git a/cmake/modules/Findgflags.cmake b/cmake/modules/Findgflags.cmake new file mode 100644 index 00000000000..d9183fbf8c4 --- /dev/null +++ b/cmake/modules/Findgflags.cmake @@ -0,0 +1,29 @@ +# - Find gflags library +# Find the gflags includes and library +# +# gflags_INCLUDE_DIR - where to find gflags.h. +# gflags_LIBRARIES - List of libraries when using gflags. +# gflags_FOUND - True if gflags found. + +find_path(GFLAGS_INCLUDE_DIR + NAMES gflags/gflags.h) + +find_library(GFLAGS_LIBRARIES + NAMES gflags) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(gflags + DEFAULT_MSG GFLAGS_LIBRARIES GFLAGS_INCLUDE_DIR) + +mark_as_advanced( + GFLAGS_LIBRARIES + GFLAGS_INCLUDE_DIR) + +if(gflags_FOUND AND NOT (TARGET gflags::gflags)) + add_library(gflags::gflags UNKNOWN IMPORTED) + set_target_properties(gflags::gflags + PROPERTIES + IMPORTED_LOCATION ${GFLAGS_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${GFLAGS_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX") +endif() From a9b53665cc57cddcc7adc6c31d10a70b424cbe28 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Dec 2019 11:30:32 +0800 Subject: [PATCH 09/12] cmake: require gflags if WITH_GFLAGS Signed-off-by: Kefu Chai --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64844487ed4..9bb3b4541dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,8 +105,9 @@ else() # No config file for this if(WITH_GFLAGS) - find_package(gflags) + find_package(gflags REQUIRED) add_definitions(-DGFLAGS=1) + include_directories(${gflags_INCLUDE_DIR}) list(APPEND THIRDPARTY_LIBS gflags::gflags) endif() From 5492027d7f21ff5231a27fdc846a7ccbd33bd2c0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 13 Dec 2019 10:54:21 +0800 Subject: [PATCH 10/12] .travis.yml: disable WITH_GFLAGS for cmake-mingw as we don't have libgflags-dev installed on mingw, and the toolchain is not MSVC. please note, currently WITH_GFLAGS is OFF by default on MINGW, but it's still better to be explicit. Signed-off-by: Kefu Chai --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7af91483bca..e8c7ea83a06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -113,7 +113,7 @@ script: ;; cmake-mingw) sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix; - mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni + mkdir build && cd build && cmake -DJNI=1 -DWITH_GFLAGS=OFF .. -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ -DCMAKE_SYSTEM_NAME=Windows && make -j4 rocksdb rocksdbjni ;; cmake*) mkdir build && cd build && cmake -DJNI=1 .. -DCMAKE_BUILD_TYPE=Release && make -j4 rocksdb rocksdbjni From f8cd930f0bc63def1f5717b8d03224907e6f434b Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 13 Dec 2019 16:26:51 +0800 Subject: [PATCH 11/12] .travis.yml: install gflags on osx since WITH_GFLAGS is ON by default on OSX, we need to install or or disable it explicitly. it'd be better to install it for better coverage of the CI test. Signed-off-by: Kefu Chai --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e8c7ea83a06..3f1df274c28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,7 @@ matrix: # https://docs.travis-ci.com/user/caching/#ccache-cache install: - if [ "${TRAVIS_OS_NAME}" == osx ]; then - brew install ccache zstd lz4 snappy xz; + brew install ccache gflags zstd lz4 snappy xz; PATH=$PATH:/usr/local/opt/ccache/libexec; fi - if [ "${JOB_NAME}" == cmake-gcc8 ]; then From 04f35734205c1beec193452e25e86d3a08f5e703 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 13 Dec 2019 18:06:27 +0800 Subject: [PATCH 12/12] db_stress: silence clang++ warning stress_tool/batched_ops_stress.cc:178:41: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] 2822 std::array keys = {"0", "1", "2", "3", "4", 2823 ^~~~~~~~~~~~~~~~~~~~~~~~ 28241 error generated. see the discussions at https://stackoverflow.com/questions/22501368/why-wasnt-a-double-curly-braces-syntax-preferred-for-constructors-taking-a-std and https://en.cppreference.com/w/cpp/container/array Signed-off-by: Kefu Chai --- db_stress_tool/batched_ops_stress.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db_stress_tool/batched_ops_stress.cc b/db_stress_tool/batched_ops_stress.cc index e5e346da9dc..298903a0a1d 100644 --- a/db_stress_tool/batched_ops_stress.cc +++ b/db_stress_tool/batched_ops_stress.cc @@ -175,8 +175,8 @@ class BatchedOpsStressTest : public StressTest { const std::vector& rand_keys) override { size_t num_keys = rand_keys.size(); std::vector ret_status(num_keys); - std::array keys = {"0", "1", "2", "3", "4", - "5", "6", "7", "8", "9"}; + std::array keys = {{"0", "1", "2", "3", "4", + "5", "6", "7", "8", "9"}}; size_t num_prefixes = keys.size(); for (size_t rand_key = 0; rand_key < num_keys; ++rand_key) { std::vector key_slices;