Home | History | Annotate | Download | only in llvm
      1 From a3e95da137134a4820937a481fb065c1d1104ac8 Mon Sep 17 00:00:00 2001
      2 From: Logan Chien <loganchien (a] google.com>
      3 Date: Wed, 12 Sep 2012 18:32:47 +0800
      4 Subject: [PATCH] Detect sysroot automatically.
      5 
      6 If --sysroot is not specified, try to look for
      7 sysroot at <clang-executable-dir>/../sysroot.
      8 ---
      9  llvm-3.1/tools/clang/lib/Driver/Driver.cpp |   10 +++++++++-
     10  1 files changed, 9 insertions(+), 1 deletions(-)
     11 
     12 diff --git a/llvm-3.1/tools/clang/lib/Driver/Driver.cpp b/llvm-3.1/tools/clang/lib/Driver/Driver.cpp
     13 index 3ddac69..6c65b2d 100644
     14 --- a/llvm-3.1/tools/clang/lib/Driver/Driver.cpp
     15 +++ b/llvm-3.1/tools/clang/lib/Driver/Driver.cpp
     16 @@ -324,8 +324,16 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
     17      A->claim();
     18      PrefixDirs.push_back(A->getValue(*Args, 0));
     19    }
     20 -  if (const Arg *A = Args->getLastArg(options::OPT__sysroot_EQ))
     21 +  if (const Arg *A = Args->getLastArg(options::OPT__sysroot_EQ)) {
     22      SysRoot = A->getValue(*Args);
     23 +  } else {
     24 +    llvm::sys::Path SysRootCandidate(Dir);
     25 +    SysRootCandidate.appendComponent("..");
     26 +    SysRootCandidate.appendComponent("sysroot");
     27 +    bool Exists = false;
     28 +    if (!llvm::sys::fs::exists(SysRootCandidate.c_str(), Exists) && Exists)
     29 +      SysRoot = SysRootCandidate.str();
     30 +  }
     31    if (Args->hasArg(options::OPT_nostdlib))
     32      UseStdLib = false;
     33  
     34 -- 
     35 1.7.7.3
     36 
     37