[cfe-dev] Version agnostic path search for mingw

Aaron Ballman aaron at aaronballman.com
Mon Mar 19 06:44:22 PDT 2012


On Sun, Mar 18, 2012 at 4:52 AM, Nikola Smiljanic <popizdeh at gmail.com> wrote:
> Here's something we talked about on IRC, it should have two effects:
>
> 1. regex is used to match directories of the form x.x.x, this should
> be the only change for mingw-w64
> 2. clang doesn't add all the necessary paths when it comes to
> mingw.org, it only includes c:/mingw/include (hello world will fail to
> compile due to missing stddef.h). I added
> c:\MinGW\lib\gcc\mingw32\x.x.x\include and
> c:\MinGW\lib\gcc\mingw32\x.x.x\include-fixed directories. The order in
> which they are added is the same one that mingw.org uses (got this
> from gcc -xc -E -v -), this is why the call to
> AddPath("c:/mingw/include") is inside the loop even though it doesn't
> depend on any loop variable.
>
> I have no idea how this plays with MSYS and Cygwin, but it shouldn't
> change the logic, I'm only adding more paths. The code doesn't follow
> the 80 column width convention, this is something I'll change before
> submitting the patch to cfe-commits, it's just easier to read this
> way.

Overall, I like the concept!

> +void InitHeaderSearch::AddMinGWCIncludePaths(StringRef Base)
> +{
> +  llvm::error_code EC;
> +  // match directories of the form x.x.x
> +  llvm::Regex Regex("[0-9]\\.[[0-9]\\.[0-9]$");

This will only work for single digit versions.  Might want to modify
the regex to handle multi-digit releases?  Also, are there ever
releases with only a major and minor version?  Same goes for
AddMinGWCPlusPlusIncludePaths and AddMinGW64CXXPaths

Also, I wonder if we can continue the generalization of the functions
so they can be used by any of the triples which have version numbers
in their paths?

Otherwise, I really like the direction -- thanks for looking into this!

~Aaron



More information about the cfe-dev mailing list