[cfe-commits] r172548 - in /cfe/trunk: lib/Driver/ToolChains.cpp test/Driver/darwin-sdkroot.c

Daniel Dunbar daniel at zuster.org
Tue Jan 15 12:33:56 PST 2013


Author: ddunbar
Date: Tue Jan 15 14:33:56 2013
New Revision: 172548

URL: http://llvm.org/viewvc/llvm-project?rev=172548&view=rev
Log:
[driver/Darwin] Adjust SDKROOT handling code to not generate "-isysroot /".

Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/test/Driver/darwin-sdkroot.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=172548&r1=172547&r2=172548&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jan 15 14:33:56 2013
@@ -404,9 +404,10 @@
       getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
   } else {
     if (char *env = ::getenv("SDKROOT")) {
-      // We only use this value as the default if it is an absolute path and
-      // exists.
-      if (llvm::sys::path::is_absolute(env) && llvm::sys::fs::exists(env)) {
+      // We only use this value as the default if it is an absolute path,
+      // exists, and it is not the root path.
+      if (llvm::sys::path::is_absolute(env) && llvm::sys::fs::exists(env) &&
+          StringRef(env) != "/") {
         Args.append(Args.MakeSeparateArg(
                       0, Opts.getOption(options::OPT_isysroot), env));
       }

Modified: cfe/trunk/test/Driver/darwin-sdkroot.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdkroot.c?rev=172548&r1=172547&r2=172548&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-sdkroot.c Tue Jan 15 14:33:56 2013
@@ -11,7 +11,7 @@
 // CHECK-BASIC: "-isysroot" "{{.*tmpdir}}"
 
 // Check that we don't use SDKROOT as the default if it is not a valid path.
-
+//
 // RUN: rm -rf %t.nonpath
 // RUN: env SDKROOT=%t.nonpath %clang -target x86_64-apple-darwin10 \
 // RUN:   -c %s -### 2> %t.log
@@ -20,3 +20,13 @@
 // CHECK-NONPATH: clang
 // CHECK-NONPATH: "-cc1"
 // CHECK-NONPATH-NOT: "-isysroot"
+
+// Check that we don't use SDKROOT as the default if it is just "/"
+//
+// RUN: env SDKROOT=/ %clang -target x86_64-apple-darwin10 \
+// RUN:   -c %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-NONROOT < %t.log %s
+//
+// CHECK-NONROOT: clang
+// CHECK-NONROOT: "-cc1"
+// CHECK-NONROOT-NOT: "-isysroot"





More information about the cfe-commits mailing list