Adds support for mimalloc with static linking on Linux, for testing purposes, the following combination works:
- -DLLVM_INTEGRATED_CRT_ALLOC=mimalloc and -DLLVM_LINK_LLVM_DYLIB=OFF
I have been working on testing rpmalloc and mimalloc as custom allocators with clang on Linux. Neither of them works out of the box with dynamic linking due to a hang bug in glibc 2.31 (Ubuntu 20.04LTS) elf/rtld.c:_dl_start_final which I have not yet debugged fully. As a result this patch just adds support for mimalloc with static linking (LLVM_LINK_LLVM_DYLIB=OFF) which was the only configuration I could get working.
Most of the patch is implementing CMake constraints conditions similar to the Windows support so that CMake will report errors for combinations that do not work, so it checks LLVM_LINK_LLVM_DYLIB and only allows mimalloc on Linux. The patch expects mimalloc to be checked out next to the LLVM directory same as the Windows support. Unlike the windows patch, mimalloc is added as a CMake subdirectory and mimalloc-static is properly exported into LLVM's CMake.
It adds the following error messages:
- LLVM_INTEGRATED_CRT_ALLOC is only supported on Windows and Linux.
- LLVM_INTEGRATED_CRT_ALLOC currently only supports mimalloc on Linux!"
- LLVM_INTEGRATED_CRT_ALLOC cannot be used with LLVM_LINK_LLVM_DYLIB on Linux!"