diff options
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/ToolChains.cpp | 32 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 31 |
2 files changed, 52 insertions, 11 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index f62fbf1160..81f388781a 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -332,7 +332,9 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, // Darwin doesn't support real static executables, don't link any runtime // libraries with -static. - if (Args.hasArg(options::OPT_static)) + if (Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_fapple_kext) || + Args.hasArg(options::OPT_mkernel)) return; // Reject -static-libgcc for now, we can deal with this when and if someone @@ -676,7 +678,14 @@ void DarwinClang::AddCCKextLibArgs(const ArgList &Args, llvm::sys::Path P(getDriver().ResourceDir); P.appendComponent("lib"); P.appendComponent("darwin"); - P.appendComponent("libclang_rt.cc_kext.a"); + + // Use the newer cc_kext for iOS ARM after 6.0. + if (!isTargetIPhoneOS() || isTargetIOSSimulator() || + !isIPhoneOSVersionLT(6, 0)) { + P.appendComponent("libclang_rt.cc_kext.a"); + } else { + P.appendComponent("libclang_rt.cc_kext_ios5.a"); + } // For now, allow missing resource libraries to support developers who may // not have compiler-rt checked out or integrated into their build. @@ -902,6 +911,25 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, if (BoundArch) AddDeploymentTarget(*DAL); + // For iOS 6, undo the translation to add -static for -mkernel/-fapple-kext. + // FIXME: It would be far better to avoid inserting those -static arguments, + // but we can't check the deployment target in the translation code until + // it is set here. + if (isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) { + for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) { + Arg *A = *it; + ++it; + if (A->getOption().getID() != options::OPT_mkernel && + A->getOption().getID() != options::OPT_fapple_kext) + continue; + assert(it != ie && "unexpected argument translation"); + A = *it; + assert(A->getOption().getID() == options::OPT_static && + "missing expected -static argument"); + it = DAL->getArgs().erase(it); + } + } + // Validate the C++ standard library choice. CXXStdlibType Type = GetCXXStdlibType(*DAL); if (Type == ToolChain::CST_Libcxx) { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 63c84f629c..97b3c4e943 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -674,7 +674,9 @@ void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs, bool KernelOrKext) const { const Driver &D = getToolChain().getDriver(); - llvm::Triple Triple = getToolChain().getTriple(); + // Get the effective triple, which takes into account the deployment target. + std::string TripleStr = getToolChain().ComputeEffectiveClangTriple(Args); + llvm::Triple Triple(TripleStr); // Select the ABI to use. // @@ -759,8 +761,10 @@ void Clang::AddARMTargetArgs(const ArgList &Args, // Kernel code has more strict alignment requirements. if (KernelOrKext) { - CmdArgs.push_back("-backend-option"); - CmdArgs.push_back("-arm-long-calls"); + if (Triple.getOS() != llvm::Triple::IOS || Triple.isOSVersionLT(6)) { + CmdArgs.push_back("-backend-option"); + CmdArgs.push_back("-arm-long-calls"); + } CmdArgs.push_back("-backend-option"); CmdArgs.push_back("-arm-strict-align"); @@ -1680,7 +1684,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } // Note that these flags are trump-cards. Regardless of the order w.r.t. the // PIC or PIE options above, if these show up, PIC is disabled. - if (Args.hasArg(options::OPT_mkernel)) + llvm::Triple Triple(TripleStr); + if ((Args.hasArg(options::OPT_mkernel) || + Args.hasArg(options::OPT_fapple_kext)) && + (Triple.getOS() != llvm::Triple::IOS || + Triple.isOSVersionLT(6))) PICDisabled = true; if (Args.hasArg(options::OPT_static)) PICDisabled = true; @@ -3671,7 +3679,10 @@ void darwin::CC1::AddCC1Args(const ArgList &Args, CheckCodeGenerationOptions(D, Args); // Derived from cc1 spec. - if (!Args.hasArg(options::OPT_mkernel) && !Args.hasArg(options::OPT_static) && + if ((!Args.hasArg(options::OPT_mkernel) || + (getDarwinToolChain().isTargetIPhoneOS() && + !getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) && + !Args.hasArg(options::OPT_static) && !Args.hasArg(options::OPT_mdynamic_no_pic)) CmdArgs.push_back("-fPIC"); @@ -4125,9 +4136,11 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-force_cpusubtype_ALL"); if (getToolChain().getTriple().getArch() != llvm::Triple::x86_64 && - (Args.hasArg(options::OPT_mkernel) || - Args.hasArg(options::OPT_static) || - Args.hasArg(options::OPT_fapple_kext))) + (((Args.hasArg(options::OPT_mkernel) || + Args.hasArg(options::OPT_fapple_kext)) && + (!getDarwinToolChain().isTargetIPhoneOS() || + getDarwinToolChain().isIPhoneOSVersionLT(6, 0))) || + Args.hasArg(options::OPT_static))) CmdArgs.push_back("-static"); Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, @@ -4475,7 +4488,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, } else if (getDarwinToolChain().isTargetIPhoneOS()) { if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1)) CmdArgs.push_back("-lcrt1.o"); - else + else if (getDarwinToolChain().isIPhoneOSVersionLT(6, 0)) CmdArgs.push_back("-lcrt1.3.1.o"); } else { if (getDarwinToolChain().isMacosxVersionLT(10, 5)) |