[llvm-dev] Trying to cross-compile LLVM runtimes to Windows
Shoaib Meenai via llvm-dev
llvm-dev at lists.llvm.org
Tue Nov 6 10:24:07 PST 2018
We cross-compile clang and compiler-rt for Windows on Linux. For clang, we use LLVM's WinMsvc toolchain file (https://reviews.llvm.org/diffusion/L/browse/llvm/trunk/cmake/platforms/WinMsvc.cmake). We add /manifest:no to our link flags in that toolchain file, which prevents cmake from attempting to do any mt or rc calls IIRC. I don't know if not embedding a manifest is an acceptable workaround for your use case, but it works for us. For compiler-rt, we have this weird setup (for historic reasons) where we build for Windows with an msvc triple but using the gcc-style driver, which I think ends up saving us from CMake's rc calls (though we then need some other CMake shenanigans to make lld-link happy). I wouldn't recommend going that route, but even with clang-cl the /manifest:no might save you?
From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Petr Hosek via llvm-dev <llvm-dev at lists.llvm.org>
Reply-To: Petr Hosek <phosek at chromium.org>
Date: Monday, November 5, 2018 at 7:22 PM
To: llvm-dev <llvm-dev at lists.llvm.org>
Subject: [llvm-dev] Trying to cross-compile LLVM runtimes to Windows
I've tried building libc++ for Windows on Linux by setting clang-cl as
the compiler and lld-link as the linker, but I immediately hit
roadblocks. The first issue seems to be the fact that CMake appears to
ignore the value of CMAKE_RC_COMPILER variable and hardcodes "rc" as
the resource compiler. This got resolved in upstream 12 days ago
(https://github.com/Kitware/CMake/commit/bd9bfc644954a48b1bf7ea18fc260a1231840671)
I managed to workaround this issue by symlinking llvm-rc as rc.
However, that's not sufficient because CMake uses following invocation
(https://github.com/Kitware/CMake/blob/master/Source/cmcmd.cxx#L1815):
rc /foCMakeFiles/cmTC_2c376.dir/manifest.res
CMakeFiles/cmTC_2c376.dir/manifest.rc
llvm-rc option parses requires /fo option argument to be separate.
I've modified the flag to support both joined and separate value which
helped getting past that error, but I immediately hit another error:
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_P8113&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=82qI1RuoLDjwjZpvS0PiL5VDrKw2gGPq6f7mUeLCPsM&s=H9pXwH61JYpJcujicmY5DYAehO4n0joQqSwhhdEypis&e=
The problem seems to be that the .rc file generated by CMake contains
an absolute path to the resource, but llvm-rc expects the path to be
always relative. However, I couldn't fine any documentation that would
explain whether that's a requirement and it's CMake's fault or whether
llvm-rc should be handling absolute paths as well. Is anyone familiar
with Windows resource file semantics?
All of these errors seem to suggest that this cross-compiling for
Windows with Clang using CMake isn't a well explored area. Has anyone
had more success with cross-compiling LLVM runtimes (libc++,
compiler-rt) to Windows?
_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org<mailto:llvm-dev at lists.llvm.org>
https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=82qI1RuoLDjwjZpvS0PiL5VDrKw2gGPq6f7mUeLCPsM&s=o-_kQY-hSeJzHZ7Rkst6SECmQbFm8C1WLq6OpfSbF3A&e=
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181106/32a870c5/attachment.html>
More information about the llvm-dev
mailing list