]> granicus.if.org Git - clang/commitdiff
Driver/Darwin: Tweak link logic for simulator.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 31 Mar 2011 17:12:33 +0000 (17:12 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 31 Mar 2011 17:12:33 +0000 (17:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128641 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.h
lib/Driver/Tools.cpp

index ec16737f0d1cc28630e987226407b469bc6688f2..9c567b61916179d1425dc5d07bb3d46bed85ed0c 100644 (file)
@@ -103,6 +103,16 @@ public:
     return TargetIsIPhoneOS;
   }
 
+  bool isTargetIOSSimulator() const {
+    // In GCC, the simulator historically was treated as being OS X in some
+    // contexts, like determining the link logic, despite generally being called
+    // with an iOS deployment target. For compatibility, we detect the
+    // simulator is iOS + x86, and treat it differently in a few contexts.
+    return isTargetIPhoneOS() && 
+      (getTriple().getArch() == llvm::Triple::x86 ||
+       getTriple().getArch() == llvm::Triple::x86_64);
+  }
+
   bool isTargetInitialized() const { return TargetInitialized; }
 
   void getTargetVersion(unsigned (&Res)[3]) const {
index 8ac68ed9520430f9a6a75e1c1b1f6b658312f869..659b1194312ccc39711cf1b48fdfea67a70b3d31 100644 (file)
@@ -2885,7 +2885,10 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA,
             CmdArgs.push_back("-lcrt0.o");
           } else {
             // Derived from darwin_crt1 spec.
-            if (getDarwinToolChain().isTargetIPhoneOS()) {
+            if (getDarwinToolChain().isTargetIOSSimulator()) {
+              // The simulator doesn't have a versioned crt1 file.
+              CmdArgs.push_back("-lcrt1.o");
+            } else if (getDarwinToolChain().isTargetIPhoneOS()) {
               if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1))
                 CmdArgs.push_back("-lcrt1.o");
               else