123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918 |
- //===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
- //
- // The LLVM Compiler Infrastructure
- //
- // This file is distributed under the University of Illinois Open Source
- // License. See LICENSE.TXT for details.
- //
- //===----------------------------------------------------------------------===//
- #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
- #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
- #include "Tools.h"
- #include "clang/Basic/VersionTuple.h"
- #include "clang/Driver/Action.h"
- #include "clang/Driver/Multilib.h"
- #include "clang/Driver/ToolChain.h"
- #include "llvm/ADT/DenseMap.h"
- #include "llvm/ADT/Optional.h"
- #include "llvm/Support/Compiler.h"
- #include <set>
- #include <vector>
- namespace clang {
- namespace driver {
- namespace toolchains {
- /// Generic_GCC - A tool chain using the 'gcc' command to perform
- /// all subcommands; this relies on gcc translating the majority of
- /// command line options.
- class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
- public:
- /// \brief Struct to store and manipulate GCC versions.
- ///
- /// We rely on assumptions about the form and structure of GCC version
- /// numbers: they consist of at most three '.'-separated components, and each
- /// component is a non-negative integer except for the last component. For
- /// the last component we are very flexible in order to tolerate release
- /// candidates or 'x' wildcards.
- ///
- /// Note that the ordering established among GCCVersions is based on the
- /// preferred version string to use. For example we prefer versions without
- /// a hard-coded patch number to those with a hard coded patch number.
- ///
- /// Currently this doesn't provide any logic for textual suffixes to patches
- /// in the way that (for example) Debian's version format does. If that ever
- /// becomes necessary, it can be added.
- struct GCCVersion {
- /// \brief The unparsed text of the version.
- std::string Text;
- /// \brief The parsed major, minor, and patch numbers.
- int Major, Minor, Patch;
- /// \brief The text of the parsed major, and major+minor versions.
- std::string MajorStr, MinorStr;
- /// \brief Any textual suffix on the patch number.
- std::string PatchSuffix;
- static GCCVersion Parse(StringRef VersionText);
- bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch,
- StringRef RHSPatchSuffix = StringRef()) const;
- bool operator<(const GCCVersion &RHS) const {
- return isOlderThan(RHS.Major, RHS.Minor, RHS.Patch, RHS.PatchSuffix);
- }
- bool operator>(const GCCVersion &RHS) const { return RHS < *this; }
- bool operator<=(const GCCVersion &RHS) const { return !(*this > RHS); }
- bool operator>=(const GCCVersion &RHS) const { return !(*this < RHS); }
- };
- /// \brief This is a class to find a viable GCC installation for Clang to
- /// use.
- ///
- /// This class tries to find a GCC installation on the system, and report
- /// information about it. It starts from the host information provided to the
- /// Driver, and has logic for fuzzing that where appropriate.
- class GCCInstallationDetector {
- bool IsValid;
- llvm::Triple GCCTriple;
- // FIXME: These might be better as path objects.
- std::string GCCInstallPath;
- std::string GCCParentLibPath;
- /// The primary multilib appropriate for the given flags.
- Multilib SelectedMultilib;
- /// On Biarch systems, this corresponds to the default multilib when
- /// targeting the non-default multilib. Otherwise, it is empty.
- llvm::Optional<Multilib> BiarchSibling;
- GCCVersion Version;
- // We retain the list of install paths that were considered and rejected in
- // order to print out detailed information in verbose mode.
- std::set<std::string> CandidateGCCInstallPaths;
- /// The set of multilibs that the detected installation supports.
- MultilibSet Multilibs;
- public:
- GCCInstallationDetector() : IsValid(false) {}
- void init(const Driver &D, const llvm::Triple &TargetTriple,
- const llvm::opt::ArgList &Args);
- /// \brief Check whether we detected a valid GCC install.
- bool isValid() const { return IsValid; }
- /// \brief Get the GCC triple for the detected install.
- const llvm::Triple &getTriple() const { return GCCTriple; }
- /// \brief Get the detected GCC installation path.
- StringRef getInstallPath() const { return GCCInstallPath; }
- /// \brief Get the detected GCC parent lib path.
- StringRef getParentLibPath() const { return GCCParentLibPath; }
- /// \brief Get the detected Multilib
- const Multilib &getMultilib() const { return SelectedMultilib; }
- /// \brief Get the whole MultilibSet
- const MultilibSet &getMultilibs() const { return Multilibs; }
- /// Get the biarch sibling multilib (if it exists).
- /// \return true iff such a sibling exists
- bool getBiarchSibling(Multilib &M) const;
- /// \brief Get the detected GCC version string.
- const GCCVersion &getVersion() const { return Version; }
- /// \brief Print information about the detected GCC installation.
- void print(raw_ostream &OS) const;
- private:
- static void
- CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
- const llvm::Triple &BiarchTriple,
- SmallVectorImpl<StringRef> &LibDirs,
- SmallVectorImpl<StringRef> &TripleAliases,
- SmallVectorImpl<StringRef> &BiarchLibDirs,
- SmallVectorImpl<StringRef> &BiarchTripleAliases);
- void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
- const llvm::opt::ArgList &Args,
- const std::string &LibDir,
- StringRef CandidateTriple,
- bool NeedsBiarchSuffix = false);
- };
- protected:
- GCCInstallationDetector GCCInstallation;
- public:
- Generic_GCC(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- ~Generic_GCC() override;
- void printVerboseInfo(raw_ostream &OS) const override;
- bool IsUnwindTablesDefault() const override;
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- bool IsIntegratedAssemblerDefault() const override;
- protected:
- Tool *getTool(Action::ActionClass AC) const override;
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- /// \name ToolChain Implementation Helper Functions
- /// @{
- /// \brief Check whether the target triple's architecture is 64-bits.
- bool isTarget64Bit() const { return getTriple().isArch64Bit(); }
- /// \brief Check whether the target triple's architecture is 32-bits.
- bool isTarget32Bit() const { return getTriple().isArch32Bit(); }
- /// @}
- private:
- mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocess;
- mutable std::unique_ptr<tools::gcc::Compiler> Compile;
- };
- class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- Tool *getTool(Action::ActionClass AC) const override;
- private:
- mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
- mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
- mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
- public:
- MachO(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- ~MachO() override;
- /// @name MachO specific toolchain API
- /// {
- /// Get the "MachO" arch name for a particular compiler invocation. For
- /// example, Apple treats different ARM variations as distinct architectures.
- StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
- /// Add the linker arguments to link the ARC runtime library.
- virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const {}
- /// Add the linker arguments to link the compiler runtime library.
- virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const;
- virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const {
- }
- virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const {}
- /// On some iOS platforms, kernel and kernel modules were built statically. Is
- /// this such a target?
- virtual bool isKernelStatic() const { return false; }
- /// Is the target either iOS or an iOS simulator?
- bool isTargetIOSBased() const { return false; }
- void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs,
- StringRef DarwinLibName, bool AlwaysLink = false,
- bool IsEmbedded = false, bool AddRPath = false) const;
- /// Add any profiling runtime libraries that are needed. This is essentially a
- /// MachO specific version of addProfileRT in Tools.cpp.
- virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const {
- // There aren't any profiling libs for embedded targets currently.
- }
- /// }
- /// @name ToolChain Implementation
- /// {
- std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
- types::ID InputType) const override;
- types::ID LookupTypeForExtension(const char *Ext) const override;
- bool HasNativeLLVMSupport() const override;
- llvm::opt::DerivedArgList *
- TranslateArgs(const llvm::opt::DerivedArgList &Args,
- const char *BoundArch) const override;
- bool IsBlocksDefault() const override {
- // Always allow blocks on Apple; users interested in versioning are
- // expected to use /usr/include/Block.h.
- return true;
- }
- bool IsIntegratedAssemblerDefault() const override {
- // Default integrated assembler to on for Apple's MachO targets.
- return true;
- }
- bool IsMathErrnoDefault() const override { return false; }
- bool IsEncodeExtendedBlockSignatureDefault() const override { return true; }
- bool IsObjCNonFragileABIDefault() const override {
- // Non-fragile ABI is default for everything but i386.
- return getTriple().getArch() != llvm::Triple::x86;
- }
- bool UseObjCMixedDispatch() const override { return true; }
- bool IsUnwindTablesDefault() const override;
- RuntimeLibType GetDefaultRuntimeLibType() const override {
- return ToolChain::RLT_CompilerRT;
- }
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- bool SupportsProfiling() const override;
- bool SupportsObjCGC() const override { return false; }
- bool UseDwarfDebugFlags() const override;
- bool UseSjLjExceptions() const override { return false; }
- /// }
- };
- /// Darwin - The base Darwin tool chain.
- class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
- public:
- /// Whether the information on the target has been initialized.
- //
- // FIXME: This should be eliminated. What we want to do is make this part of
- // the "default target for arguments" selection process, once we get out of
- // the argument translation business.
- mutable bool TargetInitialized;
- enum DarwinPlatformKind { MacOS, IPhoneOS, IPhoneOSSimulator };
- mutable DarwinPlatformKind TargetPlatform;
- /// The OS version we are targeting.
- mutable VersionTuple TargetVersion;
- private:
- void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
- public:
- Darwin(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- ~Darwin() override;
- std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
- types::ID InputType) const override;
- /// @name Apple Specific Toolchain Implementation
- /// {
- void addMinVersionArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- bool isKernelStatic() const override {
- return !isTargetIPhoneOS() || isIPhoneOSVersionLT(6, 0);
- }
- void addProfileRTLibs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- protected:
- /// }
- /// @name Darwin specific Toolchain functions
- /// {
- // FIXME: Eliminate these ...Target functions and derive separate tool chains
- // for these targets and put version in constructor.
- 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 && TargetPlatform == Platform &&
- TargetVersion == VersionTuple(Major, Minor, Micro))
- return;
- assert(!TargetInitialized && "Target already initialized!");
- TargetInitialized = true;
- TargetPlatform = Platform;
- TargetVersion = VersionTuple(Major, Minor, Micro);
- }
- bool isTargetIPhoneOS() const {
- assert(TargetInitialized && "Target not initialized!");
- return TargetPlatform == IPhoneOS;
- }
- bool isTargetIOSSimulator() const {
- assert(TargetInitialized && "Target not initialized!");
- return TargetPlatform == IPhoneOSSimulator;
- }
- bool isTargetIOSBased() const {
- assert(TargetInitialized && "Target not initialized!");
- return isTargetIPhoneOS() || isTargetIOSSimulator();
- }
- bool isTargetMacOS() const {
- assert(TargetInitialized && "Target not initialized!");
- return TargetPlatform == MacOS;
- }
- bool isTargetInitialized() const { return TargetInitialized; }
- VersionTuple getTargetVersion() const {
- assert(TargetInitialized && "Target not initialized!");
- return TargetVersion;
- }
- bool isIPhoneOSVersionLT(unsigned V0, unsigned V1 = 0,
- unsigned V2 = 0) const {
- 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(isTargetMacOS() && "Unexpected call for non OS X target!");
- return TargetVersion < VersionTuple(V0, V1, V2);
- }
- public:
- /// }
- /// @name ToolChain Implementation
- /// {
- // Darwin tools support multiple architecture (e.g., i386 and x86_64) and
- // most development is done against SDKs, so compiling for a different
- // architecture should not get any special treatment.
- bool isCrossCompiling() const override { return false; }
- llvm::opt::DerivedArgList *
- TranslateArgs(const llvm::opt::DerivedArgList &Args,
- const char *BoundArch) const override;
- ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
- bool hasBlocksRuntime() const override;
- bool UseObjCMixedDispatch() const override {
- // 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 !(isTargetMacOS() && isMacosxVersionLT(10, 6));
- }
- unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
- // Stack protectors default to on for user code on 10.5,
- // and for everything in 10.6 and beyond
- if (isTargetIOSBased())
- return 1;
- else if (isTargetMacOS() && !isMacosxVersionLT(10, 6))
- return 1;
- else if (isTargetMacOS() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
- return 1;
- return 0;
- }
- bool SupportsObjCGC() const override;
- void CheckObjCARC() const override;
- bool UseSjLjExceptions() const override;
- SanitizerMask getSupportedSanitizers() const override;
- };
- /// DarwinClang - The Darwin toolchain used by Clang.
- class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
- public:
- DarwinClang(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- /// @name Apple ToolChain Implementation
- /// {
- void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
- void AddLinkARCArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- /// }
- private:
- void AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs,
- StringRef Sanitizer) const;
- };
- class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
- virtual void anchor();
- public:
- Generic_ELF(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args)
- : Generic_GCC(D, Triple, Args) {}
- void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- };
- class LLVM_LIBRARY_VISIBILITY CloudABI : public Generic_ELF {
- public:
- CloudABI(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool HasNativeLLVMSupport() const override { return true; }
- bool IsMathErrnoDefault() const override { return false; }
- bool IsObjCNonFragileABIDefault() const override { return true; }
- CXXStdlibType
- GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
- return ToolChain::CST_Libcxx;
- }
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- bool isPIEDefault() const override { return false; }
- protected:
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
- public:
- Solaris(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsIntegratedAssemblerDefault() const override { return true; }
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
- public:
- MinGW(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsIntegratedAssemblerDefault() const override;
- bool IsUnwindTablesDefault() const override;
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- bool UseSEHExceptions() const;
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- protected:
- Tool *getTool(Action::ActionClass AC) const override;
- Tool *buildLinker() const override;
- Tool *buildAssembler() const override;
- private:
- std::string Base;
- std::string GccLibDir;
- std::string Ver;
- std::string Arch;
- mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
- mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
- void findGccLibDir();
- };
- class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
- public:
- OpenBSD(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsMathErrnoDefault() const override { return false; }
- bool IsObjCNonFragileABIDefault() const override { return true; }
- bool isPIEDefault() const override { return true; }
- unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
- return 2;
- }
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF {
- public:
- Bitrig(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsMathErrnoDefault() const override { return false; }
- bool IsObjCNonFragileABIDefault() const override { return true; }
- CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
- return 1;
- }
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
- public:
- FreeBSD(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool HasNativeLLVMSupport() const override;
- bool IsMathErrnoDefault() const override { return false; }
- bool IsObjCNonFragileABIDefault() const override { return true; }
- CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- bool UseSjLjExceptions() const override;
- bool isPIEDefault() const override;
- SanitizerMask getSupportedSanitizers() const override;
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
- public:
- NetBSD(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsMathErrnoDefault() const override { return false; }
- bool IsObjCNonFragileABIDefault() const override { return true; }
- CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- bool IsUnwindTablesDefault() const override { return true; }
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
- public:
- Minix(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
- public:
- DragonFly(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsMathErrnoDefault() const override { return false; }
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- };
- class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
- public:
- Linux(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool HasNativeLLVMSupport() const override;
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- bool isPIEDefault() const override;
- SanitizerMask getSupportedSanitizers() const override;
- std::string Linker;
- std::vector<std::string> ExtraOpts;
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- private:
- static bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix,
- StringRef GCCTriple,
- StringRef GCCMultiarchTriple,
- StringRef TargetMultiarchTriple,
- Twine IncludeSuffix,
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args);
- std::string computeSysRoot() const;
- };
- class LLVM_LIBRARY_VISIBILITY CudaToolChain : public Linux {
- public:
- CudaToolChain(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- llvm::opt::DerivedArgList *
- TranslateArgs(const llvm::opt::DerivedArgList &Args,
- const char *BoundArch) const override;
- void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- };
- class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux {
- protected:
- GCCVersion GCCLibAndIncVersion;
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- public:
- Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- ~Hexagon_TC() override;
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
- StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
- static std::string GetGnuDir(const std::string &InstalledDir,
- const llvm::opt::ArgList &Args);
- static StringRef GetTargetCPU(const llvm::opt::ArgList &Args);
- static const char *GetSmallDataThreshold(const llvm::opt::ArgList &Args);
- static bool UsesG0(const char *smallDataThreshold);
- };
- class LLVM_LIBRARY_VISIBILITY NaCl_TC : public Generic_ELF {
- public:
- NaCl_TC(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
- void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- bool IsIntegratedAssemblerDefault() const override {
- return getTriple().getArch() == llvm::Triple::mipsel;
- }
- // Get the path to the file containing NaCl's ARM macros. It lives in NaCl_TC
- // because the AssembleARM tool needs a const char * that it can pass around
- // and the toolchain outlives all the jobs.
- const char *GetNaClArmMacrosPath() const { return NaClArmMacrosPath.c_str(); }
- std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
- types::ID InputType) const override;
- std::string Linker;
- protected:
- Tool *buildLinker() const override;
- Tool *buildAssembler() const override;
- private:
- std::string NaClArmMacrosPath;
- };
- /// TCEToolChain - A tool chain using the llvm bitcode tools to perform
- /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
- class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
- public:
- TCEToolChain(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- ~TCEToolChain() override;
- bool IsMathErrnoDefault() const override;
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- };
- class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
- public:
- MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- bool IsIntegratedAssemblerDefault() const override;
- bool IsUnwindTablesDefault() const override;
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- bool getWindowsSDKDir(std::string &path, int &major, int &minor) const;
- bool getWindowsSDKLibraryPath(std::string &path) const;
- bool getVisualStudioInstallDir(std::string &path) const;
- bool getVisualStudioBinariesFolder(const char *clangProgramPath,
- std::string &path) const;
- std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
- types::ID InputType) const override;
- SanitizerMask getSupportedSanitizers() const override;
- protected:
- void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args,
- const std::string &folder,
- const char *subfolder) const;
- Tool *buildLinker() const override;
- Tool *buildAssembler() const override;
- };
- class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC {
- public:
- CrossWindowsToolChain(const Driver &D, const llvm::Triple &T,
- const llvm::opt::ArgList &Args);
- bool IsIntegratedAssemblerDefault() const override { return true; }
- bool IsUnwindTablesDefault() const override;
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- unsigned int GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
- return 0;
- }
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- protected:
- Tool *buildLinker() const override;
- Tool *buildAssembler() const override;
- };
- class LLVM_LIBRARY_VISIBILITY XCore : public ToolChain {
- public:
- XCore(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- protected:
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- public:
- bool isPICDefault() const override;
- bool isPIEDefault() const override;
- bool isPICDefaultForced() const override;
- bool SupportsProfiling() const override;
- bool hasBlocksRuntime() const override;
- void
- AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddClangCXXStdlibIncludeArgs(
- const llvm::opt::ArgList &DriverArgs,
- llvm::opt::ArgStringList &CC1Args) const override;
- void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
- };
- /// SHAVEToolChain - A tool chain using the compiler installed by the the
- // Movidius SDK into MV_TOOLS_DIR (which we assume will be copied to llvm's
- // installation dir) to perform all subcommands.
- class LLVM_LIBRARY_VISIBILITY SHAVEToolChain : public Generic_GCC {
- public:
- SHAVEToolChain(const Driver &D, const llvm::Triple &Triple,
- const llvm::opt::ArgList &Args);
- ~SHAVEToolChain() override;
- virtual Tool *SelectTool(const JobAction &JA) const override;
- protected:
- Tool *getTool(Action::ActionClass AC) const override;
- Tool *buildAssembler() const override;
- Tool *buildLinker() const override;
- private:
- mutable std::unique_ptr<Tool> Compiler;
- mutable std::unique_ptr<Tool> Assembler;
- };
- } // end namespace toolchains
- } // end namespace driver
- } // end namespace clang
- #endif
|