[cfe-commits] Fix sysrooted MinGW header search paths

Ruben Van Boxem vanboxem.ruben at gmail.com
Sat Jun 18 07:21:52 PDT 2011

Attached is a patch to search directories relative to the cland
executable location. This enables the common sysrooted MinGW to be
used effectively.

I needed to add a HeaderSearchOptions paramater to
AddDefaultCPlusPlusIncludePaths, just like AddDefaultCIncludePaths
already had. I used the ResourceDir Path variable to generate a
correct relative path. I added all current versions of
x86_64-w64-mingw32 C++ include paths, and corrected the mingw-w64 crt
header path.

This is half-hacky, but on top of all the hackery already present,
this seems like an OK solution for now.

This is what I propose in the long/"short future":

1. Change the HeaderSearchOptions ResourceDir variable to something
more generally useful, like SysrootDir or something, and change the
present use of that variable accordingly.
2. Enable some form of sysroot via configure/cmake that enables only
these special directories to be searched. If not enabled, default to
old behavior. This would place most of InitHeaderSearch.cpp in #ifdef
LLVM_SYSROOT which is a good thing: less non-existing directories are
3. (long future) move the sysroot variable to some abstracter
structure, to enable clang to also find system libraries once it can
replace the system linker.

Why is this necessary? The current form of --with-cxx-include-*
configury does not allow relocation, which is very common and
important on Windows. There is no "root filesystem".

I can easily add the MinGW.org directories as well, but as the note in
the file already mentions, there needs to be a way to find
i686-w64-mingw32 (in the configure/cmake process), because its headers
are located elsewhere. If there is a good way to convert a triple into
a string, all of mingw-w64 (maybe even mingw.org) can be summarised in
a couple of lines, without much if/switch work.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: mingwsysroot.patch
Type: application/octet-stream
Size: 3304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110618/d1fd8da7/attachment.obj>

More information about the cfe-commits mailing list