[cfe-commits] r144165 - in /cfe/trunk: lib/Driver/ test/Driver/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/ test/Driver/Inputs/ubuntu_11.04_multiarch_tree/u...

Chandler Carruth chandlerc at gmail.com
Tue Nov 8 19:46:20 PST 2011


Author: chandlerc
Date: Tue Nov  8 21:46:20 2011
New Revision: 144165

URL: http://llvm.org/viewvc/llvm-project?rev=144165&view=rev
Log:
Fix an issue that Duncan discovered on a specific (no longer current)
version of Ubuntu. It has a very broken multiarch configuration, and so
we need special logic to handle it correctly. Fixing and testing this
uncovered a few other trivial issues with the logic that are fixed as
well.

I added tests to cover this as it is hard to notice if you install
recent versions of the OS.

Added:
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/
    cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o
    cfe/trunk/test/Driver/linux-header-search.cpp
Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/ToolChains.h
    cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=144165&r1=144164&r2=144165&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Nov  8 21:46:20 2011
@@ -1146,7 +1146,7 @@
       if (!llvm::sys::fs::exists(LibDir))
         continue;
       for (unsigned k = 0, ke = CandidateTriples.size(); k < ke; ++k)
-        ScanLibDirForGCCTriple(LibDir, CandidateTriples[k]);
+        ScanLibDirForGCCTriple(HostArch, LibDir, CandidateTriples[k]);
     }
   }
 }
@@ -1226,7 +1226,8 @@
 }
 
 void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
-    const std::string &LibDir, StringRef CandidateTriple) {
+    llvm::Triple::ArchType HostArch, const std::string &LibDir,
+    StringRef CandidateTriple) {
   // There are various different suffixes involving the triple we
   // check for. We also record what is necessary to walk from each back
   // up to the lib directory.
@@ -1238,7 +1239,7 @@
     // match.
     // FIXME: It may be worthwhile to generalize this and look for a second
     // triple.
-    "/" + CandidateTriple.str() + "/gcc/i686-linux-gnu"
+    "/i386-linux-gnu/gcc/" + CandidateTriple.str()
   };
   const std::string InstallSuffixes[] = {
     "/../../..",
@@ -1247,7 +1248,7 @@
   };
   // Only look at the final, weird Ubuntu suffix for i386-linux-gnu.
   const unsigned NumSuffixes = (llvm::array_lengthof(Suffixes) -
-                                (CandidateTriple != "i386-linux-gnu"));
+                                (HostArch != llvm::Triple::x86));
   for (unsigned i = 0; i < NumSuffixes; ++i) {
     StringRef Suffix = Suffixes[i];
     llvm::error_code EC;
@@ -1889,12 +1890,9 @@
     if (!Suffix.empty())
       addPathIfExists(GCCInstallation.getInstallPath(), Paths);
     addPathIfExists(LibPath + "/../" + GccTriple + "/lib", Paths);
-    addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
     addPathIfExists(LibPath, Paths);
   }
-  addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
   addPathIfExists(SysRoot + "/lib", Paths);
-  addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
   addPathIfExists(SysRoot + "/usr/lib", Paths);
 }
 
@@ -2002,7 +2000,7 @@
   for (ArrayRef<StringRef>::iterator I = MultiarchIncludeDirs.begin(),
                                      E = MultiarchIncludeDirs.end();
        I != E; ++I) {
-    if (llvm::sys::fs::exists(*I)) {
+    if (llvm::sys::fs::exists(D.SysRoot + *I)) {
       addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + *I);
       break;
     }

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=144165&r1=144164&r2=144165&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Tue Nov  8 21:46:20 2011
@@ -100,7 +100,8 @@
                                          SmallVectorImpl<StringRef> &LibDirs,
                                          SmallVectorImpl<StringRef> &Triples);
 
-    void ScanLibDirForGCCTriple(const std::string &LibDir,
+    void ScanLibDirForGCCTriple(llvm::Triple::ArchType HostArch,
+                                const std::string &LibDir,
                                 StringRef CandidateTriple);
   };
 

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/lib/i386-linux-gnu/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c%2B%2B/4.5/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/backward/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c%2B%2B/4.5/backward/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c++/4.5/i686-linux-gnu/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/c%2B%2B/4.5/i686-linux-gnu/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/include/i386-linux-gnu/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/.keep?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/ubuntu_11.04_multiarch_tree/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o?rev=144165&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/linux-header-search.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=144165&view=auto
==============================================================================
--- cfe/trunk/test/Driver/linux-header-search.cpp (added)
+++ cfe/trunk/test/Driver/linux-header-search.cpp Tue Nov  8 21:46:20 2011
@@ -0,0 +1,17 @@
+// General tests that the header search paths detected by the driver and passed
+// to CC1 are sane.
+//
+// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -ccc-host-triple i386-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
+// CHECK-UBUNTU-11-04: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-UBUNTU-11-04: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/i686-linux-gnu"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../../include/c++/4.5/backward"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-UBUNTU-11-04: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9]\.[0-9]}}/include"
+// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-UBUNTU-11-04: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=144165&r1=144164&r2=144165&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Tue Nov  8 21:46:20 2011
@@ -145,3 +145,17 @@
 // CHECK-GCC-VERSION4: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-GCC-VERSION4: "{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99/crtbegin.o"
 // CHECK-GCC-VERSION4: "-L{{.*}}/Inputs/gcc_version_parsing4/bin/../lib/gcc/i386-unknown-linux/4.7.99"
+//
+// Test a very broken version of multiarch that shipped in Ubuntu 11.04.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:     -ccc-host-triple i386-unknown-linux \
+// RUN:     --sysroot=%S/Inputs/ubuntu_11.04_multiarch_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-UBUNTU-11-04 %s
+// CHECK-UBUNTU-11-04: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-11-04: "{{.*}}/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/crtbegin.o"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../../i386-linux-gnu"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5/../../../.."
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib"
+// CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib"





More information about the cfe-commits mailing list