This patch fixes the problem reported in <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-October/018029.html>, which I ran into today.

My system requires _both_ the "include/g++-v4" and the "include" candidates, so I removed the "break" after the first one is found. Since the second one always exists if the first one does, I added a check for at least one libstdc++ header in the target path before actually adding it, using one header from each of the two paths listed above on my system. These were the first headers building clang with itself failed on if the corresponding path was not added.
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp	(revision 169064)
+++ lib/Driver/ToolChains.cpp	(working copy)
@@ -2358,6 +2358,9 @@
                                                 ArgStringList &CC1Args) {
   if (!llvm::sys::fs::exists(Base))
     return false;
+  if (!llvm::sys::fs::exists(Base + "/cxxabi.h") &&
+      !llvm::sys::fs::exists(Base + "/cstddef"))
+    return false;
   addSystemInclude(DriverArgs, CC1Args, Base);
   addSystemInclude(DriverArgs, CC1Args, Base + "/" + TargetArchDir);
   addSystemInclude(DriverArgs, CC1Args, Base + "/backward");
@@ -2394,8 +2397,9 @@
   const std::string IncludePathCandidates[] = {
     LibDir.str() + "/../include/c++/" + Version.str(),
     // Gentoo is weird and places its headers inside the GCC install, so if the
-    // first attempt to find the headers fails, try this pattern.
+    // first attempt to find the headers fails, try these patterns.
     InstallDir.str() + "/include/g++-v4",
+    InstallDir.str() + "/include",
     // Android standalone toolchain has C++ headers in yet another place.
     LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.str(),
     // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
@@ -2404,10 +2408,9 @@
   };
 
   for (unsigned i = 0; i < llvm::array_lengthof(IncludePathCandidates); ++i) {
-    if (addLibStdCXXIncludePaths(IncludePathCandidates[i], (TripleStr +
+    addLibStdCXXIncludePaths(IncludePathCandidates[i], (TripleStr +
                 GCCInstallation.getMultiarchSuffix()),
-            DriverArgs, CC1Args))
-      break;
+            DriverArgs, CC1Args);
   }
 }
 
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to