git: a3d059526101 - main - databases/rocksdb: Update to 6.22.1

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Wed, 13 Oct 2021 06:12:40 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a3d059526101b524d91e33a6b672bb6116fb08c9

commit a3d059526101b524d91e33a6b672bb6116fb08c9
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2021-10-13 06:12:34 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2021-10-13 06:12:34 +0000

    databases/rocksdb: Update to 6.22.1
    
    Changes:        https://github.com/facebook/rocksdb/releases
---
 databases/rocksdb/Makefile                         |  19 +--
 databases/rocksdb/distinfo                         |   8 +-
 databases/rocksdb/files/patch-CMakeLists.txt       |   4 +-
 databases/rocksdb/files/patch-Makefile             |  16 ++-
 .../files/patch-build_tools-build_detect_platform  |  33 +++--
 databases/rocksdb/files/patch-clang10              | 145 ---------------------
 databases/rocksdb/files/patch-db-db_test_util.cc   | 120 +++++++++++++++++
 databases/rocksdb/files/patch-memory-arena.cc      |   4 +-
 databases/rocksdb/files/patch-port-stack_trace.cc  |  20 +++
 databases/rocksdb/files/patch-util_crc32c.cc       |  31 +----
 .../rocksdb/files/patch-util_crc32c__arm64.cc      |  30 -----
 databases/rocksdb/pkg-plist                        |  16 ++-
 12 files changed, 202 insertions(+), 244 deletions(-)

diff --git a/databases/rocksdb/Makefile b/databases/rocksdb/Makefile
index 25b1c7115e11..aed108f78596 100644
--- a/databases/rocksdb/Makefile
+++ b/databases/rocksdb/Makefile
@@ -1,14 +1,10 @@
 # Created by: Sunpoet Po-Chuan Hsieh <sunpoet@FreeBSD.org>
 
 PORTNAME=	rocksdb
-PORTVERSION=	6.11.6
+PORTVERSION=	6.22.1
 DISTVERSIONPREFIX=	v
-PORTREVISION=	1
 CATEGORIES=	databases
 
-PATCH_SITES=	https://github.com/facebook/${PORTNAME}/commit/
-PATCHFILES=	b937be377901afa32357b60eebbee80f14087180.patch:-p1
-
 MAINTAINER?=	sunpoet@FreeBSD.org
 COMMENT?=	Persistent key-value store for fast storage environments
 
@@ -26,9 +22,6 @@ BUILD_DEPENDS=	bash:shells/bash
 LIB_DEPENDS=	libgflags.so:devel/gflags \
 		libsnappy.so:archivers/snappy
 
-OPTIONS_DEFINE=	DEBUG LZ4 ZSTD
-OPTIONS_DEFAULT=LZ4
-
 USES=		compiler:c++11-lib gmake localbase:ldflags perl5
 USE_PERL5=	build
 
@@ -52,6 +45,9 @@ USE_GITHUB=	yes
 BENCHMARKS=	cache_bench db_bench memtablerep_bench persistent_cache_bench range_del_aggregator_bench table_reader_bench
 TOOLS=		blob_dump db_repl_stress db_sanity_test db_stress ldb rocksdb_dump rocksdb_undump sst_dump trace_analyzer write_stress
 
+OPTIONS_DEFINE=	DEBUG LZ4 ZSTD
+OPTIONS_DEFAULT=LZ4
+
 DEBUG_MAKE_ENV=		DEBUG_LEVEL=2
 DEBUG_MAKE_ENV_OFF=	DEBUG_LEVEL=0
 LZ4_LIB_DEPENDS=	liblz4.so:archivers/liblz4
@@ -73,7 +69,7 @@ PLIST_SUB+=	LITE=""
 .include <bsd.port.pre.mk>
 
 .if ${CHOSEN_COMPILER_TYPE} == clang
-CXXFLAGS+=	-Wno-inconsistent-missing-override -Wno-unused-variable
+CXXFLAGS+=	-Wno-inconsistent-missing-override -Wno-unused-parameter -Wno-unused-variable
 # Clang 8 detects shadow enums and stops the build. This workaround adds -Wno-error=shadow to bypass it.
 .if ${COMPILER_VERSION} >= 80
 CXXFLAGS+=	-Wno-error=shadow
@@ -82,8 +78,7 @@ CXXFLAGS+=	-Wno-error=shadow
 
 post-patch:
 .if (${ARCH} == amd64 || ${ARCH} == i386) && !empty(CFLAGS:M-march=*)
-	@${REINPLACE_CMD} -e 's| -march=native| ${CFLAGS:M-march=*}|' \
-	    ${WRKSRC}/build_tools/build_detect_platform
+	@${REINPLACE_CMD} -e 's| -march=native| ${CFLAGS:M-march=*}|' ${WRKSRC}/build_tools/build_detect_platform
 .else
 	@${REINPLACE_CMD} -e 's| -march=native||' ${WRKSRC}/build_tools/build_detect_platform
 .endif
@@ -92,7 +87,7 @@ post-install:
 	${MKDIR} ${STAGEDIR}${DATADIR}/
 	cd ${WRKSRC}/ && ${INSTALL_PROGRAM} ${BENCHMARKS} ${TOOLS} ${STAGEDIR}${PREFIX}/bin/
 	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/librocksdb${PKGNAMESUFFIX}.so
-	${INSTALL_DATA} ${WRKSRC}/librocksdb${PKGNAMESUFFIX}_tools.a ${STAGEDIR}${PREFIX}/lib/
+	${INSTALL_DATA} ${WRKSRC}/librocksdb${PKGNAMESUFFIX}_tools.so ${STAGEDIR}${PREFIX}/lib/
 	${INSTALL_DATA} ${WRKSRC}/make_config.mk ${STAGEDIR}${DATADIR}/
 
 .include <bsd.port.post.mk>
diff --git a/databases/rocksdb/distinfo b/databases/rocksdb/distinfo
index fc5f73414123..dcac9108b02a 100644
--- a/databases/rocksdb/distinfo
+++ b/databases/rocksdb/distinfo
@@ -1,5 +1,3 @@
-TIMESTAMP = 1606857109
-SHA256 (facebook-rocksdb-v6.11.6_GH0.tar.gz) = 7ff7cb277cad1dc4d1516c61470816e21c7c6e4dbb9a6e517dd590f2f2732b56
-SIZE (facebook-rocksdb-v6.11.6_GH0.tar.gz) = 6210689
-SHA256 (b937be377901afa32357b60eebbee80f14087180.patch) = 05ec8d1d8710e954f43f528de012feb26ca3f1a46e77994b9591882ce2d64060
-SIZE (b937be377901afa32357b60eebbee80f14087180.patch) = 12681
+TIMESTAMP = 1634000442
+SHA256 (facebook-rocksdb-v6.22.1_GH0.tar.gz) = 2df8f34a44eda182e22cf84dee7a14f17f55d305ff79c06fb3cd1e5f8831e00d
+SIZE (facebook-rocksdb-v6.22.1_GH0.tar.gz) = 9129964
diff --git a/databases/rocksdb/files/patch-CMakeLists.txt b/databases/rocksdb/files/patch-CMakeLists.txt
index eeefd6074532..31790f595624 100644
--- a/databases/rocksdb/files/patch-CMakeLists.txt
+++ b/databases/rocksdb/files/patch-CMakeLists.txt
@@ -1,6 +1,6 @@
---- CMakeLists.txt.orig	2021-10-10 13:48:40 UTC
+--- CMakeLists.txt.orig	2021-06-25 21:15:04 UTC
 +++ CMakeLists.txt
-@@ -521,6 +521,11 @@ if(HAVE_AUXV_GETAUXVAL)
+@@ -612,6 +612,11 @@ if(HAVE_AUXV_GETAUXVAL)
    add_definitions(-DROCKSDB_AUXV_GETAUXVAL_PRESENT)
  endif()
  
diff --git a/databases/rocksdb/files/patch-Makefile b/databases/rocksdb/files/patch-Makefile
index 5f1c2c3585ae..347153273ec8 100644
--- a/databases/rocksdb/files/patch-Makefile
+++ b/databases/rocksdb/files/patch-Makefile
@@ -1,10 +1,12 @@
---- Makefile.orig	2020-05-27 23:38:10 UTC
+--- Makefile.orig	2021-06-25 21:15:04 UTC
 +++ Makefile
-@@ -207,14 +207,14 @@ AM_LINK = $(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ 
+@@ -231,16 +231,16 @@ AM_SHARE = $(AM_V_CCLD) $(CXX) $(PLATFORM_SHARED_LDFLA
  # Detect what platform we're building on.
  # Export some common variables that might have been passed as Make variables
  # instead of environment variables.
 -dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; \
+-                  export CXXFLAGS="$(EXTRA_CXXFLAGS)"; \
+-                  export LDFLAGS="$(EXTRA_LDFLAGS)"; \
 -                  export COMPILE_WITH_ASAN="$(COMPILE_WITH_ASAN)"; \
 -                  export COMPILE_WITH_TSAN="$(COMPILE_WITH_TSAN)"; \
 -                  export COMPILE_WITH_UBSAN="$(COMPILE_WITH_UBSAN)"; \
@@ -13,6 +15,8 @@
 -                  export USE_CLANG="$(USE_CLANG)"; \
 -                  "$(CURDIR)/build_tools/build_detect_platform" "$(CURDIR)/make_config.mk"))
 +#dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; \
++#                  export CXXFLAGS="$(EXTRA_CXXFLAGS)"; \
++#                  export LDFLAGS="$(EXTRA_LDFLAGS)"; \
 +#                  export COMPILE_WITH_ASAN="$(COMPILE_WITH_ASAN)"; \
 +#                  export COMPILE_WITH_TSAN="$(COMPILE_WITH_TSAN)"; \
 +#                  export COMPILE_WITH_UBSAN="$(COMPILE_WITH_UBSAN)"; \
@@ -22,13 +26,13 @@
 +#                  "$(CURDIR)/build_tools/build_detect_platform" "$(CURDIR)/make_config.mk"))
  # this file is generated by the previous line to set build flags and sources
  include make_config.mk
- export JAVAC_ARGS
-@@ -779,7 +779,7 @@ endif  # PLATFORM_SHARED_EXT
- 	blackbox_crash_test_with_txn whitebox_crash_test_with_txn
+ 
+@@ -715,7 +715,7 @@ endif  # PLATFORM_SHARED_EXT
+ 	blackbox_crash_test_with_ts whitebox_crash_test_with_ts
  
  
 -all: $(LIBRARY) $(BENCHMARKS) tools tools_lib test_libs $(TESTS)
 +all: $(LIBRARY) $(BENCHMARKS) tools tools_lib test_libs # $(TESTS)
  
- all_but_some_tests: $(LIBRARY) $(BENCHMARKS) tools tools_lib test_libs $(SUBSET)
+ all_but_some_tests: $(LIBRARY) $(BENCHMARKS) tools tools_lib test_libs $(ROCKSDBTESTS_SUBSET)
  
diff --git a/databases/rocksdb/files/patch-build_tools-build_detect_platform b/databases/rocksdb/files/patch-build_tools-build_detect_platform
index 1984674f19ec..0eae538be82a 100644
--- a/databases/rocksdb/files/patch-build_tools-build_detect_platform
+++ b/databases/rocksdb/files/patch-build_tools-build_detect_platform
@@ -1,8 +1,8 @@
 Remove -fno-builtin-memcmp and -ltcmalloc
 
---- build_tools/build_detect_platform.orig	2020-05-27 23:38:10 UTC
+--- build_tools/build_detect_platform.orig	2021-06-25 21:15:04 UTC
 +++ build_tools/build_detect_platform
-@@ -126,7 +126,7 @@ PLATFORM_SHARED_VERSIONED=true
+@@ -145,7 +145,7 @@ PLATFORM_SHARED_VERSIONED=true
  # generic port files (working on all platform by #ifdef) go directly in /port
  GENERIC_PORT_FILES=`cd "$ROCKSDB_ROOT"; find port -name '*.cc' | tr "\n" " "`
  
@@ -11,7 +11,7 @@ Remove -fno-builtin-memcmp and -ltcmalloc
  case "$TARGET_OS" in
      Darwin)
          PLATFORM=OS_MACOSX
-@@ -147,7 +147,7 @@ case "$TARGET_OS" in
+@@ -166,7 +166,7 @@ case "$TARGET_OS" in
          PLATFORM=OS_LINUX
          COMMON_FLAGS="$COMMON_FLAGS -DOS_LINUX"
          if [ -z "$USE_CLANG" ]; then
@@ -20,7 +20,7 @@ Remove -fno-builtin-memcmp and -ltcmalloc
          else
              PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
          fi
-@@ -174,34 +174,34 @@ EOF
+@@ -196,21 +196,21 @@ EOF
          ;;
      SunOS)
          PLATFORM=OS_SOLARIS
@@ -45,6 +45,17 @@ Remove -fno-builtin-memcmp and -ltcmalloc
          PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread"
          # PORT_FILES=port/freebsd/freebsd_specific.cc
          ;;
+@@ -218,7 +218,7 @@ EOF
+         PLATFORM=OS_GNU_KFREEBSD
+         COMMON_FLAGS="$COMMON_FLAGS -DOS_GNU_KFREEBSD"
+         if [ -z "$USE_CLANG" ]; then
+-            COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp"
++            COMMON_FLAGS="$COMMON_FLAGS"
+         else
+             PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
+         fi
+@@ -227,14 +227,14 @@ EOF
+         ;;
      NetBSD)
          PLATFORM=OS_NETBSD
 -        COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD"
@@ -60,7 +71,7 @@ Remove -fno-builtin-memcmp and -ltcmalloc
          PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -pthread"
          # PORT_FILES=port/openbsd/openbsd_specific.cc
  	FIND=gfind
-@@ -209,7 +209,7 @@ EOF
+@@ -242,7 +242,7 @@ EOF
          ;;
      DragonFly)
          PLATFORM=OS_DRAGONFLYBSD
@@ -69,7 +80,7 @@ Remove -fno-builtin-memcmp and -ltcmalloc
          PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread"
          # PORT_FILES=port/dragonfly/dragonfly_specific.cc
          ;;
-@@ -219,7 +219,7 @@ EOF
+@@ -252,7 +252,7 @@ EOF
          PLATFORM_CXXFLAGS="-std=gnu++11"
          COMMON_FLAGS="$COMMON_FLAGS -DCYGWIN"
          if [ -z "$USE_CLANG" ]; then
@@ -78,7 +89,7 @@ Remove -fno-builtin-memcmp and -ltcmalloc
          else
              PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
          fi
-@@ -228,7 +228,7 @@ EOF
+@@ -261,7 +261,7 @@ EOF
          ;;
      OS_ANDROID_CROSSCOMPILE)
          PLATFORM=OS_ANDROID
@@ -87,10 +98,10 @@ Remove -fno-builtin-memcmp and -ltcmalloc
  	PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS "  # All pthread features are in the Android C library
          # PORT_FILES=port/android/android.cc
          CROSS_COMPILE=true
-@@ -410,9 +410,9 @@ EOF
+@@ -451,9 +451,9 @@ EOF
      if ! test $JEMALLOC && ! test $ROCKSDB_DISABLE_TCMALLOC; then
          # jemalloc is not available. Let's try tcmalloc
-         if echo 'int main() {}' | $CXX $CFLAGS -x c++ - -o /dev/null \
+         if echo 'int main() {}' | $CXX $PLATFORM_CXXFLAGS -x c++ - -o /dev/null \
 -          -ltcmalloc 2>/dev/null; then
 -            PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -ltcmalloc"
 -            JAVA_LDFLAGS="$JAVA_LDFLAGS -ltcmalloc"
@@ -100,7 +111,7 @@ Remove -fno-builtin-memcmp and -ltcmalloc
          fi
      fi
  
-@@ -558,8 +558,8 @@ EOF
+@@ -599,8 +599,8 @@ EOF
  fi
  
  # TODO(tec): Fix -Wshorten-64-to-32 errors on FreeBSD and enable the warning.
@@ -109,5 +120,5 @@ Remove -fno-builtin-memcmp and -ltcmalloc
 +# -Wshorten-64-to-32 breaks compilation on FreeBSD i386 and aarch64
 +if ! { [ "$TARGET_OS" = FreeBSD ] && [ "$TARGET_ARCHITECTURE" = i386 -o "$TARGET_ARCHITECTURE" = "arm64" ]; }; then
    # Test whether -Wshorten-64-to-32 is available
-   $CXX $CFLAGS -x c++ - -o /dev/null -Wshorten-64-to-32 2>/dev/null  <<EOF
+   $CXX $PLATFORM_CXXFLAGS -x c++ - -o /dev/null -Wshorten-64-to-32 2>/dev/null  <<EOF
      int main() {}
diff --git a/databases/rocksdb/files/patch-clang10 b/databases/rocksdb/files/patch-clang10
deleted file mode 100644
index ae35e4b08538..000000000000
--- a/databases/rocksdb/files/patch-clang10
+++ /dev/null
@@ -1,145 +0,0 @@
-Obtained from:	https://github.com/facebook/rocksdb/commit/9cc25190e1ba6fc66bbd0d47caaf043d75839b6f
-
---- db/db_iter_stress_test.cc.orig	2020-07-16 00:54:15 UTC
-+++ db/db_iter_stress_test.cc
-@@ -97,7 +97,8 @@ struct StressTestIterator : public InternalIterator {
- 
-   bool MaybeFail() {
-     if (rnd->Next() >=
--        std::numeric_limits<uint64_t>::max() * error_probability) {
-+        static_cast<double>(std::numeric_limits<uint64_t>::max()) *
-+            error_probability) {
-       return false;
-     }
-     if (rnd->Next() % 2) {
-@@ -114,7 +115,8 @@ struct StressTestIterator : public InternalIterator {
- 
-   void MaybeMutate() {
-     if (rnd->Next() >=
--        std::numeric_limits<uint64_t>::max() * mutation_probability) {
-+        static_cast<double>(std::numeric_limits<uint64_t>::max()) *
-+            mutation_probability) {
-       return;
-     }
-     do {
-@@ -126,8 +128,9 @@ struct StressTestIterator : public InternalIterator {
-       if (data->hidden.empty()) {
-         hide_probability = 1;
-       }
--      bool do_hide =
--          rnd->Next() < std::numeric_limits<uint64_t>::max() * hide_probability;
-+      bool do_hide = rnd->Next() <
-+                     static_cast<double>(std::numeric_limits<uint64_t>::max()) *
-+                         hide_probability;
-       if (do_hide) {
-         // Hide a random entry.
-         size_t idx = rnd->Next() % data->entries.size();
---- db/db_options_test.cc.orig	2020-07-16 00:54:15 UTC
-+++ db/db_options_test.cc
-@@ -39,7 +39,7 @@ class DBOptionsTest : public DBTestBase {
-     std::unordered_map<std::string, std::string> options_map;
-     StringToMap(options_str, &options_map);
-     std::unordered_map<std::string, std::string> mutable_map;
--    for (const auto opt : db_options_type_info) {
-+    for (const auto& opt : db_options_type_info) {
-       if (opt.second.IsMutable() && opt.second.ShouldSerialize()) {
-         mutable_map[opt.first] = options_map[opt.first];
-       }
-@@ -57,7 +57,7 @@ class DBOptionsTest : public DBTestBase {
-     std::unordered_map<std::string, std::string> options_map;
-     StringToMap(options_str, &options_map);
-     std::unordered_map<std::string, std::string> mutable_map;
--    for (const auto opt : cf_options_type_info) {
-+    for (const auto& opt : cf_options_type_info) {
-       if (opt.second.IsMutable() && opt.second.ShouldSerialize()) {
-         mutable_map[opt.first] = options_map[opt.first];
-       }
---- env/env_test.cc.orig	2020-07-16 00:54:15 UTC
-+++ env/env_test.cc
-@@ -1047,7 +1047,7 @@ TEST_P(EnvPosixTestWithParam, RandomAccessUniqueIDConc
- 
-     // Collect and check whether the IDs are unique.
-     std::unordered_set<std::string> ids;
--    for (const std::string fname : fnames) {
-+    for (const std::string& fname : fnames) {
-       std::unique_ptr<RandomAccessFile> file;
-       std::string unique_id;
-       ASSERT_OK(env_->NewRandomAccessFile(fname, &file, soptions));
-@@ -1061,7 +1061,7 @@ TEST_P(EnvPosixTestWithParam, RandomAccessUniqueIDConc
-     }
- 
-     // Delete the files
--    for (const std::string fname : fnames) {
-+    for (const std::string& fname : fnames) {
-       ASSERT_OK(env_->DeleteFile(fname));
-     }
- 
---- options/options_helper.cc.orig	2020-07-16 00:54:15 UTC
-+++ options/options_helper.cc
-@@ -656,7 +656,7 @@ Status GetStringFromStruct(
-     std::string* opt_string) {
-   assert(opt_string);
-   opt_string->clear();
--  for (const auto iter : type_info) {
-+  for (const auto& iter : type_info) {
-     const auto& opt_info = iter.second;
-     // If the option is no longer used in rocksdb and marked as deprecated,
-     // we skip it in the serialization.
---- table/table_test.cc.orig	2020-07-16 00:54:15 UTC
-+++ table/table_test.cc
-@@ -228,7 +228,7 @@ class BlockConstructor: public Constructor {
-     block_ = nullptr;
-     BlockBuilder builder(table_options.block_restart_interval);
- 
--    for (const auto kv : kv_map) {
-+    for (const auto& kv : kv_map) {
-       builder.Add(kv.first, kv.second);
-     }
-     // Open the block
-@@ -352,7 +352,7 @@ class TableConstructor: public Constructor {
-         TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
-         file_writer_.get()));
- 
--    for (const auto kv : kv_map) {
-+    for (const auto& kv : kv_map) {
-       if (convert_to_internal_key_) {
-         ParsedInternalKey ikey(kv.first, kMaxSequenceNumber, kTypeValue);
-         std::string encoded;
-@@ -487,7 +487,7 @@ class MemTableConstructor: public Constructor {
-                              kMaxSequenceNumber, 0 /* column_family_id */);
-     memtable_->Ref();
-     int seq = 1;
--    for (const auto kv : kv_map) {
-+    for (const auto& kv : kv_map) {
-       memtable_->Add(seq, kTypeValue, kv.first, kv.second);
-       seq++;
-     }
-@@ -548,7 +548,7 @@ class DBConstructor: public Constructor {
-     delete db_;
-     db_ = nullptr;
-     NewDB();
--    for (const auto kv : kv_map) {
-+    for (const auto& kv : kv_map) {
-       WriteBatch batch;
-       batch.Put(kv.first, kv.second);
-       EXPECT_TRUE(db_->Write(WriteOptions(), &batch).ok());
-@@ -1224,7 +1224,7 @@ class FileChecksumTestHelper {
-   }
- 
-   Status WriteKVAndFlushTable() {
--    for (const auto kv : kv_map_) {
-+    for (const auto& kv : kv_map_) {
-       if (convert_to_internal_key_) {
-         ParsedInternalKey ikey(kv.first, kMaxSequenceNumber, kTypeValue);
-         std::string encoded;
---- tools/ldb_cmd_test.cc.orig	2020-07-16 00:54:15 UTC
-+++ tools/ldb_cmd_test.cc
-@@ -76,7 +76,7 @@ TEST_F(LdbCmdTest, HexToStringBadInputs) {
-   const vector<string> badInputs = {
-       "0xZZ", "123", "0xx5", "0x111G", "0x123", "Ox12", "0xT", "0x1Q1",
-   };
--  for (const auto badInput : badInputs) {
-+  for (const auto& badInput : badInputs) {
-     try {
-       ROCKSDB_NAMESPACE::LDBCommand::HexToString(badInput);
-       std::cerr << "Should fail on bad hex value: " << badInput << "\n";
diff --git a/databases/rocksdb/files/patch-db-db_test_util.cc b/databases/rocksdb/files/patch-db-db_test_util.cc
new file mode 100644
index 000000000000..472503e88f1f
--- /dev/null
+++ b/databases/rocksdb/files/patch-db-db_test_util.cc
@@ -0,0 +1,120 @@
+--- db/db_test_util.cc.orig	2021-06-25 21:15:04 UTC
++++ db/db_test_util.cc
+@@ -95,9 +95,11 @@ DBTestBase::DBTestBase(const std::string path, bool en
+ }
+ 
+ DBTestBase::~DBTestBase() {
++#ifndef NDEBUG
+   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->DisableProcessing();
+   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->LoadDependency({});
+   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearAllCallBacks();
++#endif
+   Close();
+   Options options;
+   options.db_paths.emplace_back(dbname_, 0);
+@@ -347,6 +349,7 @@ Options DBTestBase::GetOptions(
+   Options options = default_options;
+   BlockBasedTableOptions table_options;
+   bool set_block_based_table_factory = true;
++#ifndef NDEBUG
+ #if !defined(OS_MACOSX) && !defined(OS_WIN) && !defined(OS_SOLARIS) && \
+     !defined(OS_AIX)
+   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
+@@ -354,6 +357,7 @@ Options DBTestBase::GetOptions(
+   ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->ClearCallBack(
+       "NewWritableFile:O_DIRECT");
+ #endif
++#endif
+ 
+   bool can_allow_mmap = IsMemoryMappedAccessSupported();
+   switch (option_config) {
+@@ -408,7 +412,9 @@ Options DBTestBase::GetOptions(
+         options.use_direct_reads = true;
+         options.use_direct_io_for_flush_and_compaction = true;
+         options.compaction_readahead_size = 2 * 1024 * 1024;
++#ifndef NDEBUG
+         SetupSyncPointsToMockDirectIO();
++#endif
+         break;
+       }
+ #endif  // ROCKSDB_LITE
+@@ -1124,6 +1130,7 @@ std::string DBTestBase::FilesPerLevel(int cf) {
+ 
+ #endif  // !ROCKSDB_LITE
+ 
++#ifndef NDEBUG
+ std::vector<uint64_t> DBTestBase::GetBlobFileNumbers() {
+   VersionSet* const versions = dbfull()->TEST_GetVersionSet();
+   assert(versions);
+@@ -1148,6 +1155,7 @@ std::vector<uint64_t> DBTestBase::GetBlobFileNumbers()
+ 
+   return result;
+ }
++#endif
+ 
+ size_t DBTestBase::CountFiles() {
+   size_t count = 0;
+@@ -1230,6 +1238,7 @@ void DBTestBase::FillLevels(const std::string& smalles
+ }
+ 
+ void DBTestBase::MoveFilesToLevel(int level, int cf) {
++#ifndef NDEBUG
+   for (int l = 0; l < level; ++l) {
+     if (cf > 0) {
+       EXPECT_OK(dbfull()->TEST_CompactRange(l, nullptr, nullptr, handles_[cf]));
+@@ -1237,13 +1246,16 @@ void DBTestBase::MoveFilesToLevel(int level, int cf) {
+       EXPECT_OK(dbfull()->TEST_CompactRange(l, nullptr, nullptr));
+     }
+   }
++#endif
+ }
+ 
+ #ifndef ROCKSDB_LITE
+ void DBTestBase::DumpFileCounts(const char* label) {
+   fprintf(stderr, "---\n%s:\n", label);
++#ifndef NDEBUG
+   fprintf(stderr, "maxoverlap: %" PRIu64 "\n",
+           dbfull()->TEST_MaxNextLevelOverlappingBytes());
++#endif
+   for (int level = 0; level < db_->NumberLevels(); level++) {
+     int num = NumTableFilesAtLevel(level);
+     if (num > 0) {
+@@ -1284,10 +1296,12 @@ void DBTestBase::GenerateNewFile(int cf, Random* rnd, 
+     ASSERT_OK(Put(cf, Key(*key_idx), rnd->RandomString((i == 99) ? 1 : 990)));
+     (*key_idx)++;
+   }
++#ifndef NDEBUG
+   if (!nowait) {
+     ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
+     ASSERT_OK(dbfull()->TEST_WaitForCompact());
+   }
++#endif
+ }
+ 
+ // this will generate non-overlapping files since it keeps increasing key_idx
+@@ -1296,10 +1310,12 @@ void DBTestBase::GenerateNewFile(Random* rnd, int* key
+     ASSERT_OK(Put(Key(*key_idx), rnd->RandomString((i == 99) ? 1 : 990)));
+     (*key_idx)++;
+   }
++#ifndef NDEBUG
+   if (!nowait) {
+     ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
+     ASSERT_OK(dbfull()->TEST_WaitForCompact());
+   }
++#endif
+ }
+ 
+ const int DBTestBase::kNumKeysByGenerateNewRandomFile = 51;
+@@ -1309,10 +1325,12 @@ void DBTestBase::GenerateNewRandomFile(Random* rnd, bo
+     ASSERT_OK(Put("key" + rnd->RandomString(7), rnd->RandomString(2000)));
+   }
+   ASSERT_OK(Put("key" + rnd->RandomString(7), rnd->RandomString(200)));
++#ifndef NDEBUG
+   if (!nowait) {
+     ASSERT_OK(dbfull()->TEST_WaitForFlushMemTable());
+     ASSERT_OK(dbfull()->TEST_WaitForCompact());
+   }
++#endif
+ }
+ 
+ std::string DBTestBase::IterStatus(Iterator* iter) {
diff --git a/databases/rocksdb/files/patch-memory-arena.cc b/databases/rocksdb/files/patch-memory-arena.cc
index 1a7ea39671bf..db76c877c68f 100644
--- a/databases/rocksdb/files/patch-memory-arena.cc
+++ b/databases/rocksdb/files/patch-memory-arena.cc
@@ -1,6 +1,6 @@
---- memory/arena.cc.orig	2018-01-31 01:15:39 UTC
+--- memory/arena.cc.orig	2021-06-25 21:15:04 UTC
 +++ memory/arena.cc
-@@ -33,7 +33,7 @@ const size_t Arena::kInlineSize;
+@@ -29,7 +29,7 @@ const size_t Arena::kInlineSize;
  
  const size_t Arena::kMinBlockSize = 4096;
  const size_t Arena::kMaxBlockSize = 2u << 30;
diff --git a/databases/rocksdb/files/patch-port-stack_trace.cc b/databases/rocksdb/files/patch-port-stack_trace.cc
new file mode 100644
index 000000000000..3b83846c5101
--- /dev/null
+++ b/databases/rocksdb/files/patch-port-stack_trace.cc
@@ -0,0 +1,20 @@
+--- port/stack_trace.cc.orig	2021-06-25 21:15:04 UTC
++++ port/stack_trace.cc
+@@ -135,7 +135,7 @@ void PrintStack(int first_frames_to_skip) {
+   void* frames[kMaxFrames];
+ 
+   auto num_frames = backtrace(frames, kMaxFrames);
+-  PrintStack(&frames[first_frames_to_skip], num_frames - first_frames_to_skip);
++  PrintStack(&frames[first_frames_to_skip], (int) (num_frames - first_frames_to_skip));
+ }
+ 
+ void PrintAndFreeStack(void* callstack, int num_frames) {
+@@ -148,7 +148,7 @@ void* SaveStack(int* num_frames, int first_frames_to_s
+   void* frames[kMaxFrames];
+ 
+   auto count = backtrace(frames, kMaxFrames);
+-  *num_frames = count - first_frames_to_skip;
++  *num_frames = (int) (count - first_frames_to_skip);
+   void* callstack = malloc(sizeof(void*) * *num_frames);
+   memcpy(callstack, &frames[first_frames_to_skip], sizeof(void*) * *num_frames);
+   return callstack;
diff --git a/databases/rocksdb/files/patch-util_crc32c.cc b/databases/rocksdb/files/patch-util_crc32c.cc
index a57cbf2803fe..7325d476b4b2 100644
--- a/databases/rocksdb/files/patch-util_crc32c.cc
+++ b/databases/rocksdb/files/patch-util_crc32c.cc
@@ -1,6 +1,6 @@
---- util/crc32c.cc.orig	2021-10-10 17:19:37 UTC
+--- util/crc32c.cc.orig	2021-06-25 21:15:04 UTC
 +++ util/crc32c.cc
-@@ -463,6 +463,21 @@ static int arch_ppc_probe(void) {
+@@ -488,6 +488,21 @@ static int arch_ppc_probe(void) {
  
    return arch_ppc_crc32;
  }
@@ -22,30 +22,3 @@
  #endif  // __linux__
  
  static bool isAltiVec() {
-@@ -474,7 +489,7 @@ static bool isAltiVec() {
- }
- #endif
- 
--#if defined(__linux__) && defined(HAVE_ARM64_CRC)
-+#if (defined(__FreeBSD__) || defined(__linux__)) && defined(HAVE_ARM64_CRC)
- uint32_t ExtendARMImpl(uint32_t crc, const char *buf, size_t size) {
-   return crc32c_arm64(crc, (const unsigned char *)buf, size);
- }
-@@ -494,7 +509,7 @@ std::string IsFastCrc32Supported() {
-   has_fast_crc = false;
-   arch = "PPC";
- #endif
--#elif defined(__linux__) && defined(HAVE_ARM64_CRC)
-+#elif (defined(__FreeBSD__) || defined(__linux__)) && defined(HAVE_ARM64_CRC)
-   if (crc32c_runtime_check()) {
-     has_fast_crc = true;
-     arch = "Arm64";
-@@ -1226,7 +1241,7 @@ uint32_t crc32c_3way(uint32_t crc, const char* buf, si
- static inline Function Choose_Extend() {
- #ifdef HAVE_POWER8
-   return isAltiVec() ? ExtendPPCImpl : ExtendImpl<Slow_CRC32>;
--#elif defined(__linux__) && defined(HAVE_ARM64_CRC)
-+#elif (defined(__FreeBSD__) || defined(__linux__)) && defined(HAVE_ARM64_CRC)
-   if(crc32c_runtime_check()) {
-     return ExtendARMImpl;
-   } else {
diff --git a/databases/rocksdb/files/patch-util_crc32c__arm64.cc b/databases/rocksdb/files/patch-util_crc32c__arm64.cc
deleted file mode 100644
index bc2a2a775b6b..000000000000
--- a/databases/rocksdb/files/patch-util_crc32c__arm64.cc
+++ /dev/null
@@ -1,30 +0,0 @@
---- util/crc32c_arm64.cc.orig	2021-10-10 13:50:13 UTC
-+++ util/crc32c_arm64.cc
-@@ -5,9 +5,11 @@
- 
- #include "util/crc32c_arm64.h"
- 
--#if defined(__linux__) && defined(HAVE_ARM64_CRC)
-+#if (defined(__FreeBSD__) || defined(__linux__)) && defined(HAVE_ARM64_CRC)
- 
-+#if !defined(__FreeBSD__)
- #include <asm/hwcap.h>
-+#endif
- #ifdef ROCKSDB_AUXV_GETAUXVAL_PRESENT
- #include <sys/auxv.h>
- #endif
-@@ -37,7 +39,14 @@
- 
- uint32_t crc32c_runtime_check(void) {
- #ifdef ROCKSDB_AUXV_GETAUXVAL_PRESENT
-+#if defined(__FreeBSD__)
-+  uint64_t auxv;
-+  int result = elf_aux_info(AT_HWCAP, &auxv, sizeof auxv);
-+  if (result != 0)
-+    return 0;
-+#else
-   uint64_t auxv = getauxval(AT_HWCAP);
-+#endif
-   return (auxv & HWCAP_CRC32) != 0;
- #else
-   return 0;
diff --git a/databases/rocksdb/pkg-plist b/databases/rocksdb/pkg-plist
index 56d57e31ef6d..6492d406ead8 100644
--- a/databases/rocksdb/pkg-plist
+++ b/databases/rocksdb/pkg-plist
@@ -17,12 +17,17 @@ bin/write_stress
 include/rocksdb/advanced_options.h
 include/rocksdb/c.h
 include/rocksdb/cache.h
+include/rocksdb/cache_bench_tool.h
 include/rocksdb/cleanable.h
 include/rocksdb/compaction_filter.h
 include/rocksdb/compaction_job_stats.h
 include/rocksdb/comparator.h
+include/rocksdb/compression_type.h
 include/rocksdb/concurrent_task_limiter.h
+include/rocksdb/configurable.h
 include/rocksdb/convenience.h
+include/rocksdb/customizable.h
+include/rocksdb/data_structure.h
 include/rocksdb/db.h
 include/rocksdb/db_bench_tool.h
 include/rocksdb/db_dump_tool.h
@@ -34,6 +39,7 @@ include/rocksdb/file_checksum.h
 include/rocksdb/file_system.h
 include/rocksdb/filter_policy.h
 include/rocksdb/flush_block_policy.h
+include/rocksdb/functor_wrapper.h
 include/rocksdb/io_status.h
 include/rocksdb/iostats_context.h
 include/rocksdb/iterator.h
@@ -49,6 +55,7 @@ include/rocksdb/perf_level.h
 include/rocksdb/persistent_cache.h
 include/rocksdb/rate_limiter.h
 include/rocksdb/rocksdb_namespace.h
+include/rocksdb/secondary_cache.h
 include/rocksdb/slice.h
 include/rocksdb/slice_transform.h
 include/rocksdb/snapshot.h
@@ -56,9 +63,11 @@ include/rocksdb/sst_dump_tool.h
 include/rocksdb/sst_file_manager.h
 include/rocksdb/sst_file_reader.h
 include/rocksdb/sst_file_writer.h
+include/rocksdb/sst_partitioner.h
 include/rocksdb/statistics.h
 include/rocksdb/stats_history.h
 include/rocksdb/status.h
+include/rocksdb/system_clock.h
 include/rocksdb/table.h
 include/rocksdb/table_properties.h
 include/rocksdb/thread_status.h
@@ -67,6 +76,7 @@ include/rocksdb/trace_reader_writer.h
 include/rocksdb/transaction_log.h
 include/rocksdb/types.h
 include/rocksdb/universal_compaction.h
+include/rocksdb/utilities/backup_engine.h
 include/rocksdb/utilities/backupable_db.h
 include/rocksdb/utilities/checkpoint.h
 include/rocksdb/utilities/convenience.h
@@ -84,6 +94,7 @@ include/rocksdb/utilities/memory_util.h
 include/rocksdb/utilities/object_registry.h
 include/rocksdb/utilities/optimistic_transaction_db.h
 include/rocksdb/utilities/option_change_migration.h
+include/rocksdb/utilities/options_type.h
 include/rocksdb/utilities/options_util.h
 include/rocksdb/utilities/sim_cache.h
 include/rocksdb/utilities/stackable_db.h
@@ -103,10 +114,11 @@ include/rocksdb/write_buffer_manager.h
 %%LITE%%lib/librocksdb-lite.so.6
 %%LITE%%lib/librocksdb-lite.so.%%SHLIB_VER%%
 %%LITE%%lib/librocksdb-lite.so.%%PORTVERSION%%
-%%LITE%%lib/librocksdb-lite_tools.a
+%%LITE%%lib/librocksdb-lite_tools.so
 lib/librocksdb.a
 lib/librocksdb.so
 lib/librocksdb.so.6
 lib/librocksdb.so.%%SHLIB_VER%%
 lib/librocksdb.so.%%PORTVERSION%%
-lib/librocksdb_tools.a
+lib/librocksdb_tools.so
+libdata/pkgconfig/rocksdb.pc