Skip to content

Commit 274f535

Browse files
committed
fix: use mimalloc only on x86_64 to avoid cross-compilation issues
- Make mimalloc an optional dependency with feature flag - Only enable mimalloc on x86_64 architecture - ARM targets (aarch64, armv7) will use system default allocator - This avoids the libmimalloc-sys build issue with -Wdate-time flag on cross-compilation The libmimalloc-sys v0.1.44 build script uses -Wno-error=date-time flag which is not supported by ARM cross-compilers. By conditionally using mimalloc only on x86_64, we avoid this issue entirely while still getting the performance benefits on the most common platform.
1 parent 4f6151b commit 274f535

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ socket2 = "0.6"
8989
libc = "0.2"
9090
clap-verbosity-flag = { version = "3.0.4", default-features = false, features = ["tracing"] }
9191
chrono = { version = "0.4.42", features = ["clock"] }
92-
mimalloc = { version = "0.1", features = ["v3"] }
92+
mimalloc = { version = "0.1", features = ["v3"], optional = true }
9393
compact_str = { version = "0.9", features = ["serde"] }
9494
smallvec = { version = "1.13", features = ["serde"] }
9595

9696
[features]
97-
default = []
97+
default = ["mimalloc"]
9898
metrics = ["prometheus", "lazy_static"]
99+
mimalloc = ["dep:mimalloc"]
99100

100101
[build-dependencies]
101102
anyhow = "1.0.95"

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// Use mimalloc only on x86_64 to avoid cross-compilation issues
2+
#[cfg(all(feature = "mimalloc", target_arch = "x86_64"))]
13
use mimalloc::MiMalloc;
24

5+
#[cfg(all(feature = "mimalloc", target_arch = "x86_64"))]
36
#[global_allocator]
47
static GLOBAL: MiMalloc = MiMalloc;
58

0 commit comments

Comments
 (0)