Skip to content

prim.c: prefer Emscripten's implementation over WASI - #1455

Merged
Daan (daanx) merged 1 commit into
microsoft:dev3from
kleisauke:dev3-prefer-emscripten-over-wasi
Oct 24, 2026
Merged

Daan (daanx) merged 1 commit into
microsoft:dev3from
kleisauke:dev3-prefer-emscripten-over-wasi

Conversation

@kleisauke

Copy link
Copy Markdown
Contributor

Fixes a regression introduced in commit f72b7a0.


That commit moved the include directives before platform selection, i.e.:

--- a/src/prim/prim.c
+++ b/src/prim/prim.c
@@ -5,6 +5,10 @@ terms of the MIT license. A copy of the license can be found in the file
 "LICENSE" at the root of this distribution.
 -----------------------------------------------------------------------------*/
 
+#include "mimalloc/heap/init.h"
+#include "mimalloc/prim.h"
+
+
 // Select the implementation of the primitives
 // depending on the OS.
 
@@ -26,9 +30,6 @@ terms of the MIT license. A copy of the license can be found in the file
 
 #endif
 
-#include "mimalloc/internal/init.h"
-#include "mimalloc/internal/prim.h"
-
 // Generic process initialization
 #if !defined(MI_PRIM_HAS_PROCESS_ATTACH)
 #if defined(__GNUC__) || defined(__clang__)

which causes mimalloc/heap/init.h to transitively include mimalloc/decl.h, which defines __wasi__ for Emscripten builds.

#if defined(__EMSCRIPTEN__) && !defined(__wasi__)
#define __wasi__
#endif

This consequently selects the WASI backend when building with Emscripten. Fix this by preferring Emscripten's implementation instead.

Fixes a regression introduced in commit f72b7a0.
@daanx
Daan (daanx) merged commit d348cba into microsoft:dev3 Oct 24, 2026
1 check passed
@daanx

Copy link
Copy Markdown
Collaborator

Thank you! I will try to include emscripten in the test workflow to hopefully prevent this in the future.

@kleisauke
Kleis Auke Wolthuizen (kleisauke) deleted the dev3-prefer-emscripten-over-wasi branch October 24, 2026 17:50
Daan (daanx) added a commit that referenced this pull request Oct 25, 2026
…ing to less memory usage); allow environment variables from emscripten, see also issue #1455
Techcable pushed a commit to Techcable/mimalloc that referenced this pull request Oct 26, 2026
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.

2 participants