From: Daniel Dunbar Date: Tue, 15 Jan 2013 20:33:56 +0000 (+0000) Subject: [driver/Darwin] Adjust SDKROOT handling code to not generate "-isysroot /". X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=321425445f4ce31ccf477bea3240d05e0b1625b2;p=clang [driver/Darwin] Adjust SDKROOT handling code to not generate "-isysroot /". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172548 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 53a620a87e..b4a3980dcc 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -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)); } diff --git a/test/Driver/darwin-sdkroot.c b/test/Driver/darwin-sdkroot.c index 5abf081563..f463f4a279 100644 --- a/test/Driver/darwin-sdkroot.c +++ b/test/Driver/darwin-sdkroot.c @@ -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"