Skip to content

Commit

Permalink
Skip jemalloc options on specific platform (rust-rocksdb#324)
Browse files Browse the repository at this point in the history
On some platforms jemalloc-sys adds a prefix when building its jemalloc. Thus it is not suitable to use jemalloc-sys to provide a jemalloc in such platforms, otherwise this will lead to a link error.
  • Loading branch information
breezewish authored and yiwu-arbug committed Jul 25, 2019
1 parent a0d3b92 commit 9246b9c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion librocksdb_sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ use cmake::Config;
use std::path::PathBuf;
use std::{env, str};

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

fn main() {
let mut build = build_rocksdb();

Expand Down Expand Up @@ -71,13 +76,15 @@ fn link_cpp(build: &mut Build) {
}

fn build_rocksdb() -> Build {
let target = env::var("TARGET").expect("TARGET was not set");

let mut build = Build::new();
for e in env::vars() {
println!("{:?}", e);
}

let mut cfg = Config::new("rocksdb");
if cfg!(feature = "jemalloc") {
if cfg!(feature = "jemalloc") && NO_JEMALLOC_TARGETS.iter().all(|i| !target.contains(i)) {
cfg.register_dep("JEMALLOC").define("WITH_JEMALLOC", "ON");
}
if cfg!(feature = "portable") {
Expand Down

0 comments on commit 9246b9c

Please sign in to comment.