Skip to content

Commit cc1bc44

Browse files
committed
Use mimalloc when targeting musl
1 parent c7b8551 commit cc1bc44

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Cargo.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objdiff-cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ supports-color = "3.0"
2828
time = { version = "0.3", features = ["formatting", "local-offset"] }
2929
tracing = "0.1"
3030
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
31+
32+
[target.'cfg(target_env = "musl")'.dependencies]
33+
mimalloc = "0.1"

objdiff-cli/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ mod argp_version;
22
mod cmd;
33
mod util;
44

5+
// musl's allocator is very slow, so use mimalloc when targeting musl.
6+
// Otherwise, use the system allocator to avoid extra code size.
7+
#[cfg(target_env = "musl")]
8+
#[global_allocator]
9+
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
10+
511
use std::{env, ffi::OsStr, fmt::Display, path::PathBuf, str::FromStr};
612

713
use anyhow::{Error, Result};

0 commit comments

Comments
 (0)