[driver/Darwin] Adjust SDKROOT handling code to not generate "-isysroot /".
llvm-svn: 172548
This commit is contained in:
@@ -404,9 +404,10 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user