Skip to content

Commit 68d4f96

Browse files
authored
Define correct name for jemalloc (rust-rocksdb#989)
* Define correct name for jemalloc `WITH_JEMALLOC` is not recognized by rocksdb. `ROCKSDB_JEMALLOC` is the correct one.
1 parent 3884a77 commit 68d4f96

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.github/workflows/rust.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
with:
6767
cache-on-failure: true
6868
- name: Install dependencies
69-
run: sudo apt-get update && sudo apt-get install -y liburing-dev pkg-config
69+
run: sudo apt-get update && sudo apt-get install -y liburing-dev pkg-config libjemalloc-dev
7070
- name: Set PKG_CONFIG_PATH
7171
run: echo "PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig" >> $GITHUB_ENV
7272
- name: Run clippy
@@ -124,6 +124,9 @@ jobs:
124124
- name: Install dependencies
125125
if: runner.os == 'Windows'
126126
run: choco install llvm -y
127+
- name: Install dependencies (Linux)
128+
if: runner.os == 'Linux'
129+
run: sudo apt-get update && sudo apt-get install -y libjemalloc-dev
127130
- name: Mark working directory as read-only
128131
if: runner.os == 'Linux'
129132
run: |

librocksdb-sys/build.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
use std::path::Path;
22
use std::{env, fs, path::PathBuf, process::Command};
33

4+
// On these platforms jemalloc-sys will use a prefixed jemalloc which cannot be linked together
5+
// with RocksDB.
6+
// See https://github.com/tikv/jemallocator/blob/tikv-jemalloc-sys-0.5.3/jemalloc-sys/src/env.rs#L25
7+
const NO_JEMALLOC_TARGETS: &[&str] = &["android", "dragonfly", "musl", "darwin"];
8+
49
fn link(name: &str, bundled: bool) {
510
use std::env::var;
611
let target = var("TARGET").unwrap();
@@ -242,8 +247,12 @@ fn build_rocksdb() {
242247

243248
config.define("ROCKSDB_SUPPORT_THREAD_LOCAL", None);
244249

245-
if cfg!(feature = "jemalloc") {
246-
config.define("WITH_JEMALLOC", "ON");
250+
if cfg!(feature = "jemalloc") && NO_JEMALLOC_TARGETS.iter().all(|i| !target.contains(i)) {
251+
config.define("ROCKSDB_JEMALLOC", Some("1"));
252+
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
253+
if let Some(jemalloc_root) = env::var_os("DEP_JEMALLOC_ROOT") {
254+
config.include(Path::new(&jemalloc_root).join("include"));
255+
}
247256
}
248257

249258
#[cfg(feature = "io-uring")]

0 commit comments

Comments
 (0)