Commit 9246b9c5 authored by Wenxuan's avatar Wenxuan Committed by yiwu-arbug

Skip jemalloc options on specific platform (#324)

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.
parent a0d3b924
...@@ -19,6 +19,11 @@ use cmake::Config; ...@@ -19,6 +19,11 @@ use cmake::Config;
use std::path::PathBuf; use std::path::PathBuf;
use std::{env, str}; 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() { fn main() {
let mut build = build_rocksdb(); let mut build = build_rocksdb();
...@@ -71,13 +76,15 @@ fn link_cpp(build: &mut Build) { ...@@ -71,13 +76,15 @@ fn link_cpp(build: &mut Build) {
} }
fn build_rocksdb() -> Build { fn build_rocksdb() -> Build {
let target = env::var("TARGET").expect("TARGET was not set");
let mut build = Build::new(); let mut build = Build::new();
for e in env::vars() { for e in env::vars() {
println!("{:?}", e); println!("{:?}", e);
} }
let mut cfg = Config::new("rocksdb"); 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"); cfg.register_dep("JEMALLOC").define("WITH_JEMALLOC", "ON");
} }
if cfg!(feature = "portable") { if cfg!(feature = "portable") {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment