[cfe-commits] [PATCH 2/3] Add C/C++ header locations for Freescale SDK

Tobias von Koch tobias.von.koch at gmail.com
Tue Aug 28 09:54:10 PDT 2012


Dear all,

This is part of a sequence of three (trivial) patches to allow Clang to 
be used as a drop-in replacement for GCC with the Freescale SDK.
Support for Freescale processors has just been added to the PowerPC backend.

Please review and commit if this is OK - I don't have commit access.

Thanks!
Tobias

Description of patch:

Add C/C++ header locations for Freescale SDK. The SDK is based on 
OpenEmbedded so this may be useful for any SDK built on that framework.

-------------- next part --------------
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1274,6 +1274,11 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
     "/gcc/" + CandidateTriple.str(),
     "/" + CandidateTriple.str() + "/gcc/" + CandidateTriple.str(),
 
+    // The Freescale PPC SDK has the gcc libraries in
+    // <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well.
+    // FIXME: Ideally, this should be specific to vendor==Freescale.
+    "/" + CandidateTriple.str(),
+
     // Ubuntu has a strange mis-matched pair of triples that this happens to
     // match.
     // FIXME: It may be worthwhile to generalize this and look for a second
@@ -1283,6 +1288,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
   const std::string InstallSuffixes[] = {
     "/../../..",
     "/../../../..",
+    "/../..",
     "/../../../.."
   };
   // Only look at the final, weird Ubuntu suffix for i386-linux-gnu.
@@ -2332,10 +2338,18 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
                                 DriverArgs, CC1Args)) {
     // Gentoo is weird and places its headers inside the GCC install, so if the
     // first attempt to find the headers fails, try this pattern.
-    addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
-                             (GCCInstallation.getTriple().str() +
-                              GCCInstallation.getMultiarchSuffix()),
-                             DriverArgs, CC1Args);
+    if (!addLibStdCXXIncludePaths(InstallDir + "/include/g++-v4",
+    		                      (GCCInstallation.getTriple().str() +
+                                  GCCInstallation.getMultiarchSuffix()),
+                                  DriverArgs, CC1Args)) {
+    	// Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
+    	// without a subdirectory corresponding to the gcc version, so try this
+    	// as a last resort.
+    	addLibStdCXXIncludePaths(LibDir + "/../include/c++",
+    	    		             (GCCInstallation.getTriple().str() +
+    	                         GCCInstallation.getMultiarchSuffix()),
+    	                         DriverArgs, CC1Args);
+    }
   }
 }
 



More information about the cfe-commits mailing list