mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

mimalloc3 wasi target fails to compile

Open andreiltd opened this issue 3 months ago • 1 comments

I get the compilation errors when I try to build mimalloc3 using wasi target.

git clone --branch v3.1.5 https://github.com/microsoft/mimalloc.git
~/w/h/s/h/t/mimalloc ((v3.1.5)) [1]> ~/workspace/build/wasi-sdk-23.0-x86_64-linux/bin/clang src/static.c -I include/ -I src/ --sysroot ~/workspace/build/wasi-sdk-23.0-x86_64-linux/share/wasi-sysroot/
In file included from src/static.c:38:
In file included from src/prim/prim.c:19:
src/prim/wasi/prim.c:92:33: error: call to undeclared function 'mi_align_up_ptr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   92 |         void* aligned_current = mi_align_up_ptr(current, try_alignment);  // and align from there to minimize wasted space
      |                                 ^
src/prim/wasi/prim.c:92:33: note: did you mean '_mi_align_up_ptr'?
include/mimalloc/internal.h:441:24: note: '_mi_align_up_ptr' declared here
  441 | static inline uint8_t* _mi_align_up_ptr(void* p, size_t alignment) {
      |                        ^
In file included from src/static.c:38:
In file included from src/prim/prim.c:19:
src/prim/wasi/prim.c:92:15: error: incompatible integer to pointer conversion initializing 'void *' with an expression of type 'int' [-Wint-conversion]
   92 |         void* aligned_current = mi_align_up_ptr(current, try_alignment);  // and align from there to minimize wasted space
      |               ^                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/prim/wasi/prim.c:101:11: error: call to undeclared function 'mi_align_up_ptr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  101 |       p = mi_align_up_ptr(base, try_alignment);
      |           ^
src/prim/wasi/prim.c:101:9: error: incompatible integer to pointer conversion assigning to 'void *' from 'int' [-Wint-conversion]
  101 |       p = mi_align_up_ptr(base, try_alignment);
      |         ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.

I'm able to get rid of those by s/mi_align_up_ptr/_mi_align_up_ptr. I'm happy to create PR if that's what needed to fix it.

andreiltd avatar Sep 05 '25 07:09 andreiltd

Same issue here building from the 3.0.10 tag. I've just added -Dmi_align_up_ptr=_mi_align_up_ptr to work around it.

photex avatar Nov 14 '25 08:11 photex