From c52f7634dedcf15b04bfb0eb00955ce4787762d9 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 11 Nov 2025 23:00:48 -0500 Subject: [PATCH] Patch `librocksdb-sys` to never enable `jemalloc`, which conflicts with mimalloc Allows us to update mimalloc and enable the newly added guard pages. Conflict identified by @PlasmaPower. --- Cargo.toml | 20 ++++++++++-------- orchestration/src/mimalloc.rs | 8 +++---- patches/librocksdb-sys/Cargo.toml | 35 +++++++++++++++++++++++++++++++ patches/librocksdb-sys/src/lib.rs | 1 + 4 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 patches/librocksdb-sys/Cargo.toml create mode 100644 patches/librocksdb-sys/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 0824af84..688d6e98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,10 +171,6 @@ ark-ff-4 = { package = "ark-ff", path = "patches/ethereum/ark-ff-0.4" } c-kzg = { path = "patches/ethereum/c-kzg" } secp256k1-30 = { package = "secp256k1", path = "patches/ethereum/secp256k1-30" } -# Updates to the latest version -darling = { path = "patches/darling" } -thiserror = { path = "patches/thiserror" } - # Dependencies from monero-oxide which originate from within our own tree std-shims = { path = "patches/std-shims" } simple-request = { path = "patches/simple-request" } @@ -185,12 +181,18 @@ dalek-ff-group = { path = "crypto/dalek-ff-group" } minimal-ed448 = { path = "crypto/ed448" } modular-frost = { path = "crypto/frost" } +# Patch due to `std` now including the required functionality +is_terminal_polyfill = { path = "./patches/is_terminal_polyfill" } +# This has a non-deprecated `std` alternative since Rust's 2024 edition +home = { path = "patches/home" } + +# Updates to the latest version +darling = { path = "patches/darling" } +thiserror = { path = "patches/thiserror" } + # https://github.com/rust-lang-nursery/lazy-static.rs/issues/201 lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev = "5735630d46572f1e5377c8f2ba0f79d18f53b10c" } -# These has an `std` alternative since Rust's 2024 edition -home = { path = "patches/home" } - # directories-next was created because directories was unmaintained # directories-next is now unmaintained while directories is maintained # The directories author pulls in ridiculously pointless crates and prefers @@ -203,8 +205,8 @@ directories-next = { path = "patches/directories-next" } k256 = { git = "https://github.com/kayabaNerve/elliptic-curves", rev = "4994c9ab163781a88cd4a49beae812a89a44e8c3" } p256 = { git = "https://github.com/kayabaNerve/elliptic-curves", rev = "4994c9ab163781a88cd4a49beae812a89a44e8c3" } -# Patch due to `std` now including the required functionality -is_terminal_polyfill = { path = "./patches/is_terminal_polyfill" } +# `jemalloc` conflicts with `mimalloc`, so patch to a `rocksdb` which never uses `jemalloc` +librocksdb-sys = { path = "patches/librocksdb-sys" } [workspace.lints.clippy] incompatible_msrv = "allow" # Manually verified with a GitHub workflow diff --git a/orchestration/src/mimalloc.rs b/orchestration/src/mimalloc.rs index 73b866e8..5e8bcbff 100644 --- a/orchestration/src/mimalloc.rs +++ b/orchestration/src/mimalloc.rs @@ -7,10 +7,10 @@ FROM alpine:latest AS mimalloc-alpine RUN apk update && apk upgrade && apk --no-cache add gcc g++ libc-dev make cmake git RUN git clone https://github.com/microsoft/mimalloc && \ cd mimalloc && \ - git checkout 43ce4bd7fd34bcc730c1c7471c99995597415488 && \ + git checkout fbd8b99c2b828428947d70fdc046bb55609be93e && \ mkdir -p out/secure && \ cd out/secure && \ - cmake -DMI_SECURE=ON ../.. && \ + cmake -DMI_SECURE=ON -DMI_GUARDED=on ../.. && \ make && \ cp ./libmimalloc-secure.so ../../../libmimalloc.so "#; @@ -21,10 +21,10 @@ FROM debian:trixie-slim AS mimalloc-debian RUN apt update && apt upgrade -y && apt install -y gcc g++ make cmake git RUN git clone https://github.com/microsoft/mimalloc && \ cd mimalloc && \ - git checkout 43ce4bd7fd34bcc730c1c7471c99995597415488 && \ + git checkout fbd8b99c2b828428947d70fdc046bb55609be93e && \ mkdir -p out/secure && \ cd out/secure && \ - cmake -DMI_SECURE=ON ../.. && \ + cmake -DMI_SECURE=ON -DMI_GUARDED=on ../.. && \ make && \ cp ./libmimalloc-secure.so ../../../libmimalloc.so "#; diff --git a/patches/librocksdb-sys/Cargo.toml b/patches/librocksdb-sys/Cargo.toml new file mode 100644 index 00000000..6a3175ff --- /dev/null +++ b/patches/librocksdb-sys/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "librocksdb-sys" +version = "0.17.99" +description = "Replacement for `librocksdb-sys` which removes the `jemalloc` feature" +license = "MIT" +repository = "https://github.com/serai-dex/serai/tree/develop/patches/librocksdb-sys" +authors = ["Luke Parker "] +keywords = [] +edition = "2018" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[workspace] + +[dependencies] +# librocksdb-sys 0.17.3+10.4.2, with the commit provided by crates.io in `cargo_vcs_info.json` +librocksdb-sys = { git = "https://github.com/rust-rocksdb/rust-rocksdb", commit = "bb7d2168eab1bc7849f23adbcb825e3aba1bd2f4", default-features = false } + +[features] +default = ["librocksdb-sys/default"] +jemalloc = [] +static = ["librocksdb-sys/static"] +bindgen-runtime = ["librocksdb-sys/bindgen-runtime"] +bindgen-static = ["librocksdb-sys/bindgen-static"] +mt_static = ["librocksdb-sys/mt_static"] +io-uring = ["librocksdb-sys/io-uring"] +snappy = ["librocksdb-sys/snappy"] +lz4 = ["librocksdb-sys/lz4"] +zstd = ["librocksdb-sys/zstd"] +zlib = ["librocksdb-sys/zlib"] +bzip2 = ["librocksdb-sys/bzip2"] +rtti = ["librocksdb-sys/rtti"] +lto = ["librocksdb-sys/lto"] diff --git a/patches/librocksdb-sys/src/lib.rs b/patches/librocksdb-sys/src/lib.rs new file mode 100644 index 00000000..3178f28e --- /dev/null +++ b/patches/librocksdb-sys/src/lib.rs @@ -0,0 +1 @@ +pub use librocksdb_sys::*;