Skip to content

change mimalloc_rust build to more strictly follow original mimalloc sources build system#160

Open
Havunen wants to merge 2 commits intopurpleprotocol:masterfrom
Havunen:feat/adjust_build_to_match_mimalloc
Open

change mimalloc_rust build to more strictly follow original mimalloc sources build system#160
Havunen wants to merge 2 commits intopurpleprotocol:masterfrom
Havunen:feat/adjust_build_to_match_mimalloc

Conversation

@Havunen
Copy link
Copy Markdown

@Havunen Havunen commented Apr 23, 2026

This PR fixes: #159

Its a workaround to compile the mimalloc using C++ compiler for Windows ARM / MSVC family

Original issue has been raised to mimalloc: microsoft/mimalloc#1277

However, there were some differences in this Rust mimalloc build system compared to mimalloc official sources, this PR addresses those.

tested here: Auto-Explore/GitComet#160

GPT 5.4 Analysis

  • For the Windows ARM/MSVC-family bug, the highest-priority gap is that git/mimalloc_rust/libmimalloc-sys/build.rs:27 still compiles src/
    static.c and only does build.cpp(true) on MSVC-like compilers at git/mimalloc_rust/libmimalloc-sys/build.rs:85. Upstream is stronger: it
    forces C++ on MSVC/clang-cl and treats src/static.c as C++ source in CMakeLists.txt:177 and CMakeLists.txt:577. I would add c++17, /Zc:__cplusplus, and
    either /TP or a .cc wrapper around static.c.

  • For release parity, build.rs only sets MI_DEBUG=0 in non-debug builds at git/mimalloc_rust/libmimalloc-sys/build.rs:75. Upstream also adds
    MI_BUILD_RELEASE in release-like configs at CMakeLists.txt:612. That matters because the vendored source checks MI_BUILD_RELEASE/NDEBUG separately in /
    home/sampo/git/mimalloc_rust/libmimalloc-sys/c_src/mimalloc/v3/include/mimalloc/types.h:73 and git/mimalloc_rust/libmimalloc-sys/c_src/
    mimalloc/v3/src/os.c:140. I would define MI_BUILD_RELEASE and NDEBUG in non-debug Cargo profiles.

  • For arm64 performance, the Rust wrapper has no equivalent to upstream MI_OPT_ARCH. Upstream auto-enables that on arm64 in CMakeLists.txt:162 and uses
    -march=armv8.1-a or /arch:armv8.1 in CMakeLists.txt:505. That is the main missing perf flag.

  • Optional but useful: expose MI_WIN_DIRECT_TLS=1 as an opt-in Windows feature from CMakeLists.txt:422, and add -fno-builtin-malloc when the Rust override
    feature is used, to match CMakeLists.txt:488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0xc0000005 access violation on aarch64-pc-windows-msvc after upgrade to 0.1.49 / libmimalloc-sys 0.1.46

1 participant