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

Tobias von Koch tobias.von.koch at gmail.com
Fri Aug 31 06:33:37 PDT 2012


New patch with test case attached, as well as a .tar.gz with the mock 
directory layouts for 32-/64-bit.

Thanks again,
Tobias

On 28/08/2012 19:52, Hal Finkel wrote:
> Tobias,
>
> Please add a test case to:
> test/Driver/linux-ld.c (which will require adding a corresponding mock
> directory layout to test/Driver/Inputs).
>
> Thanks again,
> Hal
>
> On Tue, 28 Aug 2012 18:54:10 +0200
> Tobias von Koch <tobias.von.koch at gmail.com> wrote:
>
>> 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);
+    }
   }
 }
 
--- a/test/Driver/linux-ld.c
+++ b/test/Driver/linux-ld.c
@@ -398,3 +398,24 @@
 // CHECK-ANDROID-STATIC: "-lgcc"
 // CHECK-ANDROID-STATIC-NOT: "gcc_s"
 // CHECK-ANDROID-STATIC: "{{.*}}/crtend_android.o"
+//
+// Test linker invocation for Freescale SDK (OpenEmbedded).
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target powerpc-fsl-linux \
+// RUN:     --sysroot=%S/Inputs/freescale_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-FSL-PPC %s
+// CHECK-FSL-PPC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-FSL-PPC: "-m" "elf32ppclinux"
+// CHECK-FSL-PPC: "{{.*}}/crt1.o"
+// CHECK-FSL-PPC: "{{.*}}/crtbegin.o"
+// CHECK-FSL-PPC: "-L[[SYSROOT]]/usr/lib"
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -target powerpc64-fsl-linux \
+// RUN:     --sysroot=%S/Inputs/freescale_ppc64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-FSL-PPC64 %s
+// CHECK-FSL-PPC64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-FSL-PPC64: "-m" "elf64ppc"
+// CHECK-FSL-PPC64: "{{.*}}/crt1.o"
+// CHECK-FSL-PPC64: "{{.*}}/crtbegin.o"
+// CHECK-FSL-PPC64: "-L[[SYSROOT]]/usr/lib64/powerpc64-fsl-linux/4.6.2/../.."
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freescale-sdk-trees.tar.gz
Type: application/x-gzip
Size: 581 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120831/a73f8b65/attachment.bin>


More information about the cfe-commits mailing list