Honor MACOSX_DEPLOYMENT_TARGET environment variable.

llvm-svn: 68822
This commit is contained in:
Daniel Dunbar 2009-04-10 21:00:07 +00:00
parent 5e8b8b37a3
commit b5023e90f4
2 changed files with 15 additions and 1 deletions

View File

@ -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 @@ DerivedArgList *Darwin_X86::TranslateArgs(InputArgList &Args) const {
// 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) {

View File

@ -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