From 5444942f158fac75336fcfa05719a5c77eb1681a Mon Sep 17 00:00:00 2001 From: Yuhong Guo Date: Mon, 10 Aug 2020 10:46:14 -0700 Subject: [PATCH] Fix cmake build on MacOS (#7205) Summary: 1. `std::random_shuffle` is deprecated and now we can use `std::shuffle` ``` /rocksdb/db/prefix_test.cc:590:12: error: 'random_shuffle >' is deprecated [-Werror,-Wdeprecated-declarations] std::random_shuffle(prefixes.begin(), prefixes.end()); ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:2982:1: note: 'random_shuffle >' has been explicitly marked deprecated here _LIBCPP_DEPRECATED_IN_CXX14 void ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1107:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX14' # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED ^ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1090:48: note: expanded from macro '_LIBCPP_DEPRECATED' # define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) ``` 2. `c_test` link error with `-DROCKSDB_BUILD_SHARED=OFF`: ``` [ 7%] Linking CXX executable c_test ld: library not found for -lrocksdb-shared clang: error: linker command failed with exit code 1 (use -v to see invocation) make[5]: *** [c_test] Error 1 make[4]: *** [CMakeFiles/c_test.dir/all] Error 2 make[4]: *** Waiting for unfinished jobs.... ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/7205 Reviewed By: ajkr Differential Revision: D23030641 Pulled By: pdillinger fbshipit-source-id: f270e50fc0b824ca1a0876ec5c65d33f55a72dd0 --- CMakeLists.txt | 3 +-- db/prefix_test.cc | 2 +- table/cuckoo/cuckoo_table_reader_test.cc | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2731a60ef..34f368a2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1230,9 +1230,8 @@ if(WITH_TESTS) if(ROCKSDB_LIB_FOR_C) set(C_TESTS db/c_test.c) - # 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) + target_link_libraries(c_test ${ROCKSDB_LIB_FOR_C} testharness) add_test(NAME c_test COMMAND c_test${ARTIFACT_SUFFIX}) add_dependencies(check c_test) endif() diff --git a/db/prefix_test.cc b/db/prefix_test.cc index 81387ce76..6bd618351 100644 --- a/db/prefix_test.cc +++ b/db/prefix_test.cc @@ -587,7 +587,7 @@ TEST_F(PrefixTest, DynamicPrefixIterator) { } if (FLAGS_random_prefix) { - std::random_shuffle(prefixes.begin(), prefixes.end()); + RandomShuffle(prefixes.begin(), prefixes.end()); } HistogramImpl hist_put_time; diff --git a/table/cuckoo/cuckoo_table_reader_test.cc b/table/cuckoo/cuckoo_table_reader_test.cc index f53f74fa8..5795de80d 100644 --- a/table/cuckoo/cuckoo_table_reader_test.cc +++ b/table/cuckoo/cuckoo_table_reader_test.cc @@ -500,7 +500,7 @@ void ReadKeys(uint64_t num, uint32_t batch_size) { for (uint64_t i = 0; i < num; ++i) { keys.push_back(2 * i); } - std::random_shuffle(keys.begin(), keys.end()); + RandomShuffle(keys.begin(), keys.end()); PinnableSlice value; // Assume only the fast path is triggered