Skip to content

Commit fb75b98

Browse files
authored
fix: Use jemalloc on platforms that mimalloc fails to build (#10116)
**Description:** Github Actions run: https://github.com/swc-project/swc/actions/runs/13560294213/job/37902319812
1 parent 7d8cfe6 commit fb75b98

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

Diff for: .changeset/rich-beers-pay.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
swc_core: minor
3+
swc_malloc: minor
4+
---
5+
6+
fix: Use `jemalloc` on platforms that `mimalloc` fails to build

Diff for: Cargo.lock

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: crates/swc_malloc/Cargo.toml

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ bench = false
1313

1414
[dependencies]
1515

16-
[target.'cfg(not(any(target_os = "linux", target_family = "wasm", target_env = "musl")))'.dependencies]
16+
[target.'cfg(not(any(target_os = "linux", target_family = "wasm", target_env = "musl", all(target_os="linux", target_env = "gnu", target_arch="arm"))))'.dependencies]
1717
mimalloc = { version = "0.1.43", features = [] }
1818

19-
[target.'cfg(all(target_os = "linux", not(any(target_family = "wasm", target_env = "musl"))))'.dependencies]
19+
[target.'cfg(all(target_os = "linux", not(any(target_family = "wasm", target_env = "musl", all(target_os="linux", target_env = "gnu", target_arch="arm")))))'.dependencies]
2020
mimalloc = { version = "0.1.43", features = ["local_dynamic_tls"] }
21+
22+
[target.'cfg(all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"))'.dependencies]
23+
tikv-jemallocator = { version = "0.5", features = ["disable_initial_exec_tls"] }

Diff for: crates/swc_malloc/src/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
//!
33
//! The swc crates related to the node binding should depend on this crate.
44
5-
#[cfg(not(any(target_family = "wasm", target_env = "musl")))]
5+
#[cfg(not(any(
6+
target_family = "wasm",
7+
target_env = "musl",
8+
all(target_os = "linux", target_env = "gnu", target_arch = "aarch64")
9+
)))]
610
#[global_allocator]
711
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
12+
13+
// On linux aarch64, mimalloc fails to build.
14+
// So we use tikv-jemallocator instead.
15+
16+
#[cfg(all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"))]
17+
#[global_allocator]
18+
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

0 commit comments

Comments
 (0)