[PATCH] D45291: [Driver] Infer Android sysroot location.

Dan Albert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 4 14:50:51 PDT 2018


danalbert created this revision.
danalbert added a reviewer: srhines.

Android toolchains include their headers and libraries in a
self-contained directory within the toolchain.


Repository:
  rC Clang

https://reviews.llvm.org/D45291

Files:
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===================================================================
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -413,6 +413,15 @@
   if (!getDriver().SysRoot.empty())
     return getDriver().SysRoot;
 
+  if (getTriple().isAndroid()) {
+    // Android toolchains typically include a sysroot at ../sysroot relative to
+    // the clang binary.
+    const StringRef ClangDir = getDriver().getInstalledDir();
+    std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str();
+    if (getVFS().exists(AndroidSysRootPath))
+      return AndroidSysRootPath;
+  }
+
   if (!GCCInstallation.isValid() || !tools::isMipsArch(getTriple().getArch()))
     return std::string();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45291.141067.patch
Type: text/x-patch
Size: 744 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180404/e5986eb0/attachment.bin>


More information about the cfe-commits mailing list