[cfe-commits] r68822 - in /cfe/trunk: lib/Driver/ToolChains.cpp test/Driver/darwin-version.c
Daniel Dunbar
daniel at zuster.org
Fri Apr 10 14:00:07 PDT 2009
Author: ddunbar
Date: Fri Apr 10 16:00:07 2009
New Revision: 68822
URL: http://llvm.org/viewvc/llvm-project?rev=68822&view=rev
Log:
Honor MACOSX_DEPLOYMENT_TARGET environment variable.
Added:
cfe/trunk/test/Driver/darwin-version.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=68822&r1=68821&r2=68822&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Apr 10 16:00:07 2009
@@ -20,6 +20,8 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Path.h"
+#include <cstdlib> // ::getenv
+
using namespace clang::driver;
using namespace clang::driver::toolchains;
@@ -152,8 +154,14 @@
// Chose the default version based on the arch.
//
// FIXME: This will need to be fixed when we merge in arm support.
+
+ // Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version
+ // from the host.
+ const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET");
+ if (!Version)
+ Version = MacosxVersionMin.c_str();
const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
- DAL->append(DAL->MakeJoinedArg(0, O, MacosxVersionMin.c_str()));
+ DAL->append(DAL->MakeJoinedArg(0, O, Version));
}
for (ArgList::iterator it = Args.begin(), ie = Args.end(); it != ie; ++it) {
Added: cfe/trunk/test/Driver/darwin-version.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=68822&view=auto
==============================================================================
--- cfe/trunk/test/Driver/darwin-version.c (added)
+++ cfe/trunk/test/Driver/darwin-version.c Fri Apr 10 16:00:07 2009
@@ -0,0 +1,6 @@
+// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 clang -E %s
+
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
+#error Invalid version
+#endif
+
More information about the cfe-commits
mailing list