Driver/Darwin: Honor IPHONEOS_DEPLOYMENT_TARGET.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94488 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-01-26 01:45:19 +00:00
Родитель 21ae3196c9
Коммит 816bc31ed4
4 изменённых файлов: 55 добавлений и 16 удалений

Просмотреть файл

@ -62,6 +62,8 @@ def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">;
def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">;
def err_drv_invalid_remap_file : Error<
"invalid option '%0' not of the form <from-file>;<to-file>">;
def err_drv_conflicting_deployment_targets : Error<
"conflicting deployment targets, both MACOSX_DEPLOYMENT_TARGET '%0' and IPHONEOS_DEPLOYMENT_TARGET '%1' are present in environment">;
def warn_drv_input_file_unused : Warning<
"%0: '%1' input unused when '%2' is present">;

Просмотреть файл

@ -403,22 +403,38 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
<< OSXVersion->getAsString(Args)
<< iPhoneVersion->getAsString(Args);
} else if (!OSXVersion && !iPhoneVersion) {
// Chose the default version based on the arch.
//
// FIXME: Are there iPhone overrides for this?
// If neither OS X nor iPhoneOS targets were specified, check for
// environment defines.
const char *OSXTarget = ::getenv("MACOSX_DEPLOYMENT_TARGET");
const char *iPhoneOSTarget = ::getenv("IPHONEOS_DEPLOYMENT_TARGET");
if (!isIPhoneOS()) {
// 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();
// Ignore empty strings.
if (OSXTarget && OSXTarget[0] == '\0')
OSXTarget = 0;
if (iPhoneOSTarget && iPhoneOSTarget[0] == '\0')
iPhoneOSTarget = 0;
if (OSXTarget && iPhoneOSTarget) {
getDriver().Diag(clang::diag::err_drv_conflicting_deployment_targets)
<< OSXTarget << iPhoneOSTarget;
} else if (OSXTarget) {
const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
DAL->append(DAL->MakeJoinedArg(0, O, Version));
} else {
const char *Version = IPhoneOSVersionMin.c_str();
DAL->append(DAL->MakeJoinedArg(0, O, OSXTarget));
} else if (iPhoneOSTarget) {
const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
DAL->append(DAL->MakeJoinedArg(0, O, Version));
DAL->append(DAL->MakeJoinedArg(0, O, iPhoneOSTarget));
} else {
// Otherwise, choose the default version based on the toolchain.
// FIXME: This is confusing it should be more explicit what the default
// target is.
if (isIPhoneOS()) {
const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ);
DAL->append(DAL->MakeJoinedArg(0, O, IPhoneOSVersionMin));
} else {
const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ);
DAL->append(DAL->MakeJoinedArg(0, O, MacosxVersionMin));
}
}
}

Просмотреть файл

@ -54,11 +54,15 @@ class VISIBILITY_HIDDEN Darwin : public ToolChain {
//
// FIXME: This should go away, such differences should be completely
// determined by the target triple.
//
// FIXME: It is also broken, we need to distinguish the "default target" from
// the actual target. The -m...-version-min strings and deployment targets can
// change this.
bool IsIPhoneOS;
/// The default macosx-version-min of this tool chain; empty until
/// initialized.
mutable std::string MacosxVersionMin;
std::string MacosxVersionMin;
/// The default iphoneos-version-min of this tool chain.
std::string IPhoneOSVersionMin;

Просмотреть файл

@ -1,6 +1,23 @@
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 %clang -ccc-host-triple i386-apple-darwin9 -E %s
// RUN: env MACOSX_DEPLOYMENT_TARGET=10.1 \
// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST0 -E %s
#ifdef TEST0
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ != 1010
#error Invalid version
#endif
#endif
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.0 \
// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST1 -E %s
#ifdef TEST1
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ != 20000
#error Invalid version
#endif
#endif
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=2.3.1 \
// RUN: %clang -ccc-host-triple i386-apple-darwin9 -DTEST2 -E %s
#ifdef TEST2
#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ != 20301
#error Invalid version
#endif
#endif