[cfe-commits] r162116 - in /cfe/trunk: lib/Driver/ToolChains.cpp test/Driver/darwin-sdkroot.c
Daniel Dunbar
daniel at zuster.org
Fri Aug 17 11:43:51 PDT 2012
Author: ddunbar
Date: Fri Aug 17 13:43:50 2012
New Revision: 162116
URL: http://llvm.org/viewvc/llvm-project?rev=162116&view=rev
Log:
darwin/driver: Support using SDKROOT to define the default for -isysroot.
- The SDKROOT environment variable is the de facto way to set the default SDK
for a number of tools, join forces with them.
Added:
cfe/trunk/test/Driver/darwin-sdkroot.c
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=162116&r1=162115&r2=162116&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Aug 17 13:43:50 2012
@@ -442,6 +442,20 @@
void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
const OptTable &Opts = getDriver().getOpts();
+ // Support allowing the SDKROOT environment variable used by xcrun and other
+ // Xcode tools to define the default sysroot, by making it the default for
+ // isysroot.
+ if (!Args.hasArg(options::OPT_isysroot)) {
+ 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)) {
+ Args.append(Args.MakeSeparateArg(
+ 0, Opts.getOption(options::OPT_isysroot), env));
+ }
+ }
+ }
+
Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ);
Arg *iOSVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ);
Arg *iOSSimVersion = Args.getLastArg(
Added: cfe/trunk/test/Driver/darwin-sdkroot.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdkroot.c?rev=162116&view=auto
==============================================================================
--- cfe/trunk/test/Driver/darwin-sdkroot.c (added)
+++ cfe/trunk/test/Driver/darwin-sdkroot.c Fri Aug 17 13:43:50 2012
@@ -0,0 +1,22 @@
+// Check that SDKROOT is used to define the default for -isysroot on Darwin.
+//
+// RUN: rm -rf %t.tmpdir
+// RUN: mkdir -p %t.tmpdir
+// RUN: env SDKROOT=%t.tmpdir %clang -target x86_64-apple-darwin10 \
+// RUN: -c %s -### 2> %t.log
+// RUN: FileCheck --check-prefix=CHECK-BASIC < %t.log %s
+//
+// CHECK-BASIC: clang
+// CHECK-BASIC: "-cc1"
+// 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
+// RUN: FileCheck --check-prefix=CHECK-NONPATH < %t.log %s
+//
+// CHECK-NONPATH: clang
+// CHECK-NONPATH: "-cc1"
+// CHECK-NONPATH-NOT: "-isysroot"
More information about the cfe-commits
mailing list