<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">We cross-compile clang and compiler-rt for Windows on Linux. For clang, we use LLVM's WinMsvc toolchain file (<a href="https://reviews.llvm.org/diffusion/L/browse/llvm/trunk/cmake/platforms/WinMsvc.cmake">https://reviews.llvm.org/diffusion/L/browse/llvm/trunk/cmake/platforms/WinMsvc.cmake</a>).
 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?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Petr Hosek via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Reply-To: </b>Petr Hosek <phosek@chromium.org><br>
<b>Date: </b>Monday, November 5, 2018 at 7:22 PM<br>
<b>To: </b>llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject: </b>[llvm-dev] Trying to cross-compile LLVM runtimes to Windows<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I've tried building libc++ for Windows on Linux by setting clang-cl as<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">the compiler and lld-link as the linker, but I immediately hit<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">roadblocks. The first issue seems to be the fact that CMake appears to<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">ignore the value of CMAKE_RC_COMPILER variable and hardcodes "rc" as<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">the resource compiler. This got resolved in upstream 12 days ago<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">(<a href="https://github.com/Kitware/CMake/commit/bd9bfc644954a48b1bf7ea18fc260a1231840671">https://github.com/Kitware/CMake/commit/bd9bfc644954a48b1bf7ea18fc260a1231840671</a>)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I managed to workaround this issue by symlinking llvm-rc as rc.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">However, that's not sufficient because CMake uses following invocation<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">(<a href="https://github.com/Kitware/CMake/blob/master/Source/cmcmd.cxx#L1815">https://github.com/Kitware/CMake/blob/master/Source/cmcmd.cxx#L1815</a>):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">rc /foCMakeFiles/cmTC_2c376.dir/manifest.res<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">CMakeFiles/cmTC_2c376.dir/manifest.rc<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">llvm-rc option parses requires /fo option argument to be separate.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I've modified the flag to support both joined and separate value which<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">helped getting past that error, but I immediately hit another error:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_P8113&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=82qI1RuoLDjwjZpvS0PiL5VDrKw2gGPq6f7mUeLCPsM&s=H9pXwH61JYpJcujicmY5DYAehO4n0joQqSwhhdEypis&e=">https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_P8113&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=82qI1RuoLDjwjZpvS0PiL5VDrKw2gGPq6f7mUeLCPsM&s=H9pXwH61JYpJcujicmY5DYAehO4n0joQqSwhhdEypis&e=</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">The problem seems to be that the .rc file generated by CMake contains<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">an absolute path to the resource, but llvm-rc expects the path to be<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">always relative. However, I couldn't fine any documentation that would<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">explain whether that's a requirement and it's CMake's fault or whether<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">llvm-rc should be handling absolute paths as well. Is anyone familiar<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">with Windows resource file semantics?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">All of these errors seem to suggest that this cross-compiling for<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Windows with Clang using CMake isn't a well explored area. Has anyone<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">had more success with cross-compiling LLVM runtimes (libc++,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">compiler-rt) to Windows?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">_______________________________________________<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">LLVM Developers mailing list<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><a href="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=">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=</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
</body>
</html>