r331390 - [Driver] Infer Android sysroot location.

Dan Albert via cfe-commits cfe-commits at lists.llvm.org
Wed May 2 12:38:37 PDT 2018


Author: danalbert
Date: Wed May  2 12:38:37 2018
New Revision: 331390

URL: http://llvm.org/viewvc/llvm-project?rev=331390&view=rev
Log:
[Driver] Infer Android sysroot location.

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

Reviewers: srhines

Reviewed By: srhines

Subscribers: cfe-commits

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

Modified:
    cfe/trunk/lib/Driver/ToolChains/Linux.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=331390&r1=331389&r2=331390&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Wed May  2 12:38:37 2018
@@ -429,6 +429,15 @@ std::string Linux::computeSysRoot() cons
   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();
 




More information about the cfe-commits mailing list