]> granicus.if.org Git - clang/commitdiff
use DEFAULT_SYSROOT
authorSebastian Pop <spop@codeaurora.org>
Mon, 16 Apr 2012 04:16:43 +0000 (04:16 +0000)
committerSebastian Pop <spop@codeaurora.org>
Mon, 16 Apr 2012 04:16:43 +0000 (04:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154792 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
include/clang/Config/config.h.cmake
include/clang/Config/config.h.in
include/clang/Driver/Compilation.h
lib/Driver/Compilation.cpp
lib/Driver/Driver.cpp
lib/Driver/Tools.cpp

index 1197610f7b1fa5fd946a60b91b135013fc7e5cf3..c828482ac70298f5edecf7142d0d92774dd9682b 100644 (file)
@@ -66,6 +66,10 @@ set(CLANG_RESOURCE_DIR "" CACHE STRING
 set(C_INCLUDE_DIRS "" CACHE STRING
   "Colon separated list of directories clang will search for headers.")
 
+set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
+set(DEFAULT_SYSROOT "" CACHE PATH
+  "Default <path> to all compiler invocations for --sysroot=<path>." )
+
 set(CLANG_VENDOR "" CACHE STRING
   "Vendor-specific text for showing with version information.")
 
index bd5dc31f32320eee1c12818931b8fdf3559c95a9..c18c4cc86f765b75800c7a621d145309cee70306 100644 (file)
@@ -4,8 +4,11 @@
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}"
 
-/* Directory where gcc is installed. */
-#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}"
-
 /* Directories clang will search for headers */
 #define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}"
+
+/* Default <path> to all compiler invocations for --sysroot=<path>. */
+#define DEFAULT_SYSROOT "${DEFAULT_SYSROOT}"
+
+/* Directory where gcc is installed. */
+#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}"
index 86d5b0959b6ed6bf1f605c21c52f545136f2c075..8ff94178e27e53a27e3ef3a510bfcd430bf27ce3 100644 (file)
@@ -9,13 +9,16 @@
 /* Relative directory for resource files */
 #undef CLANG_RESOURCE_DIR
 
-/* Directory where gcc is installed. */
-#undef GCC_INSTALL_PREFIX
-
 /* Directories clang will search for headers */
 #undef C_INCLUDE_DIRS
 
 /* Linker version detected at compile time. */
 #undef HOST_LINK_VERSION
 
+/* Default <path> to all compiler invocations for --sysroot=<path>. */
+#undef DEFAULT_SYSROOT
+
+/* Directory where gcc is installed. */
+#undef GCC_INSTALL_PREFIX
+
 #endif
index fd88c3a63636cf1631e9a7c63b64cf8d3e8233a9..6f1a2217cd1ca563773d30e4a6aeb6327a8cf4dd 100644 (file)
@@ -92,6 +92,9 @@ public:
     return FailureResultFiles;
   }
 
+  /// Returns the sysroot path.
+  StringRef getSysRoot() const;
+
   /// getArgsForToolChain - Return the derived argument list for the
   /// tool chain \arg TC (or the default tool chain, if TC is not
   /// specified).
index 42c84493fa6aca48d3d2b601c694560c35621d8b..5553fc937e015547ddaa59e1692aa776eea08e72 100644 (file)
@@ -230,3 +230,7 @@ void Compilation::initCompilationForDiagnostics(void) {
   Redirects[1] = new const llvm::sys::Path();
   Redirects[2] = new const llvm::sys::Path();
 }
+
+StringRef Compilation::getSysRoot(void) const {
+  return getDriver().SysRoot;
+}
index 424936b242361af2c5758b04b90cf99a1aa80219..3ddac69e98cbee1e0283c0106ede4ae42d50161b 100644 (file)
@@ -49,8 +49,8 @@ Driver::Driver(StringRef ClangExecutable,
                bool IsProduction,
                DiagnosticsEngine &Diags)
   : Opts(createDriverOptTable()), Diags(Diags),
-    ClangExecutable(ClangExecutable), UseStdLib(true),
-    DefaultTargetTriple(DefaultTargetTriple), 
+    ClangExecutable(ClangExecutable), SysRoot(DEFAULT_SYSROOT),
+    UseStdLib(true), DefaultTargetTriple(DefaultTargetTriple),
     DefaultImageName(DefaultImageName),
     DriverTitle("clang \"gcc-compatible\" driver"),
     CCPrintOptionsFilename(0), CCPrintHeadersFilename(0),
@@ -660,9 +660,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
     llvm::outs() << "\n";
     llvm::outs() << "libraries: =" << ResourceDir;
 
-    std::string sysroot;
-    if (Arg *A = C.getArgs().getLastArg(options::OPT__sysroot_EQ))
-      sysroot = A->getValue(C.getArgs());
+    StringRef sysroot = C.getSysRoot();
 
     for (ToolChain::path_list::const_iterator it = TC.getFilePaths().begin(),
            ie = TC.getFilePaths().end(); it != ie; ++it) {
index fbf4f08d4c346d44089d4e7eb58cec162e6d8117..47b52949546df3ee2a9d9dc471ec5fafb15d2c84 100644 (file)
@@ -377,10 +377,11 @@ void Clang::AddPreprocessingOptions(Compilation &C,
 
   // If we have a --sysroot, and don't have an explicit -isysroot flag, add an
   // -isysroot to the CC1 invocation.
-  if (Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) {
+  StringRef sysroot = C.getSysRoot();
+  if (sysroot != "") {
     if (!Args.hasArg(options::OPT_isysroot)) {
       CmdArgs.push_back("-isysroot");
-      CmdArgs.push_back(A->getValue(Args));
+      CmdArgs.push_back(C.getArgs().MakeArgString(sysroot));
     }
   }
   
@@ -4016,9 +4017,10 @@ void darwin::Link::AddLinkArgs(Compilation &C,
 
   // Give --sysroot= preference, over the Apple specific behavior to also use
   // --isysroot as the syslibroot.
-  if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ)) {
+  StringRef sysroot = C.getSysRoot();
+  if (sysroot != "") {
     CmdArgs.push_back("-syslibroot");
-    CmdArgs.push_back(A->getValue(Args));
+    CmdArgs.push_back(C.getArgs().MakeArgString(sysroot));
   } else if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
     CmdArgs.push_back("-syslibroot");
     CmdArgs.push_back(A->getValue(Args));