diff --git a/Cargo.toml b/Cargo.toml index 670e80ff..5135fa52 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ libc = "0.2" # jemalloc is currently disabled on macOS due to a bug in jemalloc in combination with macOS # Catalina. See https://github.com/sharkdp/fd/issues/498 for details. [target.'cfg(all(not(windows), not(target_os = "android"), not(target_os = "macos"), not(target_os = "freebsd"), not(target_env = "musl")))'.dependencies] -jemallocator = "0.3.0" +jemallocator = {version = "0.3.0", optional = true} [dev-dependencies] diff = "0.1" @@ -77,3 +77,7 @@ test-case = "1.2" [profile.release] lto = true codegen-units = 1 + +[features] +use-jemalloc = ["jemallocator"] +default = ["use-jemalloc"] \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 56d6bfb8..8ff14780 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,8 @@ use crate::regex_helper::{pattern_has_uppercase_char, pattern_matches_strings_wi not(target_os = "android"), not(target_os = "macos"), not(target_os = "freebsd"), - not(target_env = "musl") + not(target_env = "musl"), + feature = "use-jemalloc" ))] #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;