[cfe-commits] r94488 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h test/Driver/darwin-version.c
Daniel Dunbar
daniel at zuster.org
Mon Jan 25 17:45:19 PST 2010
Author: ddunbar
Date: Mon Jan 25 19:45:19 2010
New Revision: 94488
URL: http://llvm.org/viewvc/llvm-project?rev=94488&view=rev
Log:
Driver/Darwin: Honor IPHONEOS_DEPLOYMENT_TARGET.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/test/Driver/darwin-version.c
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=94488&r1=94487&r2=94488&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jan 25 19:45:19 2010
@@ -62,6 +62,8 @@
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">;
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=94488&r1=94487&r2=94488&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Jan 25 19:45:19 2010
@@ -403,22 +403,38 @@
<< 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 (!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();
+ // 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");
+
+ // 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));
+ }
}
}
Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=94488&r1=94487&r2=94488&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon Jan 25 19:45:19 2010
@@ -54,11 +54,15 @@
//
// 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;
Modified: cfe/trunk/test/Driver/darwin-version.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-version.c?rev=94488&r1=94487&r2=94488&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-version.c (original)
+++ cfe/trunk/test/Driver/darwin-version.c Mon Jan 25 19:45:19 2010
@@ -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
More information about the cfe-commits
mailing list