Summary
Building libmimalloc-sys2 0.1.55 for the aarch64-pc-windows-msvc target with clang as the C compiler fails because the bundled mimalloc/include/mimalloc/atomic.h calls the MSVC ARM64 intrinsics __ldar64 and __stlr64 without a declaration that clang can see. The same setup worked on 0.1.54, so this is a regression introduced in 0.1.55.
The downstream mimalloc-safe crate, when resolved to a version whose libmimalloc-sys2 constraint admits 0.1.55, breaks the aarch64-pc-windows-msvc release build for any project using TARGET_CC=clang.
Environment
- Crate:
libmimalloc-sys2 = 0.1.55
- Parent crate:
mimalloc-safe (latest at the time of the failure; the failing project pinned mimalloc-safe = "=0.1.58" and still hit this because its libmimalloc-sys2 requirement allowed 0.1.55)
- Target triple:
aarch64-pc-windows-msvc
- Host: GitHub Actions
windows-2025 runner (Windows Server 2025 Datacenter, 10.0.26100)
TARGET_CC=clang
- Rust: stable (release build via
napi build --target aarch64-pc-windows-msvc --release)
Reproduction
In a workspace whose Cargo.toml depends on mimalloc-safe (any version that resolves libmimalloc-sys2 = 0.1.55):
# On a Windows runner with clang available
set TARGET_CC=clang
cargo build --release --target aarch64-pc-windows-msvc
Minimal reproduction is available in the rolldown CI failure log:
Error output
Compiling libmimalloc-sys2 v0.1.55
warning: libmimalloc-sys2@0.1.55: In file included from ./c_src/mimalloc/src/static.c:17:
warning: libmimalloc-sys2@0.1.55: In file included from ./c_src/mimalloc/include\mimalloc/internal.h:16:
warning: libmimalloc-sys2@0.1.55: In file included from ./c_src/mimalloc/include\mimalloc\types.h:29:
warning: libmimalloc-sys2@0.1.55: ./c_src/mimalloc/include\mimalloc\atomic.h:230:14: error: call to undeclared function '__ldar64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: libmimalloc-sys2@0.1.55: 230 | return MI_MSC_XX(__ldar)((volatile const uintptr_t*)p);
warning: libmimalloc-sys2@0.1.55: | ^
warning: libmimalloc-sys2@0.1.55: ./c_src/mimalloc/include\mimalloc\atomic.h:164:23: note: expanded from macro 'MI_MSC_XX'
warning: libmimalloc-sys2@0.1.55: 164 | #define MI_MSC_XX(f) f##64
warning: libmimalloc-sys2@0.1.55: | ^
warning: libmimalloc-sys2@0.1.55: <scratch space>:9:1: note: expanded from here
warning: libmimalloc-sys2@0.1.55: 9 | __ldar64
warning: libmimalloc-sys2@0.1.55: | ^
warning: libmimalloc-sys2@0.1.55: ./c_src/mimalloc/include\mimalloc\atomic.h:252:7: error: call to undeclared function '__stlr64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: libmimalloc-sys2@0.1.55: 252 | MI_MSC_XX(__stlr)((volatile uintptr_t*)p,x);
warning: libmimalloc-sys2@0.1.55: | ^
warning: libmimalloc-sys2@0.1.55: ./c_src/mimalloc/include\mimalloc\atomic.h:273:14: error: call to undeclared function '__ldar64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: libmimalloc-sys2@0.1.55: 273 | return __ldar64((volatile const uintptr_t*)p);
warning: libmimalloc-sys2@0.1.55: | ^
warning: libmimalloc-sys2@0.1.55: ./c_src/mimalloc/include\mimalloc\atomic.h:298:7: error: call to undeclared function '__stlr64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: libmimalloc-sys2@0.1.55: 298 | __stlr64((volatile uint64_t*)p, (uint64_t)x);
warning: libmimalloc-sys2@0.1.55: | ^
warning: libmimalloc-sys2@0.1.55: 4 errors generated.
error: failed to run custom build command for `libmimalloc-sys2 v0.1.55`
Analysis
atomic.h in the bundled mimalloc sources uses __ldar64 / __stlr64 through the MI_MSC_XX macro. These are MSVC-specific ARM64 load-acquire / store-release intrinsics (declared in MSVC's <intrin.h> / <arm64intr.h>). When the file is compiled by clang targeting aarch64-pc-windows-msvc, these intrinsics are not visible, so clang reports call to undeclared function. Under newer clang defaults this is an error rather than a warning, which fails the build.
0.1.54 did not exhibit this, so the regression is in whatever change 0.1.55 made (likely a bump of the bundled mimalloc C source, or a change to the include/guard layout).
Possible fixes (one of):
- Guard the affected branches so they are only compiled under MSVC (
#if defined(_MSC_VER) && !defined(__clang__)), and fall back to the __atomic_* / inline-asm path under clang on Windows-ARM64.
- Forward-declare or include the MSVC intrinsic headers (
<intrin.h>) when targeting Windows-ARM64, including under clang-cl / clang.
- Yank
0.1.55 and re-release a fixed 0.1.56 so consumers that don't carry an explicit pin recover automatically.
Workaround for downstream users
Pin libmimalloc-sys2 to =0.1.54 in Cargo.lock:
cargo update -p libmimalloc-sys2 --precise 0.1.54
(Pinning mimalloc-safe alone is not sufficient — its version requirement still allows libmimalloc-sys2 0.1.55 to be resolved.)
Summary
Building
libmimalloc-sys2 0.1.55for theaarch64-pc-windows-msvctarget withclangas the C compiler fails because the bundledmimalloc/include/mimalloc/atomic.hcalls the MSVC ARM64 intrinsics__ldar64and__stlr64without a declaration that clang can see. The same setup worked on0.1.54, so this is a regression introduced in0.1.55.The downstream
mimalloc-safecrate, when resolved to a version whoselibmimalloc-sys2constraint admits0.1.55, breaks the aarch64-pc-windows-msvc release build for any project usingTARGET_CC=clang.Environment
libmimalloc-sys2 = 0.1.55mimalloc-safe(latest at the time of the failure; the failing project pinnedmimalloc-safe = "=0.1.58"and still hit this because itslibmimalloc-sys2requirement allowed 0.1.55)aarch64-pc-windows-msvcwindows-2025runner (Windows Server 2025 Datacenter, 10.0.26100)TARGET_CC=clangnapi build --target aarch64-pc-windows-msvc --release)Reproduction
In a workspace whose
Cargo.tomldepends onmimalloc-safe(any version that resolveslibmimalloc-sys2 = 0.1.55):Minimal reproduction is available in the rolldown CI failure log:
mimalloc-safeto=0.1.58libmimalloc-sys2to=0.1.54viaCargo.lockError output
Analysis
atomic.hin the bundled mimalloc sources uses__ldar64/__stlr64through theMI_MSC_XXmacro. These are MSVC-specific ARM64 load-acquire / store-release intrinsics (declared in MSVC's<intrin.h>/<arm64intr.h>). When the file is compiled byclangtargetingaarch64-pc-windows-msvc, these intrinsics are not visible, so clang reportscall to undeclared function. Under newer clang defaults this is an error rather than a warning, which fails the build.0.1.54did not exhibit this, so the regression is in whatever change0.1.55made (likely a bump of the bundled mimalloc C source, or a change to the include/guard layout).Possible fixes (one of):
#if defined(_MSC_VER) && !defined(__clang__)), and fall back to the__atomic_*/ inline-asm path under clang on Windows-ARM64.<intrin.h>) when targeting Windows-ARM64, including under clang-cl / clang.0.1.55and re-release a fixed0.1.56so consumers that don't carry an explicit pin recover automatically.Workaround for downstream users
Pin
libmimalloc-sys2to=0.1.54inCargo.lock:(Pinning
mimalloc-safealone is not sufficient — its version requirement still allowslibmimalloc-sys2 0.1.55to be resolved.)