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));
}
// 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
// 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"