Closed bluesillybeard closed 7 months ago
1 is nonsense for a C-lib by the way and when you use clang on Windows you are already linking lots of msvc libs anyway.
Ok then, I'll go ahead and use --compile
to make a lib, instead of using --json
to load the data into Zig. It makes cross-compilation difficult but that's ok.
I found out why linking an MSVC lib with Clang doesn't work. No, it's not nonsense; and in fact is expected to happen.
Clang, as far as I know, will always link mingwex.lib
, which defines a bunch of synbols, including __guard_check_icall_fptr
and __guard_dispatch_icall_fptr
. However, the lib from MSVC already defines those symbols so the linker errors because of duplicate symbols.
Unless you have a decent way to fix this, I'm going to have to compile it entirely with Clang.
Would you accept a pull request that refactors the code so it compiles with Clang as well as MSVC?
That's not a clang problem, that's a mingw problem and you don't need to use mingw libs with clang - but maybe Zig forces that, no idea. If you need to use mingw I don't think there is much hope.
By setting the ABI to msvc, I was able to get it to work! (yay)
Is your feature request related to a problem? Please describe. I am creating a Zig binding for Kinc. As part of that binding, Kinc is compiled with Zig, which uses Clang under the hood.
The problem is, Clang does not compile the code for Windows. It gives a bunch of errors, presumably because the code is written assuming the MSBuild compiler.
Describe the solution you'd like Honestly, I don't know what a solution would look like. I don't know if this is as easy as adding some configs in Clang, or as fundamental as completely rewriting all of the Windows code.
Describe alternatives you've considered clang-cl looks like a good option, but Zig's version of Clang is statically linked into Zig itself, so that is not really an option.
It's possible to use Kmake to compile the library instead, then link the application against the library. This is undesirable for a few reasons: