Issues when crosscompiling with clang-cl (Linux to Windows)
When using Ninja as a generator and using clang-cl as compiler to crosscompile for windows there are a few things that go wrong.
First CMake fails to pick up on llvm-rc
, llvm-link
, and llvm-mt
.
Making a symlink for these will cause both link
and mt
to be picked up immediately, but rc
is not.
Instead I have to do export RC=/opt/winclang/bin/llvm-rc
. But this doesn't mean that you don't need the rc
symlink, as the configure stage needs it.
Please change the configure stage to use the cmake flags instead of hardcoded filenames, this should also make it a little more future proof.
This might have to introduce an extra CMAKE_MANIFEST_COMPILER
variable (I assume it's a compiler), but so be it.
In addition, please please check for the existence for llvm-*
when searching for these tools.
Now when it configures everything seems to be going well, except that rules.ninja has wrong dependency rules for all .rc
files.
It uses deps = gcc
instead of deps = msvc
, which causes it to prepend the commandline with some (what I assume to be) ninja internal information.
I managed to work around this by defining set(CMAKE_NINJA_DEPTYPE_RC msvc)
under set(CMAKE_NINJA_DEPTYPE_${lang} msvc)
in Platform/Windows-MSVC.cmake
, but I don't know if this break anything on Windows, as I didn't test it.
Another thing I had to add to llvm-mt
was support for the undocumented /notify_update
flag, I think it's bad practice to rely on undocumented behavior as it's harder to replicate the behavior correctly.
Please remove this in favor of a more manual method, as I'd rather get a small hit in performance than a broken build because I/llvm implemented the behavior incorrectly.