microsoft / microsoft/mimalloc
aligned_alloc not detected on musl
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 13.4k
- Forks
- 1.2k
- Avg merge
- 4d 45m
- Merged PRs (30d)
- 13
Description
prior merge request related to this: https://github.com/microsoft/mimalloc/pull/385
the #if check in https://github.com/microsoft/mimalloc/blob/f2712f4a8f038a7fb4df2790f4c3b7e3ed9e219b/src/alloc-override.c#L241-L248
fails to detect aligned_alloc when built on alpine linux with musl, because __USE_ISOC11 is not defined anywhere in musl or gcc. this just makes aligned_alloc always return null when used with mimalloc (tested via LD_PRELOAD only), which makes it unusable for anything that uses aligned_alloc.
this can be worked around by manually adding CFLAGS="-D__USE_ISOC11" when building mimalloc to force the detection, but is there any better way to detect it here via the build system or some other macros so it doesn't have to be? aligned_alloc is part of the c11/c++17 standards https://github.com/microsoft/mimalloc/blob/f2712f4a8f038a7fb4df2790f4c3b7e3ed9e219b/CMakeLists.txt#L4-L5 (see https://en.cppreference.com/w/cpp/memory/c/aligned_alloc and https://en.cppreference.com/w/c/memory/aligned_alloc), so it can be assumed to exist, and if some downstream needs a workaround for it due to their own definitions (conda) they should have a way to disable it instead (maybe a -DMIMALLOC_NO_ALIGNED_MALLOC via cmake, etc.)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue on Alpine Linux with musl, then inspect the #if check in src/alloc-override.c around lines 241-248 and the C11/C++17 settings in CMakeLists.txt around lines 4-5. Done means aligned_alloc is detected without manually defining __USE_ISOC11, while downstream builds can still disable the behavior if their own definitions require it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cmake, linux
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100