]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Fix a few link arguments when targetting different iPhoneOS
authorDaniel Dunbar <daniel@zuster.org>
Wed, 27 Jan 2010 00:56:56 +0000 (00:56 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 27 Jan 2010 00:56:56 +0000 (00:56 +0000)
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

lib/Driver/ToolChains.h
lib/Driver/Tools.cpp
test/Driver/darwin-ld.c

index 758007f03a72843b0ca3bb09385ce7b1e22acc09..71de8b7109ffa2b438ec4584fe495b3f1a3d30cb 100644 (file)
@@ -141,6 +141,12 @@ public:
     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.
index f6e88e2264c5647ef89fad052100e0ff79c280c2..e75e12c496284b212c6e7421c5cccc51e226d326 100644 (file)
@@ -2039,16 +2039,26 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
     // 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 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
           } 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");
index de751a67d9655ed412478c5df1b44ac37c50be6d..9916d48d14c0ea178d2e68b4d52774dd1f52d6d0 100644 (file)
 // RUN: %clang -ccc-host-triple i386-apple-darwin9 -### -arch i386 -arch x86_64 -g %s 2> %t.log
 // RUN: grep dsymutil %t.log | count 0
 
+// Check linker changes that came with new linkedit format.
+// RUN: touch %t.o
+// RUN: %clang -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
+// RUN: %clang -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
 
+// LINK_IPHONE_3_0: ld"
+// LINK_IPHONE_3_0-NOT: -lcrt1.3.1.o
+// LINK_IPHONE_3_0: -lcrt1.o
+// LINK_IPHONE_3_0: -lSystem
+// LINK_IPHONE_3_0: ld"
+// LINK_IPHONE_3_0: -dylib
+// LINK_IPHONE_3_0: -ldylib1.o
+// LINK_IPHONE_3_0: -lSystem
+// LINK_IPHONE_3_0: ld"
+// LINK_IPHONE_3_0: -lbundle1.o
+// LINK_IPHONE_3_0: -lSystem
 
+// RUN: %clang -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
+// RUN: %clang -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
+// RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
+
+// LINK_IPHONE_3_1: ld"
+// LINK_IPHONE_3_1-NOT: -lcrt1.o
+// LINK_IPHONE_3_1: -lcrt1.3.1.o
+// LINK_IPHONE_3_1: -lSystem
+// LINK_IPHONE_3_1: ld"
+// LINK_IPHONE_3_1: -dylib
+// LINK_IPHONE_3_1-NOT: -ldylib1.o
+// LINK_IPHONE_3_1: -lSystem
+// LINK_IPHONE_3_1: ld"
+// LINK_IPHONE_3_1-NOT: -lbundle1.o
+// LINK_IPHONE_3_1: -lSystem