Skip to content

Commit

Permalink
don't use system jemalloc
Browse files Browse the repository at this point in the history
  • Loading branch information
zaidoon1 committed Mar 3, 2024
1 parent 2fbae42 commit bb1c934
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ jobs:
- name: Install dependencies
if: runner.os == 'Windows'
run: choco install llvm -y

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install libjemalloc-dev

- name: Run rocksdb tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion librocksdb-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exclude = [

[features]
default = ["static"]
jemalloc = ["tikv-jemalloc-sys", "pkg-config"]
jemalloc = ["tikv-jemalloc-sys"]
static = ["libz-sys?/static", "bzip2-sys?/static"]
io-uring = ["pkg-config"]
snappy = []
Expand Down
22 changes: 10 additions & 12 deletions librocksdb-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
use std::path::Path;
use std::{env, fs, path::PathBuf, process::Command};

// On these platforms jemalloc-sys will use a prefixed jemalloc which cannot be linked together
// with RocksDB.
// See https://github.com/tikv/jemallocator/blob/tikv-jemalloc-sys-0.5.3/jemalloc-sys/src/env.rs#L25
const NO_JEMALLOC_TARGETS: &[&str] = &["android", "dragonfly", "musl", "darwin"];

fn link(name: &str, bundled: bool) {
use std::env::var;
let target = var("TARGET").unwrap();
Expand Down Expand Up @@ -218,18 +223,11 @@ fn build_rocksdb() {

config.define("ROCKSDB_SUPPORT_THREAD_LOCAL", None);

#[cfg(feature = "jemalloc")]
{
if target.contains("linux") {
pkg_config::probe_library("jemalloc")
.expect("The jemalloc feature was requested but jemalloc is not installed");
config.define("ROCKSDB_JEMALLOC", Some("1"));
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
} else {
// this doesn't actually enable jemalloc, but mac/windows needs more
// work to make it work (statically link tikv-jemalloc). For now,
// I'll keep this as is.
config.define("WITH_JEMALLOC", "ON");
if cfg!(feature = "jemalloc") && NO_JEMALLOC_TARGETS.iter().all(|i| !target.contains(i)) {
config.define("ROCKSDB_JEMALLOC", Some("1"));
config.define("JEMALLOC_NO_DEMANGLE", Some("1"));
if let Some(jemalloc_root) = env::var_os("DEP_JEMALLOC_ROOT") {
config.include(Path::new(&jemalloc_root).join("include"));
}
}

Expand Down

0 comments on commit bb1c934

Please sign in to comment.