<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=Windows-1252">
<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:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1203522349;
mso-list-type:hybrid;
mso-list-template-ids:-1938502616 -1 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1
{mso-list-id:1716730918;
mso-list-type:hybrid;
mso-list-template-ids:2038082692 -1 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l1:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l1:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">I want to build llvm + clang + lld + compiler-rt on Linux to build a windows host toolchain for example.
</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In GNU toolchain, it is 2 step.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<ol style="margin-top:0cm" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo2">Build a target cross toolchain</li></ol>
<p class="MsoNormal" style="text-indent:36.0pt">Binutils : --target=x86_64-w64-mingw32 (multilib)</p>
<p class="MsoNormal" style="margin-left:18.0pt"> MinGW-w64-crt header files: --target=x86_64-w64-mingw32, --host=x86_64-w64-mingw32</p>
<p class="MsoNormal" style="margin-left:18.0pt"> GCC, gcc part: --target=x86_64-w64-mingw32 (multilib)</p>
<p class="MsoNormal" style="margin-left:18.0pt"> MinGW-w64-crt: --target=x86_64-w64-mingw32, --host=x86_64-w64-mingw32</p>
<p class="MsoNormal" style="margin-left:18.0pt"> GCC libgcc and libstdc++: --target=x86_64-w64-mingw32</p>
<p class="MsoNormal" style="margin-left:18.0pt;text-indent:18.0pt">Done</p>
<ol style="margin-top:0cm" start="2" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo2">Use this target x86_64-w64-mingw32 cross toolchain to build a new host toolchain</li></ol>
<p class="MsoListParagraph">Binutils : --target=x86_64-w64-mingw32 (multilib) –host= x86_64-w64-mingw32 –disable-gdb</p>
<p class="MsoListParagraph">GCC: --target=x86_64-w64-mingw32 (multilib) –host= x86_64-w64-mingw32</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> Then copy the CRT build from the first target cross toolchain in this host toolchain.</p>
<p class="MsoNormal"> Then we can use this new host toolchain and use it to build programs.
</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, I try the same thing with llvm, I could not do it. cmake will do stupid checks to prevent me to just do the 2<sup>nd</sup> part.</p>
<p class="MsoNormal"> I could not even use clang –target=x86_64-windows-gnu -fuse-ld=lld to build a host GCC since it fails to build gmp, only GCC could build that.</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I think this is extremely important as a cross compiler. You want to bootstrap another toolchain from this platform to a new platform to make the new platform self host.</p>
<p class="MsoNormal">However, I guess it is very hard for LLVM, since it requires python and all kinds of other dependencies which the target cross toolchain does not provide.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The largest issue is clearly cmake, which prevents cross compilation.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I do not know what is the solution here.</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">
Mail</a> for Windows 10</p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>