mimalloc icon indicating copy to clipboard operation
mimalloc copied to clipboard

Fix windows clang compiling

Open MaxwellGengYF opened this issue 4 months ago • 4 comments

_lzcnt_u64 may not supported by native LLVM compiler on Windows.

MaxwellGengYF avatar Aug 07 '25 06:08 MaxwellGengYF

I don't have any issues with compiling mimalloc3 with LLVM under Visual Studio (for more than half a year), could you elaborate?

solbjorn avatar Aug 22 '25 19:08 solbjorn

I don't have any issues with compiling mimalloc3 with LLVM under Visual Studio (for more than half a year), could you elaborate?

When you are using Visual-Studio, you are actually using clang-cl.exe instead of clang.exe, which the driver mode is like cl.exe instead of 'original' clang

MaxwellGengYF avatar Sep 07 '25 02:09 MaxwellGengYF

I don't have any issues with compiling mimalloc3 with LLVM under Visual Studio (for more than half a year), could you elaborate?

When you are using Visual-Studio, you are actually using clang-cl.exe instead of clang.exe, which the driver mode is like cl.exe instead of 'original' clang

But you added the condition under the _MSC_VER definition, which assumes either clang-cl OR clang -fms-compatibility. Both of them should provide the function you're trying to toss off.

__clang__ is defined under both clang and clang-cl, so your check should be more precise either way. For example, set via a CMake feature test whether the function is available.

solbjorn avatar Sep 07 '25 09:09 solbjorn

Hmm, yes, the current test seems correct; on my system clang-cl works fine? If you can test your scenario further why _lzcnt_u64 is not supported that would be great.

daanx avatar Nov 06 '25 00:11 daanx