Driver/Darwin: Fix a few link arguments when targetting different iPhoneOS
versions to match gcc (which is matching linker changes).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94640 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
index 758007f..71de8b7 100644
--- a/lib/Driver/ToolChains.h
+++ b/lib/Driver/ToolChains.h
@@ -141,6 +141,12 @@
return isMacosxVersionLT(A, B);
}
+ bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
+ assert(isTargetIPhoneOS() && "Unexpected call for OS X target!");
+ unsigned B[3] = { V0, V1, V2 };
+ return isMacosxVersionLT(TargetVersion, B);
+ }
+
/// AddLinkSearchPathArgs - Add the linker search paths to \arg CmdArgs.
///
/// \param Args - The input argument list.
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index f6e88e2..e75e12c 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -2039,16 +2039,26 @@
// Derived from startfile spec.
if (Args.hasArg(options::OPT_dynamiclib)) {
// Derived from darwin_dylib1 spec.
- if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
- CmdArgs.push_back("-ldylib1.o");
- else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
- CmdArgs.push_back("-ldylib1.10.5.o");
+ if (getDarwinToolChain().isTargetIPhoneOS()) {
+ if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
+ CmdArgs.push_back("-ldylib1.o");
+ } else {
+ if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 5))
+ CmdArgs.push_back("-ldylib1.o");
+ else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10,6))
+ CmdArgs.push_back("-ldylib1.10.5.o");
+ }
} else {
if (Args.hasArg(options::OPT_bundle)) {
if (!Args.hasArg(options::OPT_static)) {
// Derived from darwin_bundle1 spec.
- if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
- CmdArgs.push_back("-lbundle1.o");
+ if (getDarwinToolChain().isTargetIPhoneOS()) {
+ if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
+ CmdArgs.push_back("-lbundle1.o");
+ } else {
+ if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin, 10, 6))
+ CmdArgs.push_back("-lbundle1.o");
+ }
}
} else {
if (Args.hasArg(options::OPT_pg)) {
@@ -2069,7 +2079,10 @@
} else {
// Derived from darwin_crt1 spec.
if (getDarwinToolChain().isTargetIPhoneOS()) {
- CmdArgs.push_back("-lcrt1.o");
+ if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
+ CmdArgs.push_back("-lcrt1.o");
+ else
+ CmdArgs.push_back("-lcrt1.3.1.o");
} else if (getDarwinToolChain().isMacosxVersionLT(MacosxVersionMin,
10, 5))
CmdArgs.push_back("-lcrt1.o");