From: Tim Northover Date: Thu, 12 Dec 2013 11:55:52 +0000 (+0000) Subject: Darwin-embedded: find correct libclang_rt for embedded targets. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b4615075c174d9be07039f7a35189b137c6e0eb;p=clang Darwin-embedded: find correct libclang_rt for embedded targets. This refactors some of the Darwin toolchain classification to give a more solid distinction between the three primary Darwin platforms (OS X, IOS and IOS simulator) so that a 4th choice can be added temporarily: embedded MachO targets. Longer term, this support will be factored out into a separate class and no longer classified as "darwin-eabi", but the refactoring should still be useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197148 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 3a3b26a78e..d2d481c9f2 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -83,7 +83,7 @@ bool Darwin::HasNativeLLVMSupport() const { /// Darwin provides an ARC runtime starting in MacOS X 10.7 and iOS 5.0. ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const { - if (isTargetIPhoneOS()) + if (isTargetIOSBased()) return ObjCRuntime(ObjCRuntime::iOS, TargetVersion); if (isNonFragile) return ObjCRuntime(ObjCRuntime::MacOSX, TargetVersion); @@ -92,10 +92,14 @@ ObjCRuntime Darwin::getDefaultObjCRuntime(bool isNonFragile) const { /// Darwin provides a blocks runtime starting in MacOS X 10.6 and iOS 3.2. bool Darwin::hasBlocksRuntime() const { - if (isTargetIPhoneOS()) + if (isTargetIOSBased()) return !isIPhoneOSVersionLT(3, 2); - else + else if (isTargetMacOS()) return !isMacosxVersionLT(10, 6); + else { + assert(isTargetEmbedded() && "unexpected target platform"); + return false; + } } static const char *GetArmArchForMArch(StringRef Value) { @@ -134,6 +138,17 @@ static const char *GetArmArchForMCpu(StringRef Value) { .Default(0); } +static bool isSoftFloatABI(const ArgList &Args) { + Arg *A = Args.getLastArg(options::OPT_msoft_float, + options::OPT_mhard_float, + options::OPT_mfloat_abi_EQ); + if (!A) return false; + + return A->getOption().matches(options::OPT_msoft_float) || + (A->getOption().matches(options::OPT_mfloat_abi_EQ) && + A->getValue() == StringRef("soft")); +} + StringRef Darwin::getDarwinArchName(const ArgList &Args) const { switch (getTriple().getArch()) { default: @@ -174,7 +189,7 @@ std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args, Triple.setEnvironment(llvm::Triple::EABI); } else { SmallString<16> Str; - Str += isTargetIPhoneOS() ? "ios" : "macosx"; + Str += isTargetIOSBased() ? "ios" : "macosx"; Str += getTargetVersion().getAsString(); Triple.setOSName(Str); } @@ -247,10 +262,12 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args, void DarwinClang::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs, - const char *DarwinStaticLib, - bool AlwaysLink) const { + StringRef DarwinStaticLib, + bool AlwaysLink, + bool IsEmbedded) const { SmallString<128> P(getDriver().ResourceDir); - llvm::sys::path::append(P, "lib", "darwin", DarwinStaticLib); + llvm::sys::path::append(P, "lib", IsEmbedded ? "darwin_embedded" : "darwin", + DarwinStaticLib); // For now, allow missing resource libraries to support developers who may // not have compiler-rt checked out or integrated into their build (unless @@ -271,6 +288,21 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, return; } + if (isTargetEmbedded()) { + // Embedded targets are simple at the moment, not supporting sanitizers and + // with different libraries for each member of the product { static, PIC } x + // { hard-float, soft-float } + llvm::SmallString<32> CompilerRT = StringRef("libclang_rt."); + CompilerRT += + tools::arm::getARMFloatABI(getDriver(), Args, getTriple()) == "hard" + ? "hard" + : "soft"; + CompilerRT += Args.hasArg(options::OPT_fPIC) ? "_pic.a" : "_static.a"; + + AddLinkRuntimeLib(Args, CmdArgs, CompilerRT, false, true); + return; + } + // Darwin doesn't support real static executables, don't link any runtime // libraries with -static. if (Args.hasArg(options::OPT_static) || @@ -293,7 +325,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, Args.hasArg(options::OPT_fcreate_profile) || Args.hasArg(options::OPT_coverage)) { // Select the appropriate runtime library for the target. - if (isTargetIPhoneOS()) { + if (isTargetIOSBased()) { AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_ios.a"); } else { AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.profile_osx.a"); @@ -305,10 +337,11 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, // Add Ubsan runtime library, if required. if (Sanitize.needsUbsanRt()) { // FIXME: Move this check to SanitizerArgs::filterUnsupportedKinds. - if (isTargetIPhoneOS()) { + if (isTargetIOSBased()) { getDriver().Diag(diag::err_drv_clang_unsupported_per_platform) << "-fsanitize=undefined"; } else { + assert(isTargetMacOS() && "unexpected non OS X target"); AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ubsan_osx.a", true); // The Ubsan runtime library requires C++. @@ -320,7 +353,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, // should not be linked with the runtime library. if (Sanitize.needsAsanRt()) { // FIXME: Move this check to SanitizerArgs::filterUnsupportedKinds. - if (isTargetIPhoneOS() && !isTargetIOSSimulator()) { + if (isTargetIPhoneOS()) { getDriver().Diag(diag::err_drv_clang_unsupported_per_platform) << "-fsanitize=address"; } else { @@ -348,7 +381,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, CmdArgs.push_back("-lSystem"); // Select the dynamic runtime library and the target specific static library. - if (isTargetIPhoneOS()) { + if (isTargetIOSBased()) { // If we are compiling as iOS / simulator, don't attempt to link libgcc_s.1, // it never went into the SDK. // Linking against libgcc_s.1 isn't needed for iOS 5.0+ @@ -358,6 +391,7 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, // We currently always need a static runtime library for iOS. AddLinkRuntimeLib(Args, CmdArgs, "libclang_rt.ios.a"); } else { + assert(isTargetMacOS() && "unexpected non MacOS platform"); // The dynamic runtime library was merged with libSystem for 10.6 and // beyond; only 10.4 and 10.5 need an additional runtime library. if (isMacosxVersionLT(10, 5)) @@ -448,9 +482,9 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { // If no OSX or iOS target has been specified and we're compiling for armv7, // go ahead as assume we're targeting iOS. + StringRef DarwinArchName = getDarwinArchName(Args); if (OSXTarget.empty() && iOSTarget.empty() && - (getDarwinArchName(Args) == "armv7" || - getDarwinArchName(Args) == "armv7s")) + (DarwinArchName == "armv7" || DarwinArchName == "armv7s")) iOSTarget = iOSVersionMin; // Handle conflicting deployment targets @@ -488,7 +522,8 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { options::OPT_mios_simulator_version_min_EQ); iOSSimVersion = Args.MakeJoinedArg(0, O, iOSSimTarget); Args.append(iOSSimVersion); - } else { + } else if (DarwinArchName != "armv6m" && DarwinArchName != "armv7m" && + DarwinArchName != "armv7em") { // Otherwise, assume we are targeting OS X. const Option O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); OSXVersion = Args.MakeJoinedArg(0, O, MacosxVersionMin); @@ -496,6 +531,16 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { } } + DarwinPlatformKind Platform; + if (OSXVersion) + Platform = MacOS; + else if (iOSVersion) + Platform = IPhoneOS; + else if (iOSSimVersion) + Platform = IPhoneOSSimulator; + else + Platform = Embedded; + // Reject invalid architecture combinations. if (iOSSimVersion && (getTriple().getArch() != llvm::Triple::x86 && getTriple().getArch() != llvm::Triple::x86_64)) { @@ -506,14 +551,14 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { // Set the tool chain target information. unsigned Major, Minor, Micro; bool HadExtra; - if (OSXVersion) { + if (Platform == MacOS) { assert((!iOSVersion && !iOSSimVersion) && "Unknown target platform!"); if (!Driver::GetReleaseVersion(OSXVersion->getValue(), Major, Minor, Micro, HadExtra) || HadExtra || Major != 10 || Minor >= 100 || Micro >= 100) getDriver().Diag(diag::err_drv_invalid_version_number) << OSXVersion->getAsString(Args); - } else { + } else if (Platform == IPhoneOS || Platform == IPhoneOSSimulator) { const Arg *Version = iOSVersion ? iOSVersion : iOSSimVersion; assert(Version && "Unknown target platform!"); if (!Driver::GetReleaseVersion(Version->getValue(), Major, Minor, @@ -521,19 +566,20 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { Major >= 10 || Minor >= 100 || Micro >= 100) getDriver().Diag(diag::err_drv_invalid_version_number) << Version->getAsString(Args); + } else { + assert(Platform == Embedded && "unexpected platform"); + Major = Minor = Micro = 0; } - bool IsIOSSim = bool(iOSSimVersion); - // 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 as iOS + x86, and treat it differently in a few contexts. if (iOSVersion && (getTriple().getArch() == llvm::Triple::x86 || getTriple().getArch() == llvm::Triple::x86_64)) - IsIOSSim = true; + Platform = IPhoneOSSimulator; - setTarget(/*IsIPhoneOS=*/ !OSXVersion, Major, Minor, Micro, IsIOSSim); + setTarget(Platform, Major, Minor, Micro); } void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args, @@ -837,7 +883,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, // 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)) { + if (isTargetIOSBased() && !isIPhoneOSVersionLT(6, 0)) { for (ArgList::iterator it = DAL->begin(), ie = DAL->end(); it != ie; ) { Arg *A = *it; ++it; @@ -854,7 +900,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, // Default to use libc++ on OS X 10.9+ and iOS 7+. if (((isTargetMacOS() && !isMacosxVersionLT(10, 9)) || - (isTargetIPhoneOS() && !isIPhoneOSVersionLT(7, 0))) && + (isTargetIOSBased() && !isIPhoneOSVersionLT(7, 0))) && !Args.getLastArg(options::OPT_stdlib_EQ)) DAL->AddJoinedArg(0, Opts.getOption(options::OPT_stdlib_EQ), "libc++"); @@ -865,7 +911,7 @@ DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args, StringRef where; // Complain about targeting iOS < 5.0 in any way. - if (isTargetIPhoneOS() && isIPhoneOSVersionLT(5, 0)) + if (isTargetIOSBased() && isIPhoneOSVersionLT(5, 0)) where = "iOS 5.0"; if (where != StringRef()) { @@ -911,12 +957,11 @@ bool Darwin::SupportsProfiling() const { } bool Darwin::SupportsObjCGC() const { - // Garbage collection is supported everywhere except on iPhone OS. - return !isTargetIPhoneOS(); + return isTargetMacOS(); } void Darwin::CheckObjCARC() const { - if (isTargetIPhoneOS() || !isMacosxVersionLT(10, 6)) + if (isTargetIOSBased()|| (isTargetMacOS() && !isMacosxVersionLT(10, 6))) return; getDriver().Diag(diag::err_arc_unsupported_on_toolchain); } @@ -1299,17 +1344,6 @@ void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const { BiarchTripleAliases.push_back(BiarchTriple.str()); } -static bool isSoftFloatABI(const ArgList &Args) { - Arg *A = Args.getLastArg(options::OPT_msoft_float, - options::OPT_mhard_float, - options::OPT_mfloat_abi_EQ); - if (!A) return false; - - return A->getOption().matches(options::OPT_msoft_float) || - (A->getOption().matches(options::OPT_mfloat_abi_EQ) && - A->getValue() == StringRef("soft")); -} - static bool isMipsArch(llvm::Triple::ArchType Arch) { return Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel || diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index c061a1f462..c13eeee1b1 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -210,11 +210,14 @@ private: // the argument translation business. mutable bool TargetInitialized; - /// Whether we are targeting iPhoneOS target. - mutable bool TargetIsIPhoneOS; + enum DarwinPlatformKind { + MacOS, + IPhoneOS, + IPhoneOSSimulator, + Embedded // FIXME: embedded isn't really a Darwin platform. + }; - /// Whether we are targeting the iPhoneOS simulator target. - mutable bool TargetIsIPhoneOSSimulator; + mutable DarwinPlatformKind TargetPlatform; /// The OS version we are targeting. mutable VersionTuple TargetVersion; @@ -244,36 +247,42 @@ public: // FIXME: Eliminate these ...Target functions and derive separate tool chains // for these targets and put version in constructor. - void setTarget(bool IsIPhoneOS, unsigned Major, unsigned Minor, - unsigned Micro, bool IsIOSSim) const { - assert((!IsIOSSim || IsIPhoneOS) && "Unexpected deployment target!"); - + void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor, + unsigned Micro) const { // FIXME: For now, allow reinitialization as long as values don't // change. This will go away when we move away from argument translation. - if (TargetInitialized && TargetIsIPhoneOS == IsIPhoneOS && - TargetIsIPhoneOSSimulator == IsIOSSim && + if (TargetInitialized && TargetPlatform == Platform && TargetVersion == VersionTuple(Major, Minor, Micro)) return; assert(!TargetInitialized && "Target already initialized!"); TargetInitialized = true; - TargetIsIPhoneOS = IsIPhoneOS; - TargetIsIPhoneOSSimulator = IsIOSSim; + TargetPlatform = Platform; TargetVersion = VersionTuple(Major, Minor, Micro); } bool isTargetIPhoneOS() const { assert(TargetInitialized && "Target not initialized!"); - return TargetIsIPhoneOS; + return TargetPlatform == IPhoneOS; } bool isTargetIOSSimulator() const { assert(TargetInitialized && "Target not initialized!"); - return TargetIsIPhoneOSSimulator; + return TargetPlatform == IPhoneOSSimulator; + } + + bool isTargetIOSBased() const { + assert(TargetInitialized && "Target not initialized!"); + return isTargetIPhoneOS() || isTargetIOSSimulator(); } bool isTargetMacOS() const { - return !isTargetIOSSimulator() && !isTargetIPhoneOS(); + return TargetPlatform == MacOS; + } + + bool isTargetEmbedded() const { + assert(TargetInitialized && "Target not initialized!"); + return TargetPlatform == Embedded; } bool isTargetInitialized() const { return TargetInitialized; } @@ -289,12 +298,12 @@ public: StringRef getDarwinArchName(const llvm::opt::ArgList &Args) const; bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { - assert(isTargetIPhoneOS() && "Unexpected call for OS X target!"); + assert(isTargetIOSBased() && "Unexpected call for non iOS target!"); return TargetVersion < VersionTuple(V0, V1, V2); } bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { - assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!"); + assert(isTargetMacOS() && "Unexpected call for non OS X target!"); return TargetVersion < VersionTuple(V0, V1, V2); } @@ -350,15 +359,20 @@ public: // This is only used with the non-fragile ABI and non-legacy dispatch. // Mixed dispatch is used everywhere except OS X before 10.6. - return !(!isTargetIPhoneOS() && isMacosxVersionLT(10, 6)); + return !(isTargetMacOS() && isMacosxVersionLT(10, 6)); } virtual bool IsUnwindTablesDefault() const; virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { // Stack protectors default to on for user code on 10.5, // and for everything in 10.6 and beyond - return isTargetIPhoneOS() || - (!isMacosxVersionLT(10, 6) || - (!isMacosxVersionLT(10, 5) && !KernelOrKext)); + if (isTargetIOSBased()) + return 1; + else if (isTargetMacOS() && !isMacosxVersionLT(10, 6)) + return 1; + else if (isTargetMacOS() && !isMacosxVersionLT(10, 5) && !KernelOrKext) + return 1; + + return 0; } virtual RuntimeLibType GetDefaultRuntimeLibType() const { return ToolChain::RLT_CompilerRT; @@ -393,8 +407,9 @@ public: llvm::opt::ArgStringList &CmdArgs) const; void AddLinkRuntimeLib(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, - const char *DarwinStaticLib, - bool AlwaysLink = false) const; + StringRef DarwinStaticLib, + bool AlwaysLink = false, + bool IsEmbedded = false) const; virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index c006939d3d..7870f424eb 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -703,9 +703,8 @@ static void getARMFPUFeatures(const Driver &D, const Arg *A, // Select the float ABI as determined by -msoft-float, -mhard-float, and // -mfloat-abi=. -static StringRef getARMFloatABI(const Driver &D, - const ArgList &Args, - const llvm::Triple &Triple) { +StringRef tools::arm::getARMFloatABI(const Driver &D, const ArgList &Args, + const llvm::Triple &Triple) { StringRef FloatABI; if (Arg *A = Args.getLastArg(options::OPT_msoft_float, options::OPT_mhard_float, @@ -785,7 +784,7 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple, const ArgList &Args, std::vector &Features, bool ForAS) { - StringRef FloatABI = getARMFloatABI(D, Args, Triple); + StringRef FloatABI = tools::arm::getARMFloatABI(D, Args, Triple); if (!ForAS) { // FIXME: Note, this is a hack, the LLVM backend doesn't actually use these // yet (it uses the -mfloat-abi and -msoft-float options), and it is @@ -872,7 +871,7 @@ void Clang::AddARMTargetArgs(const ArgList &Args, CmdArgs.push_back(ABIName); // Determine floating point ABI from the options & target defaults. - StringRef FloatABI = getARMFloatABI(D, Args, Triple); + StringRef FloatABI = tools::arm::getARMFloatABI(D, Args, Triple); if (FloatABI == "soft") { // Floating point operations and argument passing are soft. // @@ -4824,7 +4823,7 @@ void darwin::Link::AddLinkArgs(Compilation &C, Args.AddLastArg(CmdArgs, options::OPT_all__load); Args.AddAllArgs(CmdArgs, options::OPT_allowable__client); Args.AddLastArg(CmdArgs, options::OPT_bind__at__load); - if (DarwinTC.isTargetIPhoneOS()) + if (DarwinTC.isTargetIOSBased()) Args.AddLastArg(CmdArgs, options::OPT_arch__errors__fatal); Args.AddLastArg(CmdArgs, options::OPT_dead__strip); Args.AddLastArg(CmdArgs, options::OPT_no__dead__strip__inits__and__terms); @@ -4847,13 +4846,16 @@ void darwin::Link::AddLinkArgs(Compilation &C, // // FIXME: We may be able to remove this, once we can verify no one depends on // it. - if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ)) + if (Args.hasArg(options::OPT_mios_simulator_version_min_EQ)) { CmdArgs.push_back("-ios_simulator_version_min"); - else if (DarwinTC.isTargetIPhoneOS()) + CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + } else if (DarwinTC.isTargetIOSBased()) { CmdArgs.push_back("-iphoneos_version_min"); - else + CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + } else if (DarwinTC.isTargetMacOS()) { CmdArgs.push_back("-macosx_version_min"); - CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString())); + } Args.AddLastArg(CmdArgs, options::OPT_nomultidefs); Args.AddLastArg(CmdArgs, options::OPT_multi__module); @@ -4978,7 +4980,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, } else if (getDarwinToolChain().isTargetIPhoneOS()) { if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1)) CmdArgs.push_back("-ldylib1.o"); - } else { + } else if (getDarwinToolChain().isTargetMacOS()) { if (getDarwinToolChain().isMacosxVersionLT(10, 5)) CmdArgs.push_back("-ldylib1.o"); else if (getDarwinToolChain().isMacosxVersionLT(10, 6)) @@ -4994,7 +4996,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, } else if (getDarwinToolChain().isTargetIPhoneOS()) { if (getDarwinToolChain().isIPhoneOSVersionLT(3, 1)) CmdArgs.push_back("-lbundle1.o"); - } else { + } else if (getDarwinToolChain().isTargetMacOS()) { if (getDarwinToolChain().isMacosxVersionLT(10, 6)) CmdArgs.push_back("-lbundle1.o"); } @@ -5034,7 +5036,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-lcrt1.o"); else if (getDarwinToolChain().isIPhoneOSVersionLT(6, 0)) CmdArgs.push_back("-lcrt1.3.1.o"); - } else { + } else if (getDarwinToolChain().isTargetMacOS()) { if (getDarwinToolChain().isMacosxVersionLT(10, 5)) CmdArgs.push_back("-lcrt1.o"); else if (getDarwinToolChain().isMacosxVersionLT(10, 6)) @@ -5049,7 +5051,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, } } - if (!getDarwinToolChain().isTargetIPhoneOS() && + if (getDarwinToolChain().isTargetMacOS() && Args.hasArg(options::OPT_shared_libgcc) && getDarwinToolChain().isMacosxVersionLT(10, 5)) { const char *Str = @@ -6234,8 +6236,8 @@ void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA, if (MArch == "armv8" || MArch == "armv8a" || MArch == "armv8-a") CmdArgs.push_back("-mfpu=crypto-neon-fp-armv8"); - StringRef ARMFloatABI = getARMFloatABI(getToolChain().getDriver(), Args, - getToolChain().getTriple()); + StringRef ARMFloatABI = tools::arm::getARMFloatABI( + getToolChain().getDriver(), Args, getToolChain().getTriple()); CmdArgs.push_back(Args.MakeArgString("-mfloat-abi=" + ARMFloatABI)); Args.AddLastArg(CmdArgs, options::OPT_march_EQ); diff --git a/lib/Driver/Tools.h b/lib/Driver/Tools.h index e4b1fdfad8..b2dd6d9713 100644 --- a/lib/Driver/Tools.h +++ b/lib/Driver/Tools.h @@ -606,6 +606,10 @@ namespace visualstudio { }; } // end namespace visualstudio +namespace arm { + StringRef getARMFloatABI(const Driver &D, const llvm::opt::ArgList &Args, + const llvm::Triple &Triple); +} namespace XCore { // For XCore, we do not need to instantiate tools for PreProcess, PreCompile and Compile. // We simply use "clang -cc1" for those actions. diff --git a/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.hard_pic.a b/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.hard_pic.a new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.hard_static.a b/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.hard_static.a new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.soft_pic.a b/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.soft_pic.a new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.soft_static.a b/test/Driver/Inputs/resource_dir/lib/darwin_embedded/libclang_rt.soft_static.a new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/darwin-embedded.c b/test/Driver/darwin-embedded.c new file mode 100644 index 0000000000..fb3ead6cbb --- /dev/null +++ b/test/Driver/darwin-embedded.c @@ -0,0 +1,26 @@ +// RUN: %clang -target x86_64-apple-darwin -arch armv6m -resource-dir=%S/Inputs/resource_dir %s -### 2> %t +// RUN: %clang -target x86_64-apple-darwin -arch armv7em -resource-dir=%S/Inputs/resource_dir %s -### 2>> %t +// RUN: %clang -target x86_64-apple-darwin -arch armv7em -mhard-float -resource-dir=%S/Inputs/resource_dir %s -### 2>> %t + +// RUN: %clang -target x86_64-apple-darwin -arch armv7m -fPIC -resource-dir=%S/Inputs/resource_dir %s -### 2>> %t +// RUN: %clang -target x86_64-apple-darwin -arch armv7 -fPIC -mfloat-abi=hard -resource-dir=%S/Inputs/resource_dir %s -### 2>> %t +// RUN: %clang -target x86_64-apple-darwin-eabi -arch armv7em -fPIC -mfloat-abi=softfp -resource-dir=%S/Inputs/resource_dir %s -### 2>> %t + +// ARMv6m has no float +// CHECK: libclang_rt.soft_static.a + +// ARMv7em does, but defaults to soft +// CHECK: libclang_rt.soft_static.a + +// Which can be overridden +// CHECK: libclang_rt.hard_static.a + +// ARMv7m has no float either +// CHECK: libclang_rt.soft_pic.a + +// But it can be enabled on ARMv7 +// CHECK: libclang_rt.hard_pic.a + +// "softfp" must link against a soft-float library since that's what the +// callers we're compiling will expect. +// CHECK: libclang_rt.soft_pic.a