From: Daniel Dunbar Date: Thu, 31 Mar 2011 17:12:33 +0000 (+0000) Subject: Driver/Darwin: Tweak link logic for simulator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4035580e3475db9013f335ce2b8a49dd1988a79a;p=clang Driver/Darwin: Tweak link logic for simulator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128641 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index ec16737f0d..9c567b6191 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -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 { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 8ac68ed952..659b119431 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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