<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014/1/14 Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div dir="ltr"><div><div class="gmail_extra">On Sun, Jan 12, 2014 at 3:20 AM, Ruben Van Boxem <span dir="ltr"><<a href="mailto:vanboxem.ruben@gmail.com" target="_blank">vanboxem.ruben@gmail.com</a>></span> wrote:<br>

</div>
</div><div class="gmail_extra"><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<div><div><div>Hi,<br><br></div>I'm planning to take a much-needed look at MinGW(-w64) compatibility in the Clang driver. What I'm hoping to accomplish is the following:<br></div>1. allow 'clang -target [i686,x86_64]-w64-mingw32' to:<br>



1a) search /usr/[i686,x86_64]-w64-mingw32/[include,lib] and certain subdirectories for C(++) headers and libraries,<br></div><div>1b) use [i686,x86_64]-w64-mingw32-[as,ld,...] instead of what is currently (as of Clang 3.3 in my Arch Linux installation, will soon test a top of trunk build) [as,ld,...]<br>



</div><div>1c) set the necessary libraries to link in various situations.<br></div><div>2) Build a toolchain:<br>2a) that uses GNU binutils, Clang, and GNU libgcc/libstdc++ and make it work.<br></div><div>2b) that uses GNU binutils, Clang, LLVM compiler-rt, and GNU libstdc++ and make it work.<br>


</div></div></blockquote><div><br></div></div><div>Sounds good! </div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div></div><div>For this, I'd like to introduce a new Toolchain subclass, MinGWToolchain, which takes care of the *-*-mingw32 triplets.<br><br></div><div>I'm unsure of several things:<br></div><div>


1) where is the target triple "converted" into a Toolchain instance?<br></div></div></blockquote><div><br></div></div><div>Driver::getToolChain() in Driver.cpp</div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div class="gmail_extra">
<div class="gmail_quote"><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div>
</div><div>2) how can I pass triplet-specific include dirs at configure/cmake time? This would not really be necessary, but actually really is if Clang is to be used as an "ultra-cross"-compiler targetting every triplet under the sun from one binary (which is an awesome idea).<br>


</div></div></blockquote><div><br></div></div><div>I'm not sure exactly what the question is.</div></div></div></div></blockquote><div><br></div><div>I was talking about the<code> --with-c-include-dirs</code> and associated configure options. But I now believe my MinGWToolChain and related work will include these settings hardcoded in the driver, which is much better. So forget this question :-)<br>

<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"><div></div><div>I have read the sparse Driver documentation, and unfortunately not found an answer to the above issues. I would appreciate any substantial help anyone can give me in these departments. I'd like to do this right so the changes can stay (unlike my previous InitHeaderSearch hacks)<br>


</div></div></blockquote><div><br></div></div><div>We have driver documentation?  I wasn't aware of it.  :)  I'd look at clang/test/Driver for some of the existing header / library search tests.</div></div></div>

</div></blockquote><div><br></div><div>OK, thanks. I'll be sure to take a look there.<br><br>Attached is a *preliminary* patch adding MinGW-w64 driver support. This includes:<br></div><div> - C(++) system include directories<br>
</div><div> - C(++) system libraries<br></div><div> - basic "Hello World" C and C++ test compiles and links on Arch Linux with the mingw-w64-gcc toolchain packages installed. Clang now calls the cross binutils directly instead of linking with cross gcc. <br>
</div><div><br></div><div>This patch is missing:<br></div><div> - more than basic testing (including a Windows native Clang, which will take some manual installation steps)<br></div><div> - dll import lib options,<br></div>
<div> - MinGW(.org) search directories. I'll get to this once I solve the next point;<br></div><div> - Cross GCC version detection: I know the Generic_GCC ToolChain has machinery to do this, but it also adds the /usr/include and /usr/local/include directories, and probably some native library directories which I really really don't want. Is there an easy way to get at the cross GCC version at the ToolChain level?<br>
<br></div><div>Once I get the GCC version (which is hardcoded in attached patch), I'll fix up the rest and this should be ready in no time!<br><br></div><div>Another question for later: how do I build the libgcc replacing part of compiler-rt for a specific target? Is there CMake build machinery to build a number of target libraries or do I need to build them separately and manually (not really a problem, just need to know how)?<br>
</div><div><br></div><div>Cheers!<br><br></div><div>Ruben<br><br>PS: I'm not subscribed to cfe-dev, please CC me directly.</div></div></div></div>