diff --git a/rocksdb/0000-toku-time-riscv.patch b/rocksdb/0000-toku-time-riscv.patch new file mode 100644 index 000000000..76497d031 --- /dev/null +++ b/rocksdb/0000-toku-time-riscv.patch @@ -0,0 +1,26 @@ +--- utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h 2021-11-25 22:20:08.918983110 +0800 ++++ utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h 2021-11-25 23:57:44.352396324 +0800 +@@ -133,6 +133,23 @@ + return result; + #elif defined(__powerpc__) + return __ppc_get_timebase(); ++#elif defined(__riscv) && __riscv_xlen == 32 ++ uint32_t cycles_lo, cycles_hi0, cycles_hi1; ++ // Implemented in assembly because Clang insisted on branching. ++ asm volatile( ++ "rdcycleh %0\n" ++ "rdcycle %1\n" ++ "rdcycleh %2\n" ++ "sub %0, %0, %2\n" ++ "seqz %0, %0\n" ++ "sub %0, zero, %0\n" ++ "and %1, %1, %0\n" ++ : "=r"(cycles_hi0), "=r"(cycles_lo), "=r"(cycles_hi1)); ++ return (static_cast(cycles_hi1) << 32) | cycles_lo; ++#elif defined(__riscv) && __riscv_xlen == 64 ++ uint64_t cycles; ++ asm volatile("rdcycle %0" : "=r"(cycles)); ++ return cycles; + #else + #error No timer implementation for this platform + #endif diff --git a/rocksdb/riscv64.patch b/rocksdb/riscv64.patch new file mode 100644 index 000000000..364bde941 --- /dev/null +++ b/rocksdb/riscv64.patch @@ -0,0 +1,23 @@ +--- PKGBUILD ++++ PKGBUILD +@@ -10,8 +10,18 @@ url="https://rocksdb.org/" + license=(GPL2 Apache) + depends=(bzip2 jemalloc lz4 snappy zlib zstd tbb liburing) + makedepends=(python) +-source=(rocksdb-$pkgver.tar.gz::https://github.com/facebook/rocksdb/archive/v$pkgver.tar.gz) +-sha256sums=('b793066463da71d31a46f31946e4fca435a7c3e73435e2bb1d062d95e0a20116') ++source=(rocksdb-$pkgver.tar.gz::https://github.com/facebook/rocksdb/archive/v$pkgver.tar.gz ++ 0000-toku-time-riscv.patch) ++sha256sums=('b793066463da71d31a46f31946e4fca435a7c3e73435e2bb1d062d95e0a20116' ++ '9bd4ddbbcad2da293026be27921057f096370894efbb16314246cbf9d463f4a2') ++ ++prepare() { ++ cd rocksdb-$pkgver ++ sed -i "s/-lpthread/-pthread/" build_tools/build_detect_platform examples/Makefile ++ ++ # see https://github.com/facebook/rocksdb/pull/9215 ++ patch -p0 -i ../0000-toku-time-riscv.patch ++} + + build() { + cd rocksdb-$pkgver