r329512 - [Driver] Update GCC libraries detection logic for Gentoo.

Manoj Gupta via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 7 12:59:58 PDT 2018


Author: manojgupta
Date: Sat Apr  7 12:59:58 2018
New Revision: 329512

URL: http://llvm.org/viewvc/llvm-project?rev=329512&view=rev
Log:
[Driver] Update GCC libraries detection logic for Gentoo.

Summary:
1. Find GCC's LDPATH from the actual GCC config file.
2. Avoid picking libraries from a similar named tuple if the exact
   tuple is installed.

Reviewers: mgorny, chandlerc, thakis, rnk

Reviewed By: mgorny, rnk

Subscribers: cfe-commits, mgorny

Differential Revision: https://reviews.llvm.org/D45233

Added:
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/.keep
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/crtbegin.o
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/.keep
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/crtbegin.o
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/
    cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/.keep
Modified:
    cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
    cfe/trunk/lib/Driver/ToolChains/Gnu.h
    cfe/trunk/test/Driver/linux-header-search.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=329512&r1=329511&r2=329512&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Sat Apr  7 12:59:58 2018
@@ -1676,18 +1676,21 @@ void Generic_GCC::GCCInstallationDetecto
   // in /usr. This avoids accidentally enforcing the system GCC version
   // when using a custom toolchain.
   if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
-    for (StringRef CandidateTriple : ExtraTripleAliases) {
-      if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
-        return;
-    }
-    for (StringRef CandidateTriple : CandidateTripleAliases) {
-      if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
-        return;
-    }
-    for (StringRef CandidateTriple : CandidateBiarchTripleAliases) {
-      if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple, true))
-        return;
-    }
+    SmallVector<StringRef, 16> GentooTestTriples;
+    // Try to match an exact triple as target triple first.
+    // e.g. crossdev -S x86_64-gentoo-linux-gnu will install gcc libs for
+    // x86_64-gentoo-linux-gnu. But "clang -target x86_64-gentoo-linux-gnu"
+    // may pick the libraries for x86_64-pc-linux-gnu even when exact matching
+    // triple x86_64-gentoo-linux-gnu is present.
+    GentooTestTriples.push_back(TargetTriple.str());
+    // Check rest of triples.
+    GentooTestTriples.append(ExtraTripleAliases.begin(),
+                             ExtraTripleAliases.end());
+    GentooTestTriples.append(CandidateTripleAliases.begin(),
+                             CandidateTripleAliases.end());
+    if (ScanGentooConfigs(TargetTriple, Args, GentooTestTriples,
+                          CandidateBiarchTripleAliases))
+      return;
   }
 
   // Loop over the various components which exist and select the best GCC
@@ -1700,6 +1703,9 @@ void Generic_GCC::GCCInstallationDetecto
       const std::string LibDir = Prefix + Suffix.str();
       if (!D.getVFS().exists(LibDir))
         continue;
+      // Try to match the exact target triple first.
+      ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str());
+      // Try rest of possible triples.
       for (StringRef Candidate : ExtraTripleAliases) // Try these first.
         ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);
       for (StringRef Candidate : CandidateTripleAliases)
@@ -2193,6 +2199,22 @@ void Generic_GCC::GCCInstallationDetecto
   }
 }
 
+bool Generic_GCC::GCCInstallationDetector::ScanGentooConfigs(
+    const llvm::Triple &TargetTriple, const ArgList &Args,
+    const SmallVectorImpl<StringRef> &CandidateTriples,
+    const SmallVectorImpl<StringRef> &CandidateBiarchTriples) {
+  for (StringRef CandidateTriple : CandidateTriples) {
+    if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple))
+      return true;
+  }
+
+  for (StringRef CandidateTriple : CandidateBiarchTriples) {
+    if (ScanGentooGccConfig(TargetTriple, Args, CandidateTriple, true))
+      return true;
+  }
+  return false;
+}
+
 bool Generic_GCC::GCCInstallationDetector::ScanGentooGccConfig(
     const llvm::Triple &TargetTriple, const ArgList &Args,
     StringRef CandidateTriple, bool NeedsBiarchSuffix) {
@@ -2205,23 +2227,53 @@ bool Generic_GCC::GCCInstallationDetecto
     for (StringRef Line : Lines) {
       Line = Line.trim();
       // CURRENT=triple-version
-      if (Line.consume_front("CURRENT=")) {
-        const std::pair<StringRef, StringRef> ActiveVersion =
-          Line.rsplit('-');
-        // Note: Strictly speaking, we should be reading
-        // /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
-        // contain anything new or especially useful to us.
-        const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
-                                       ActiveVersion.first.str() + "/" +
-                                       ActiveVersion.second.str();
+      if (!Line.consume_front("CURRENT="))
+        continue;
+      // Process the config file pointed to by CURRENT.
+      llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ConfigFile =
+          D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/" +
+                                      Line.str());
+      std::pair<StringRef, StringRef> ActiveVersion = Line.rsplit('-');
+      // List of paths to scan for libraries.
+      SmallVector<StringRef, 4> GentooScanPaths;
+      // Scan the Config file to find installed GCC libraries path.
+      // Typical content of the GCC config file:
+      // LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x:/usr/lib/gcc/
+      // (continued from previous line) x86_64-pc-linux-gnu/4.9.x/32"
+      // MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.x/man"
+      // INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.x/info"
+      // STDCXX_INCDIR="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4"
+      // We are looking for the paths listed in LDPATH=... .
+      if (ConfigFile) {
+        SmallVector<StringRef, 2> ConfigLines;
+        ConfigFile.get()->getBuffer().split(ConfigLines, "\n");
+        for (StringRef ConfLine : ConfigLines) {
+          ConfLine = ConfLine.trim();
+          if (ConfLine.consume_front("LDPATH=")) {
+            // Drop '"' from front and back if present.
+            ConfLine.consume_back("\"");
+            ConfLine.consume_front("\"");
+            // Get all paths sperated by ':'
+            ConfLine.split(GentooScanPaths, ':', -1, /*AllowEmpty*/ false);
+          }
+        }
+      }
+      // Test the path based on the version in /etc/env.d/gcc/config-{tuple}.
+      std::string basePath = "/usr/lib/gcc/" + ActiveVersion.first.str() + "/"
+          + ActiveVersion.second.str();
+      GentooScanPaths.push_back(StringRef(basePath));
+
+      // Scan all paths for GCC libraries.
+      for (const auto &GentooScanPath : GentooScanPaths) {
+        std::string GentooPath = D.SysRoot + std::string(GentooScanPath);
         if (D.getVFS().exists(GentooPath + "/crtbegin.o")) {
           if (!ScanGCCForMultilibs(TargetTriple, Args, GentooPath,
                                    NeedsBiarchSuffix))
-            return false;
+            continue;
 
           Version = GCCVersion::Parse(ActiveVersion.second);
           GCCInstallPath = GentooPath;
-          GCCParentLibPath = GentooPath + "/../../..";
+          GCCParentLibPath = GentooPath + std::string("/../../..");
           GCCTriple.setTriple(ActiveVersion.first);
           IsValid = true;
           return true;

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.h?rev=329512&r1=329511&r2=329512&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.h Sat Apr  7 12:59:58 2018
@@ -265,6 +265,11 @@ public:
                                 StringRef CandidateTriple,
                                 bool NeedsBiarchSuffix = false);
 
+    bool ScanGentooConfigs(const llvm::Triple &TargetTriple,
+                           const llvm::opt::ArgList &Args,
+                           const SmallVectorImpl<StringRef> &CandidateTriples,
+                           const SmallVectorImpl<StringRef> &BiarchTriples);
+
     bool ScanGentooGccConfig(const llvm::Triple &TargetTriple,
                              const llvm::opt::ArgList &Args,
                              StringRef CandidateTriple,

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu?rev=329512&view=auto
==============================================================================
--- cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu (added)
+++ cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu Sat Apr  7 12:59:58 2018
@@ -0,0 +1 @@
+CURRENT=x86_64-pc-linux-gnu-4.9.3

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3?rev=329512&view=auto
==============================================================================
--- cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3 (added)
+++ cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3 Sat Apr  7 12:59:58 2018
@@ -0,0 +1,10 @@
+PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.x"
+ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.x"
+GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.x"
+LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32"
+MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.x/man"
+INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.x/info"
+STDCXX_INCDIR="g++-v4"
+CTARGET="x86_64-pc-linux-gnu"
+GCC_SPECS=""
+MULTIOSDIRS="../lib64:../lib32"

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release?rev=329512&view=auto
==============================================================================
--- cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release (added)
+++ cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/etc/gentoo-release Sat Apr  7 12:59:58 2018
@@ -0,0 +1 @@
+Gentoo Base System release 2.3

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/include/.keep?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/32/crtbegin.o?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/crtbegin.o?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g%2B%2B-v4.9.3/.keep?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/x32/crtbegin.o?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/32/crtbegin.o?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g%2B%2B-v5.4.0/.keep?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/x32/crtbegin.o?rev=329512&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_4.9.x_tree/usr/x86_64-pc-linux-gnu/lib/.keep?rev=329512&view=auto
==============================================================================
    (empty)

Modified: cfe/trunk/test/Driver/linux-header-search.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-header-search.cpp?rev=329512&r1=329511&r2=329512&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-header-search.cpp (original)
+++ cfe/trunk/test/Driver/linux-header-search.cpp Sat Apr  7 12:59:58 2018
@@ -343,6 +343,59 @@
 // CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3-32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for parsing Gentoo's gcc-config -- clang should parse the
+// /etc/env.d/gcc/config-x86_64-pc-linux-gnu file to find CURRENT gcc used.
+// Then should pick the multilibs from version 4.9.x specified in
+// /etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN:     --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN:     --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X %s
+//
+// CHECK-GENTOO-4-9-X: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+// CHECK-GENTOO-4-9-X: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target x86_64-unknown-linux-gnux32 -stdlib=libstdc++ \
+// RUN:     --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN:     --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X-X32 %s
+// CHECK-GENTOO-4-9-X-X32: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X-X32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X-X32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu/x32"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X-X32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN:     -target i386-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN:     --sysroot=%S/Inputs/gentoo_linux_gcc_4.9.x_tree \
+// RUN:     --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-X-32 %s
+// CHECK-GENTOO-4-9-X-32: "{{.*}}clang{{.*}}" "-cc1"
+// CHECK-GENTOO-4-9-X-32: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-GENTOO-4-9-X-32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-GENTOO-4-9-X-32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3"
+// CHECK-GENTOO-4-9-X-32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/x86_64-pc-linux-gnu/32"
+// CHECK-GENTOO-4-9-X-32: "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.x/include/g++-v4.9.3/backward"
+// CHECK-GENTOO-4-9-X-32: "-internal-isystem" "[[SYSROOT]]/usr/local/include"
+// CHECK-GENTOO-4-9-X-32: "-internal-isystem" "[[RESOURCE_DIR]]{{/|\\\\}}include"
+// CHECK-GENTOO-4-9-X-32: "-internal-externc-isystem" "[[SYSROOT]]/include"
+// CHECK-GENTOO-4-9-X-32: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
+//
 // Check header search on Debian 6 / MIPS64
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN:     -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \




More information about the cfe-commits mailing list