Honor MACOSX_DEPLOYMENT_TARGET environment variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68822 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp
index 975a6c1..87927f8 100644
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -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) {