Hi,<br><br>I found a problem and I am writing to propose a solution, I would like to know what you think.<br>I am working on Win32 with MinGW (GCC 4.4)<br>                           <br>I quote an extract of the InitHeaderSearch class ( /tools/clang/lib/Frontend/InitHeaderSearch.cpp )<br>
<br><div style="margin-left: 40px; font-family: courier new,monospace;">//----------------------------------------------------------------------------------------------------<br><br>void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base,<br>
                                                     llvm::StringRef Arch,<br>                                                     llvm::StringRef Version) {<br><br>  AddPath(Base + "/" + Arch + "/" + Version + "/include",<br>
          System, true, false, false);<br>  AddPath(Base + "/" + Arch + "/" + Version + "/include/c++",<br>          System, true, false, false);<br>  AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward",<br>
          System, true, false, false);<br>}<br><br>void InitHeaderSearch::AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) {<br>//...<br>  case llvm::Triple::MinGW64:<br>    // Try gcc 4.4.0<br>    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw64", "4.4.0");<br>
    // Try gcc 4.3.0<br>    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw64", "4.3.0");<br>    // Fall through.<br>  case llvm::Triple::MinGW32:<br>    // Try gcc 4.4.0<br>    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");<br>
    // Try gcc 4.3.0<br>    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.3.0");<br>    break;<br>//...<br>}<br><br>//----------------------------------------------------------------------------------------------------<br>
</div><br>For example, in this line ...<br><br>   <span style="font-family: courier new,monospace;"> AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.4.0");</span><br>        <br>
... "mingw32" corresponds to the parameter "Arch" of function "AddMinGWCPlusPlusIncludePaths". It is harcoded!<br><br><br>In GCC, if I want to know what is the Header Seach Path, I can run ...<br>
<br><span style="font-family: courier new,monospace;">    > g++ -v -c xxx.cpp</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        ...</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        #include "..." search starts here:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        #include <...> search starts here:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/mingw32</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include/c++/backward</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../include</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/include-fixed</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/mingw32/4.4.0/../../../../mingw32/include</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        End of search list.</span><br>        ...<br>        <br>        <br>I tried another implementation of MinGW (GCC 4.6) in which I got X.<br><br><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include/c++</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include/c++/i686-pc-mingw32</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include/c++/backward</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../include</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/include-fixed</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         c:\mingw\bin\../lib/gcc/i686-pc-mingw32/4.6.0/../../../../i686-pc-mingw32/include</span><br>
<br><br>The problem is in the "Arch" parameter, in one implementation I have "mingw32" and in the other "i686-pc-mingw32"<br><br><span style="font-family: arial,helvetica,sans-serif;">How I can know which parameter to use?</span><br>
    <br>The answer is...<br><br><span style="font-family: courier new,monospace;">    > g++ -dumpmachine</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    mingw32</span><br>
    <br>or in the second MinGW implementation...<br><br><span style="font-family: courier new,monospace;">    > g++ -dumpmachine</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    i686-pc-mingw32</span><br>
    <br>    <br>To fix this, I propose to add a new preprocessor #define on "config.h" and "llvm-config.h", like the following...<br><br><span style="font-family: courier new,monospace;">    #define LLVM_MINGW_DUMPMACHINE "mingw32"</span><br>
<br>LLVM_MINGW_DUMPMACHINE is fed in the CMake configuration phase, and can be used in the InitHeaderSearch class as follows...<br><br><span style="font-family: courier new,monospace;">    AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", llvm::StringRef(LLVM_MINGW_DUMPMACHINE), "4.4.0");</span><br>
<br><br>The files involved are:<br><br><div style="margin-left: 40px;">/cmake/config-ix.cmake<br>/cmake/modules/GetTargetTriple.cmake<br>/include/llvm/Config/config.h.cmake<br>/include/llvm/Config/llvm-config.h.cmake<br>/include/llvm/Config/<a href="http://config.h.in">config.h.in</a><br>
/include/llvm/Config/<a href="http://llvm-config.h.in">llvm-config.h.in</a><br></div><div style="margin-left: 40px;">/tools/clang/lib/Frontend/InitHeaderSearch.cpp<br></div>
<br><br><br>I want to know what do you think about this solution. If you approve, I will send the patches.<br><br>The next step is to avoid the hardcoding of "c:/MinGW/lib/gcc"...<br><br><br>Thanks and Regards.<br>
Fernando Pelliccioni.<br>