git: 09bd0656bb44 - main - databases/rocksdb-lite: Convert to normal port

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Thu, 16 Jun 2022 14:08:09 UTC
The branch main has been updated by sunpoet:

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

commit 09bd0656bb445fed1675360acc33460e6d6fde44
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-06-16 14:02:31 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-06-16 14:02:31 +0000

    databases/rocksdb-lite: Convert to normal port
---
 databases/rocksdb-lite/Makefile                    |  75 ++++++++++++-
 databases/rocksdb-lite/distinfo                    |   3 +
 databases/rocksdb-lite/files/patch-Makefile        |  40 +++++++
 databases/rocksdb-lite/files/patch-aarch64         |  14 +++
 .../files/patch-build_tools-build_detect_platform  | 115 +++++++++++++++++++
 .../rocksdb-lite/files/patch-db-db_test_util.cc    | 120 ++++++++++++++++++++
 databases/rocksdb-lite/files/patch-memory-arena.cc |  11 ++
 databases/rocksdb-lite/files/patch-memory-arena.h  |  11 ++
 .../rocksdb-lite/files/patch-memory-arena_test.cc  |  11 ++
 .../rocksdb-lite/files/patch-port-stack_trace.cc   |  20 ++++
 databases/rocksdb-lite/files/patch-powerpc64       |  25 +++++
 ...-party-gtest-1.8.1-fused-src-gtest-gtest-all.cc |  11 ++
 databases/rocksdb-lite/pkg-descr                   |  10 ++
 databases/rocksdb-lite/pkg-plist                   | 122 +++++++++++++++++++++
 14 files changed, 584 insertions(+), 4 deletions(-)

diff --git a/databases/rocksdb-lite/Makefile b/databases/rocksdb-lite/Makefile
index 8c047e0159e7..9db7f37f5bf7 100644
--- a/databases/rocksdb-lite/Makefile
+++ b/databases/rocksdb-lite/Makefile
@@ -1,16 +1,83 @@
 # Created by: David Thiel <lx@FreeBSD.org>
 
-PORTREVISION=	0
+PORTNAME=	rocksdb
+PORTVERSION=	7.2.2
+DISTVERSIONPREFIX=	v
+CATEGORIES=	databases
+PKGNAMESUFFIX=	-lite
 
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Persistent key-value store for fast storage environments (lite version)
 
-LITE=		yes
-MASTERDIR=	${.CURDIR}/../rocksdb
+LICENSE=	APACHE20 GPLv2
+LICENSE_COMB=	dual
+LICENSE_FILE_APACHE20=	${WRKSRC}/LICENSE.Apache
+LICENSE_FILE_GPLv2=	${WRKSRC}/COPYING
 
+BROKEN_DragonFly=	does not build on DragonFly BSD using GCC with -Werror
 BROKEN_armv6=	does not build: db/compaction_job.cc:714:52: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'const size_t' (aka 'const unsigned int')
 BROKEN_armv7=	does not build: db/compaction_job.cc:714:52: error: implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long') to 'const size_t' (aka 'const unsigned int')
 BROKEN_i386=	does not build: tools/db_bench_tool.cc:6320:25: error: non-constant-expression cannot be narrowed from type 'uint64_t' (aka 'unsigned long long') to 'size_t' (aka 'unsigned int') in initializer list
+BROKEN_FreeBSD_12_powerpc64=	does not build: util/crc32c.cc:435:22: 'arch_ppc_probe' was not declared in this scope
 BROKEN=		does not build: strip: open /wrkdirs/usr/ports/databases/rocksdb-lite/work/stage/usr/local/lib/librocksdb-lite.so failed: No such file or directory
 
-.include "${MASTERDIR}/Makefile"
+BUILD_DEPENDS=	bash:shells/bash
+LIB_DEPENDS=	libgflags.so:devel/gflags \
+		libsnappy.so:archivers/snappy
+
+USES=		compiler:c++17-lang gmake localbase:ldflags perl5
+USE_PERL5=	build
+
+ALL_TARGET=	shared_lib static_lib all
+CFLAGS+=	-DOS_FREEBSD -DROCKSDB_LITE=1
+CONFIGURE_ARGS=	make_config.mk
+CONFIGURE_ENV=	PORTABLE=0 ROCKSDB_ROOT=${WRKSRC}
+CONFIGURE_SCRIPT=	build_tools/build_detect_platform
+HAS_CONFIGURE=	yes
+MAKE_ENV=	CXX=${CXX} DISABLE_JEMALLOC=1 INSTALL_PATH=${STAGEDIR}${PREFIX} LIBNAME=librocksdb-lite USE_RTTI=1
+USE_CXXSTD=	c++17
+USE_LDCONFIG=	yes
+TEST_TARGET=	check
+
+PLIST_SUB=	PORTVERSION=${PORTVERSION} SHLIB_VER=${PORTVERSION:R}
+PORTDATA=	make_config.mk
+
+GH_ACCOUNT=	facebook
+USE_GITHUB=	yes
+
+CONFLICTS_INSTALL=	rocksdb
+
+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
+LZ4_MAKE_ENV_OFF=	ROCKSDB_DISABLE_LZ4=yes
+ZSTD_LIB_DEPENDS=	libzstd.so:archivers/zstd
+ZSTD_MAKE_ENV_OFF=	ROCKSDB_DISABLE_ZSTD=yes
+
+.include <bsd.port.pre.mk>
+
+.if ${CHOSEN_COMPILER_TYPE} == clang
+CXXFLAGS+=	-Wno-inconsistent-missing-override -Wno-unused-parameter -Wno-unused-variable -Wno-unused-private-field
+.endif
+
+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
+.else
+	@${REINPLACE_CMD} -e 's| -march=native||' ${WRKSRC}/build_tools/build_detect_platform
+.endif
+
+post-install:
+	${MKDIR} ${STAGEDIR}${DATADIR}/
+	cd ${WRKSRC}/ && ${INSTALL_PROGRAM} ${BENCHMARKS} ${TOOLS} ${STAGEDIR}${PREFIX}/bin/
+	${INSTALL_DATA} ${WRKSRC}/librocksdb${PKGNAMESUFFIX}_tools.so ${STAGEDIR}${PREFIX}/lib/
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/librocksdb${PKGNAMESUFFIX}.so ${STAGEDIR}${PREFIX}/lib/librocksdb${PKGNAMESUFFIX}_tools.so
+	${INSTALL_DATA} ${WRKSRC}/make_config.mk ${STAGEDIR}${DATADIR}/
+
+.include <bsd.port.post.mk>
diff --git a/databases/rocksdb-lite/distinfo b/databases/rocksdb-lite/distinfo
new file mode 100644
index 000000000000..fb5cc02a5a39
--- /dev/null
+++ b/databases/rocksdb-lite/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1652122553
+SHA256 (facebook-rocksdb-v7.2.2_GH0.tar.gz) = c4ea6bd2e3ffe3f0f8921c699234d59108c9122d61b0ba2aa78358642a7b614e
+SIZE (facebook-rocksdb-v7.2.2_GH0.tar.gz) = 9549844
diff --git a/databases/rocksdb-lite/files/patch-Makefile b/databases/rocksdb-lite/files/patch-Makefile
new file mode 100644
index 000000000000..2c820e4c7ab6
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-Makefile
@@ -0,0 +1,40 @@
+--- Makefile.orig	2022-03-10 06:51:01 UTC
++++ Makefile
+@@ -220,17 +220,17 @@ 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)"; \
+-                  export PORTABLE="$(PORTABLE)"; \
+-                  export ROCKSDB_NO_FBCODE="$(ROCKSDB_NO_FBCODE)"; \
+-                  export USE_CLANG="$(USE_CLANG)"; \
+-                  export LIB_MODE="$(LIB_MODE)"; \
+-                  "$(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)"; \
++#                  export PORTABLE="$(PORTABLE)"; \
++#                  export ROCKSDB_NO_FBCODE="$(ROCKSDB_NO_FBCODE)"; \
++#                  export USE_CLANG="$(USE_CLANG)"; \
++#                  export LIB_MODE="$(LIB_MODE)"; \
++#                  "$(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
+ 
+@@ -796,7 +796,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 $(ROCKSDBTESTS_SUBSET)
+ 
diff --git a/databases/rocksdb-lite/files/patch-aarch64 b/databases/rocksdb-lite/files/patch-aarch64
new file mode 100644
index 000000000000..31790f595624
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-aarch64
@@ -0,0 +1,14 @@
+--- CMakeLists.txt.orig	2021-06-25 21:15:04 UTC
++++ CMakeLists.txt
+@@ -612,6 +612,11 @@ if(HAVE_AUXV_GETAUXVAL)
+   add_definitions(-DROCKSDB_AUXV_GETAUXVAL_PRESENT)
+ endif()
+ 
++check_cxx_symbol_exists(elf_aux_info sys/auxv.h HAVE_ELF_AUX_INFO)
++if(HAVE_ELF_AUX_INFO)
++  add_definitions(-DROCKSDB_AUXV_GETAUXVAL_PRESENT)
++endif()
++
+ include_directories(${PROJECT_SOURCE_DIR})
+ include_directories(${PROJECT_SOURCE_DIR}/include)
+ if(WITH_FOLLY_DISTRIBUTED_MUTEX)
diff --git a/databases/rocksdb-lite/files/patch-build_tools-build_detect_platform b/databases/rocksdb-lite/files/patch-build_tools-build_detect_platform
new file mode 100644
index 000000000000..cbf3251be4f3
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-build_tools-build_detect_platform
@@ -0,0 +1,115 @@
+Remove -fno-builtin-memcmp and -ltcmalloc
+
+% sed -i .orig 's| -fno-builtin-memcmp||; s| -ltcmalloc||' build_tools/build_detect_platform
+
+--- build_tools/build_detect_platform.orig	2022-02-17 23:56:08 UTC
++++ build_tools/build_detect_platform
+@@ -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" " "`
+ 
+-# On GCC, we pick libc's memcmp over GCC's memcmp via -fno-builtin-memcmp
++# On GCC, we pick libc's memcmp over GCC's memcmp via
+ case "$TARGET_OS" in
+     Darwin)
+         PLATFORM=OS_MACOSX
+@@ -166,7 +166,7 @@ case "$TARGET_OS" in
+         PLATFORM=OS_LINUX
+         COMMON_FLAGS="$COMMON_FLAGS -DOS_LINUX"
+         if [ -z "$USE_CLANG" ]; then
+-            COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp"
++            COMMON_FLAGS="$COMMON_FLAGS"
+         else
+             PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
+         fi
+@@ -193,21 +193,21 @@ EOF
+         ;;
+     SunOS)
+         PLATFORM=OS_SOLARIS
+-        COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_SOLARIS -m64"
++        COMMON_FLAGS="$COMMON_FLAGS -D_REENTRANT -DOS_SOLARIS -m64"
+         PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt -static-libstdc++ -static-libgcc -m64"
+         # PORT_FILES=port/sunos/sunos_specific.cc
+         ;;
+     AIX)
+         PLATFORM=OS_AIX
+         CC=gcc
+-        COMMON_FLAGS="$COMMON_FLAGS -maix64 -pthread -fno-builtin-memcmp -D_REENTRANT -DOS_AIX -D__STDC_FORMAT_MACROS"
++        COMMON_FLAGS="$COMMON_FLAGS -maix64 -pthread -D_REENTRANT -DOS_AIX -D__STDC_FORMAT_MACROS"
+         PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -pthread -lpthread -lrt -maix64 -static-libstdc++ -static-libgcc"
+         # PORT_FILES=port/aix/aix_specific.cc
+         ;;
+     FreeBSD)
+         PLATFORM=OS_FREEBSD
+         CXX=clang++
+-        COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_FREEBSD"
++        COMMON_FLAGS="$COMMON_FLAGS -D_REENTRANT -DOS_FREEBSD"
+         PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread"
+         # PORT_FILES=port/freebsd/freebsd_specific.cc
+         ;;
+@@ -215,7 +215,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
+@@ -224,14 +224,14 @@ EOF
+         ;;
+     NetBSD)
+         PLATFORM=OS_NETBSD
+-        COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_NETBSD"
++        COMMON_FLAGS="$COMMON_FLAGS -D_REENTRANT -DOS_NETBSD"
+         PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lgcc_s"
+         # PORT_FILES=port/netbsd/netbsd_specific.cc
+         ;;
+     OpenBSD)
+         PLATFORM=OS_OPENBSD
+ 	CXX=clang++
+-        COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_OPENBSD"
++        COMMON_FLAGS="$COMMON_FLAGS -D_REENTRANT -DOS_OPENBSD"
+         PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -pthread"
+         # PORT_FILES=port/openbsd/openbsd_specific.cc
+ 	FIND=gfind
+@@ -239,7 +239,7 @@ EOF
+         ;;
+     DragonFly)
+         PLATFORM=OS_DRAGONFLYBSD
+-        COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_DRAGONFLYBSD"
++        COMMON_FLAGS="$COMMON_FLAGS -D_REENTRANT -DOS_DRAGONFLYBSD"
+         PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread"
+         # PORT_FILES=port/dragonfly/dragonfly_specific.cc
+         ;;
+@@ -249,7 +249,7 @@ EOF
+         PLATFORM_CXXFLAGS="-std=gnu++11"
+         COMMON_FLAGS="$COMMON_FLAGS -DCYGWIN"
+         if [ -z "$USE_CLANG" ]; then
+-            COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp"
++            COMMON_FLAGS="$COMMON_FLAGS"
+         else
+             PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic"
+         fi
+@@ -258,7 +258,7 @@ EOF
+         ;;
+     OS_ANDROID_CROSSCOMPILE)
+         PLATFORM=OS_ANDROID
+-	COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp -D_REENTRANT -DOS_ANDROID -DROCKSDB_PLATFORM_POSIX"
++	COMMON_FLAGS="$COMMON_FLAGS -D_REENTRANT -DOS_ANDROID -DROCKSDB_PLATFORM_POSIX"
+ 	PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS "  # All pthread features are in the Android C library
+         # PORT_FILES=port/android/android.cc
+         CROSS_COMPILE=true
+@@ -448,9 +448,9 @@ EOF
+     if ! test $JEMALLOC && ! test $ROCKSDB_DISABLE_TCMALLOC; then
+         # jemalloc is not available. Let's try tcmalloc
+         if echo 'int main() {}' | $CXX $PLATFORM_CXXFLAGS -x c++ - -o test.o \
+-          -ltcmalloc 2>/dev/null; then
+-            PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -ltcmalloc"
+-            JAVA_LDFLAGS="$JAVA_LDFLAGS -ltcmalloc"
++          2>/dev/null; then
++            PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS"
++            JAVA_LDFLAGS="$JAVA_LDFLAGS"
+         fi
+     fi
+ 
diff --git a/databases/rocksdb-lite/files/patch-db-db_test_util.cc b/databases/rocksdb-lite/files/patch-db-db_test_util.cc
new file mode 100644
index 000000000000..472503e88f1f
--- /dev/null
+++ b/databases/rocksdb-lite/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-lite/files/patch-memory-arena.cc b/databases/rocksdb-lite/files/patch-memory-arena.cc
new file mode 100644
index 000000000000..db76c877c68f
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-memory-arena.cc
@@ -0,0 +1,11 @@
+--- memory/arena.cc.orig	2021-06-25 21:15:04 UTC
++++ memory/arena.cc
+@@ -29,7 +29,7 @@ const size_t Arena::kInlineSize;
+ 
+ const size_t Arena::kMinBlockSize = 4096;
+ const size_t Arena::kMaxBlockSize = 2u << 30;
+-static const int kAlignUnit = alignof(max_align_t);
++static const int kAlignUnit = alignof(std::max_align_t);
+ 
+ size_t OptimizeBlockSize(size_t block_size) {
+   // Make sure block_size is in optimal range
diff --git a/databases/rocksdb-lite/files/patch-memory-arena.h b/databases/rocksdb-lite/files/patch-memory-arena.h
new file mode 100644
index 000000000000..a1dda117600a
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-memory-arena.h
@@ -0,0 +1,11 @@
+--- memory/arena.h.orig	2018-01-31 01:15:39 UTC
++++ memory/arena.h
+@@ -82,7 +82,7 @@ class Arena : public Allocator {
+   }
+ 
+  private:
+-  char inline_block_[kInlineSize] __attribute__((__aligned__(alignof(max_align_t))));
++  char inline_block_[kInlineSize] __attribute__((__aligned__(alignof(std::max_align_t))));
+   // Number of bytes allocated in one block
+   const size_t kBlockSize;
+   // Array of new[] allocated memory blocks
diff --git a/databases/rocksdb-lite/files/patch-memory-arena_test.cc b/databases/rocksdb-lite/files/patch-memory-arena_test.cc
new file mode 100644
index 000000000000..ccbdef9fc0b7
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-memory-arena_test.cc
@@ -0,0 +1,11 @@
+--- memory/arena_test.cc.orig	2018-01-31 01:15:39 UTC
++++ memory/arena_test.cc
+@@ -91,7 +91,7 @@ static void ApproximateMemoryUsageTest(s
+   ASSERT_EQ(kZero, arena.ApproximateMemoryUsage());
+ 
+   // allocate inline bytes
+-  const size_t kAlignUnit = alignof(max_align_t);
++  const size_t kAlignUnit = alignof(std::max_align_t);
+   EXPECT_TRUE(arena.IsInInlineBlock());
+   arena.AllocateAligned(kAlignUnit);
+   EXPECT_TRUE(arena.IsInInlineBlock());
diff --git a/databases/rocksdb-lite/files/patch-port-stack_trace.cc b/databases/rocksdb-lite/files/patch-port-stack_trace.cc
new file mode 100644
index 000000000000..3b83846c5101
--- /dev/null
+++ b/databases/rocksdb-lite/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-lite/files/patch-powerpc64 b/databases/rocksdb-lite/files/patch-powerpc64
new file mode 100644
index 000000000000..1cebaf2dbac2
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-powerpc64
@@ -0,0 +1,25 @@
+--- utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h.orig	2021-12-10 22:56:20 UTC
++++ utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h
+@@ -58,7 +58,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliate
+ #include <stdint.h>
+ #include <sys/time.h>
+ #include <time.h>
+-#if defined(__powerpc__)
++#if defined(__powerpc__) && defined(__linux__)
+ #include <sys/platform/ppc.h>
+ #endif
+ 
+@@ -132,7 +132,13 @@ static inline tokutime_t toku_time_now(void) {
+   __asm __volatile__("mrs %[rt], cntvct_el0" : [ rt ] "=r"(result));
+   return result;
+ #elif defined(__powerpc__)
++#ifdef __linux__
+   return __ppc_get_timebase();
++#elif defined(__FreeBSD__)
++  int64_t tbr;
++  asm volatile("mfspr %0, 268" : "=r"(tbr));
++  return tbr;
++#endif
+ #elif defined(__s390x__)
+   uint64_t result;
+   asm volatile("stckf %0" : "=Q"(result) : : "cc");
diff --git a/databases/rocksdb-lite/files/patch-third-party-gtest-1.8.1-fused-src-gtest-gtest-all.cc b/databases/rocksdb-lite/files/patch-third-party-gtest-1.8.1-fused-src-gtest-gtest-all.cc
new file mode 100644
index 000000000000..73b2d08ed88a
--- /dev/null
+++ b/databases/rocksdb-lite/files/patch-third-party-gtest-1.8.1-fused-src-gtest-gtest-all.cc
@@ -0,0 +1,11 @@
+--- third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc.orig	2020-05-27 23:38:10 UTC
++++ third-party/gtest-1.8.1/fused-src/gtest/gtest-all.cc
+@@ -35,7 +35,7 @@
+ 
+ // This line ensures that gtest.h can be compiled on its own, even
+ // when it's fused.
+-#include "gtest/gtest.h"
++#include "gtest.h"
+ 
+ // The following lines pull in the real gtest *.cc files.
+ // Copyright 2005, Google Inc.
diff --git a/databases/rocksdb-lite/pkg-descr b/databases/rocksdb-lite/pkg-descr
new file mode 100644
index 000000000000..a8ef4259b2b1
--- /dev/null
+++ b/databases/rocksdb-lite/pkg-descr
@@ -0,0 +1,10 @@
+RocksDB is an embeddable persistent key-value store for fast storage. RocksDB
+can also be the foundation for a client-server database but our current focus is
+on embedded workloads.
+
+RocksDB builds on LevelDB to be scalable to run on servers with many CPU cores,
+to efficiently use fast storage, to support IO-bound, in-memory and write-once
+workloads, and to be flexible to allow for innovation.
+
+WWW: https://rocksdb.org/
+WWW: https://github.com/facebook/rocksdb
diff --git a/databases/rocksdb-lite/pkg-plist b/databases/rocksdb-lite/pkg-plist
new file mode 100644
index 000000000000..43d53a2c7a64
--- /dev/null
+++ b/databases/rocksdb-lite/pkg-plist
@@ -0,0 +1,122 @@
+bin/blob_dump
+bin/cache_bench
+bin/db_bench
+bin/db_repl_stress
+bin/db_sanity_test
+bin/db_stress
+bin/ldb
+bin/memtablerep_bench
+bin/persistent_cache_bench
+bin/range_del_aggregator_bench
+bin/rocksdb_dump
+bin/rocksdb_undump
+bin/sst_dump
+bin/table_reader_bench
+bin/trace_analyzer
+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
+include/rocksdb/db_stress_tool.h
+include/rocksdb/env.h
+include/rocksdb/env_encryption.h
+include/rocksdb/experimental.h
+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
+include/rocksdb/ldb_tool.h
+include/rocksdb/listener.h
+include/rocksdb/memory_allocator.h
+include/rocksdb/memtablerep.h
+include/rocksdb/merge_operator.h
+include/rocksdb/metadata.h
+include/rocksdb/options.h
+include/rocksdb/perf_context.h
+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
+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
+include/rocksdb/threadpool.h
+include/rocksdb/trace_reader_writer.h
+include/rocksdb/trace_record.h
+include/rocksdb/trace_record_result.h
+include/rocksdb/transaction_log.h
+include/rocksdb/types.h
+include/rocksdb/unique_id.h
+include/rocksdb/universal_compaction.h
+include/rocksdb/utilities/agg_merge.h
+include/rocksdb/utilities/backup_engine.h
+include/rocksdb/utilities/cache_dump_load.h
+include/rocksdb/utilities/checkpoint.h
+include/rocksdb/utilities/convenience.h
+include/rocksdb/utilities/customizable_util.h
+include/rocksdb/utilities/db_ttl.h
+include/rocksdb/utilities/debug.h
+include/rocksdb/utilities/env_mirror.h
+include/rocksdb/utilities/info_log_finder.h
+include/rocksdb/utilities/ldb_cmd.h
+include/rocksdb/utilities/ldb_cmd_execute_result.h
+include/rocksdb/utilities/leveldb_options.h
+include/rocksdb/utilities/lua/rocks_lua_custom_library.h
+include/rocksdb/utilities/lua/rocks_lua_util.h
+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/replayer.h
+include/rocksdb/utilities/sim_cache.h
+include/rocksdb/utilities/stackable_db.h
+include/rocksdb/utilities/table_properties_collectors.h
+include/rocksdb/utilities/transaction.h
+include/rocksdb/utilities/transaction_db.h
+include/rocksdb/utilities/transaction_db_mutex.h
+include/rocksdb/utilities/write_batch_with_index.h
+include/rocksdb/version.h
+include/rocksdb/wal_filter.h
+include/rocksdb/write_batch.h
+include/rocksdb/write_batch_base.h
+include/rocksdb/write_buffer_manager.h
+lib/librocksdb-lite.a
+lib/librocksdb-lite.so
+lib/librocksdb-lite.so.7
+lib/librocksdb-lite.so.%%SHLIB_VER%%
+lib/librocksdb-lite.so.%%PORTVERSION%%
+lib/librocksdb-lite_tools.so
+libdata/pkgconfig/rocksdb.pc