Use the system allocator on sparc64 hosts

mold crashed at startup on sparc64 Linux, which maps user memory at
sign-extended high addresses. mimalloc v3 registers pages in a map that
covers only 48-bit addresses, so the first registration wrote out of
bounds. Until the bundled mimalloc handles that layout, sparc64 hosts use
the system allocator (https://github.com/rui314/mold/issues/1639).
This commit is contained in:
Rui Ueyama committed 2026-10-01 10:09:13 +09:00
1 parent 64325c31cc
commit bd97ebc907
2 files changed
+9 -3

No files matched your search

+4 -1
View File
@@ -15,7 +15,6 @@ path = "integration.rs"
harness = false
[dependencies]
mimalloc = { git = "https://github.com/rui314/mimalloc_rust", rev = "cc58b72775b8b5bc89ee37752af61fcb4f7c2909" }
mold.workspace = true
mold-target-x86_64 = { path = "../arch/x86_64", optional = true }
mold-target-i386 = { path = "../arch/i386", optional = true }
@@ -38,6 +37,10 @@ mold-target-sh4be = { path = "../arch/sh4be", optional = true }
mold-target-loongarch64 = { path = "../arch/loongarch64", optional = true }
mold-target-loongarch32 = { path = "../arch/loongarch32", optional = true }
# sparc64 uses the system allocator. See main.rs.
[target.'cfg(not(target_arch = "sparc64"))'.dependencies]
mimalloc = { git = "https://github.com/rui314/mimalloc_rust", rev = "cc58b72775b8b5bc89ee37752af61fcb4f7c2909" }
[dev-dependencies]
mold-tests = { path = "../tests" }
+5 -2
View File
@@ -4,8 +4,11 @@
//! decides which of them are built in.
// A Rust executable can define only one global allocator, so select mimalloc
// here rather than in the linker library.
#[cfg(not(feature = "system-allocator"))]
// here rather than in the linker library. sparc64 uses the system allocator
// because Linux maps sparc64 user memory at sign-extended high addresses,
// which mimalloc's page map does not cover
// (https://github.com/rui314/mold/issues/1639).
#[cfg(not(any(feature = "system-allocator", target_arch = "sparc64")))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;