]> granicus.if.org Git - clang/commitdiff
[VFS] Wire up multilib toolchain code to the VFS.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 9 Oct 2015 13:03:18 +0000 (13:03 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 9 Oct 2015 13:03:18 +0000 (13:03 +0000)
This lets a VFSified driver actually validate the GCC paths.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249829 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
unittests/Driver/ToolChainTest.cpp

index 2f7436f1f04a6cceaa8b0dbf84e83482dad1e4c5..24ea030b9c6d54257427c0d1f5d28271c2a51696 100644 (file)
@@ -1522,11 +1522,13 @@ namespace {
 // Filter to remove Multilibs that don't exist as a suffix to Path
 class FilterNonExistent {
   StringRef Base;
+  vfs::FileSystem &VFS;
 
 public:
-  FilterNonExistent(StringRef Base) : Base(Base) {}
+  FilterNonExistent(StringRef Base, vfs::FileSystem &VFS)
+      : Base(Base), VFS(VFS) {}
   bool operator()(const Multilib &M) {
-    return !llvm::sys::fs::exists(Base + M.gccSuffix() + "/crtbegin.o");
+    return !VFS.exists(Base + M.gccSuffix() + "/crtbegin.o");
   }
 };
 } // end anonymous namespace
@@ -1582,8 +1584,9 @@ static Multilib makeMultilib(StringRef commonSuffix) {
   return Multilib(commonSuffix, commonSuffix, commonSuffix);
 }
 
-static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
-                              const ArgList &Args, DetectedMultilibs &Result) {
+static bool findMIPSMultilibs(const Driver &D, const llvm::Triple &TargetTriple,
+                              StringRef Path, const ArgList &Args,
+                              DetectedMultilibs &Result) {
   // Some MIPS toolchains put libraries and object files compiled
   // using different options in to the sub-directoris which names
   // reflects the flags used for compilation. For example sysroot
@@ -1609,7 +1612,7 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
   //     /usr
   //       /lib  <= crt*.o files compiled with '-mips32'
 
-  FilterNonExistent NonExistent(Path);
+  FilterNonExistent NonExistent(Path, D.getVFS());
 
   // Check for FSF toolchain multilibs
   MultilibSet FSFMipsMultilibs;
@@ -1874,11 +1877,11 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
   return false;
 }
 
-static bool findBiarchMultilibs(const llvm::Triple &TargetTriple,
+static bool findBiarchMultilibs(const Driver &D,
+                                const llvm::Triple &TargetTriple,
                                 StringRef Path, const ArgList &Args,
                                 bool NeedsBiarchSuffix,
                                 DetectedMultilibs &Result) {
-
   // Some versions of SUSE and Fedora on ppc64 put 32-bit libs
   // in what would normally be GCCInstallPath and put the 64-bit
   // libs in a subdirectory named 64. The simple logic we follow is that
@@ -1906,7 +1909,7 @@ static bool findBiarchMultilibs(const llvm::Triple &TargetTriple,
                         .flag("-m64")
                         .flag("+mx32");
 
-  FilterNonExistent NonExistent(Path);
+  FilterNonExistent NonExistent(Path, D.getVFS());
 
   // Determine default multilib from: 32, 64, x32
   // Also handle cases such as 64 on 32, 32 on 64, etc.
@@ -2068,9 +2071,9 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
       // Debian mips multilibs behave more like the rest of the biarch ones,
       // so handle them there
       if (isMipsArch(TargetArch)) {
-        if (!findMIPSMultilibs(TargetTriple, LI->getName(), Args, Detected))
+        if (!findMIPSMultilibs(D, TargetTriple, LI->getName(), Args, Detected))
           continue;
-      } else if (!findBiarchMultilibs(TargetTriple, LI->getName(), Args,
+      } else if (!findBiarchMultilibs(D, TargetTriple, LI->getName(), Args,
                                       NeedsBiarchSuffix, Detected)) {
         continue;
       }
index 8fddc9b6a031f30ce27b5f746d581576de65e629..18a7bbe0f81db83f47f57d99a12b831d04ec77a8 100644 (file)
@@ -66,9 +66,13 @@ TEST(ToolChainTest, VFSGCCInstallation) {
     llvm::raw_string_ostream OS(S);
     C->getDefaultToolChain().printVerboseInfo(OS);
   }
-  EXPECT_EQ("Found candidate GCC installation: "
-            "/usr/lib/gcc/arm-linux-gnueabihf/4.6.3\n",
-            S);
+  EXPECT_EQ(
+      "Found candidate GCC installation: "
+      "/usr/lib/gcc/arm-linux-gnueabihf/4.6.3\n"
+      "Selected GCC installation: /usr/lib/gcc/arm-linux-gnueabihf/4.6.3\n"
+      "Candidate multilib: .;@m32\n"
+      "Selected multilib: .;@m32\n",
+      S);
 }
 
 } // end anonymous namespace