From 4ecbdd5ef332432492b39ee855767f1c160e2934 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Thu, 25 Apr 2024 21:03:27 +0100 Subject: [PATCH] adding no_thp option (for Linux/Android). --- Cargo.toml | 1 + libmimalloc-sys/Cargo.toml | 1 + libmimalloc-sys/build.rs | 6 ++++++ 3 files changed, 8 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 2768be2..3b3c137 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,4 @@ override = ["libmimalloc-sys/override"] debug = ["libmimalloc-sys/debug"] debug_in_debug = ["libmimalloc-sys/debug_in_debug"] local_dynamic_tls = ["libmimalloc-sys/local_dynamic_tls"] +no_thp = ["libmimalloc-sys/no_thp"] diff --git a/libmimalloc-sys/Cargo.toml b/libmimalloc-sys/Cargo.toml index 0534296..3221cc4 100644 --- a/libmimalloc-sys/Cargo.toml +++ b/libmimalloc-sys/Cargo.toml @@ -33,6 +33,7 @@ override = [] extended = ["cty"] arena = [] local_dynamic_tls = [] +no_thp = [] # Show `extended` on docs.rs since it's the full API surface. [package.metadata.docs.rs] diff --git a/libmimalloc-sys/build.rs b/libmimalloc-sys/build.rs index 7cc9379..fc1743e 100644 --- a/libmimalloc-sys/build.rs +++ b/libmimalloc-sys/build.rs @@ -32,6 +32,12 @@ fn main() { } } + if (target_os == "linux" || target_os == "android") + && env::var_os("CARGO_FEATURE_NO_THP").is_some() + { + build.define("MI_NO_THP", "1"); + } + if env::var_os("CARGO_FEATURE_DEBUG").is_some() || (env::var_os("CARGO_FEATURE_DEBUG_IN_DEBUG").is_some() && cfg!(debug_assertions)) {