Skip to content

Commit

Permalink
Apply build script suggestions from purpleprotocol#58 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomcc committed Mar 6, 2021
1 parent dcadf23 commit 2f8256c
Showing 1 changed file with 8 additions and 29 deletions.
37 changes: 8 additions & 29 deletions libmimalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,27 @@ fn main() {
let mut build = cc::Build::new();

build.include("c_src/mimalloc/include");
build.files(
[
"alloc-aligned",
"alloc-posix",
"alloc",
"arena",
"bitmap",
"heap",
"init",
"options",
"os",
"page",
"random",
"region",
"segment",
"stats",
]
.iter()
.map(|fname| format!("c_src/mimalloc/src/{}.c", fname)),
);

build.define("MI_STATIC_LIB", None);
build.include("c_src/mimalloc/src");
build.file("c_src/mimalloc/src/static.c");

let target_os = env::var("CARGO_CFG_TARGET_OS").expect("target_os not defined!");
let target_family = env::var("CARGO_CFG_TARGET_FAMILY").expect("target_family not defined!");

if cfg!(feature = "override") {
if env::var_os("CARGO_FEATURE_OVERRIDE").is_some() {
// Overriding malloc is only available on windows in shared mode, but we
// only ever build a static lib.
if target_os != "windows" {
if target_family != "windows" {
build.define("MI_MALLOC_OVERRIDE", None);
}
}

if cfg!(feature = "secure") {
if env::var_os("CARGO_FEATURE_SECURE").is_some() {
build.define("MI_SECURE", "4");
}

let dynamic_tls = cfg!(feature = "local_dynamic_tls");
let dynamic_tls = env::var("CARGO_FEATURE_LOCAL_DYNAMIC_TLS").is_ok();

if env::var("CARGO_CFG_TARGET_FAMILY").expect("target family not set") == "unix"
&& target_os != "haiku"
{
if target_family == "unix" && target_os != "haiku" {
if dynamic_tls {
build.flag_if_supported("-ftls-model=local-dynamic");
} else {
Expand Down

0 comments on commit 2f8256c

Please sign in to comment.