Home | History | Annotate | Download | only in Driver
      1 //===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_
     11 #define CLANG_LIB_DRIVER_TOOLCHAINS_H_
     12 
     13 #include "Tools.h"
     14 #include "clang/Basic/VersionTuple.h"
     15 #include "clang/Driver/Action.h"
     16 #include "clang/Driver/Multilib.h"
     17 #include "clang/Driver/ToolChain.h"
     18 #include "llvm/ADT/DenseMap.h"
     19 #include "llvm/ADT/Optional.h"
     20 #include "llvm/Support/Compiler.h"
     21 #include <set>
     22 #include <vector>
     23 
     24 namespace clang {
     25 namespace driver {
     26 namespace toolchains {
     27 
     28 /// Generic_GCC - A tool chain using the 'gcc' command to perform
     29 /// all subcommands; this relies on gcc translating the majority of
     30 /// command line options.
     31 class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
     32 protected:
     33   /// \brief Struct to store and manipulate GCC versions.
     34   ///
     35   /// We rely on assumptions about the form and structure of GCC version
     36   /// numbers: they consist of at most three '.'-separated components, and each
     37   /// component is a non-negative integer except for the last component. For
     38   /// the last component we are very flexible in order to tolerate release
     39   /// candidates or 'x' wildcards.
     40   ///
     41   /// Note that the ordering established among GCCVersions is based on the
     42   /// preferred version string to use. For example we prefer versions without
     43   /// a hard-coded patch number to those with a hard coded patch number.
     44   ///
     45   /// Currently this doesn't provide any logic for textual suffixes to patches
     46   /// in the way that (for example) Debian's version format does. If that ever
     47   /// becomes necessary, it can be added.
     48   struct GCCVersion {
     49     /// \brief The unparsed text of the version.
     50     std::string Text;
     51 
     52     /// \brief The parsed major, minor, and patch numbers.
     53     int Major, Minor, Patch;
     54 
     55     /// \brief The text of the parsed major, and major+minor versions.
     56     std::string MajorStr, MinorStr;
     57 
     58     /// \brief Any textual suffix on the patch number.
     59     std::string PatchSuffix;
     60 
     61     static GCCVersion Parse(StringRef VersionText);
     62     bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch,
     63                      StringRef RHSPatchSuffix = StringRef()) const;
     64     bool operator<(const GCCVersion &RHS) const {
     65       return isOlderThan(RHS.Major, RHS.Minor, RHS.Patch, RHS.PatchSuffix);
     66     }
     67     bool operator>(const GCCVersion &RHS) const { return RHS < *this; }
     68     bool operator<=(const GCCVersion &RHS) const { return !(*this > RHS); }
     69     bool operator>=(const GCCVersion &RHS) const { return !(*this < RHS); }
     70   };
     71 
     72   /// \brief This is a class to find a viable GCC installation for Clang to
     73   /// use.
     74   ///
     75   /// This class tries to find a GCC installation on the system, and report
     76   /// information about it. It starts from the host information provided to the
     77   /// Driver, and has logic for fuzzing that where appropriate.
     78   class GCCInstallationDetector {
     79     bool IsValid;
     80     llvm::Triple GCCTriple;
     81 
     82     // FIXME: These might be better as path objects.
     83     std::string GCCInstallPath;
     84     std::string GCCParentLibPath;
     85 
     86     /// The primary multilib appropriate for the given flags.
     87     Multilib SelectedMultilib;
     88     /// On Biarch systems, this corresponds to the default multilib when
     89     /// targeting the non-default multilib. Otherwise, it is empty.
     90     llvm::Optional<Multilib> BiarchSibling;
     91 
     92     GCCVersion Version;
     93 
     94     // We retain the list of install paths that were considered and rejected in
     95     // order to print out detailed information in verbose mode.
     96     std::set<std::string> CandidateGCCInstallPaths;
     97 
     98     /// The set of multilibs that the detected installation supports.
     99     MultilibSet Multilibs;
    100 
    101   public:
    102     GCCInstallationDetector() : IsValid(false) {}
    103     void init(const Driver &D, const llvm::Triple &TargetTriple,
    104                             const llvm::opt::ArgList &Args);
    105 
    106     /// \brief Check whether we detected a valid GCC install.
    107     bool isValid() const { return IsValid; }
    108 
    109     /// \brief Get the GCC triple for the detected install.
    110     const llvm::Triple &getTriple() const { return GCCTriple; }
    111 
    112     /// \brief Get the detected GCC installation path.
    113     StringRef getInstallPath() const { return GCCInstallPath; }
    114 
    115     /// \brief Get the detected GCC parent lib path.
    116     StringRef getParentLibPath() const { return GCCParentLibPath; }
    117 
    118     /// \brief Get the detected Multilib
    119     const Multilib &getMultilib() const { return SelectedMultilib; }
    120 
    121     /// \brief Get the whole MultilibSet
    122     const MultilibSet &getMultilibs() const { return Multilibs; }
    123 
    124     /// Get the biarch sibling multilib (if it exists).
    125     /// \return true iff such a sibling exists
    126     bool getBiarchSibling(Multilib &M) const;
    127 
    128     /// \brief Get the detected GCC version string.
    129     const GCCVersion &getVersion() const { return Version; }
    130 
    131     /// \brief Print information about the detected GCC installation.
    132     void print(raw_ostream &OS) const;
    133 
    134   private:
    135     static void
    136     CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
    137                              const llvm::Triple &BiarchTriple,
    138                              SmallVectorImpl<StringRef> &LibDirs,
    139                              SmallVectorImpl<StringRef> &TripleAliases,
    140                              SmallVectorImpl<StringRef> &BiarchLibDirs,
    141                              SmallVectorImpl<StringRef> &BiarchTripleAliases);
    142 
    143     void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
    144                                 const llvm::opt::ArgList &Args,
    145                                 const std::string &LibDir,
    146                                 StringRef CandidateTriple,
    147                                 bool NeedsBiarchSuffix = false);
    148   };
    149 
    150   GCCInstallationDetector GCCInstallation;
    151 
    152 public:
    153   Generic_GCC(const Driver &D, const llvm::Triple &Triple,
    154               const llvm::opt::ArgList &Args);
    155   ~Generic_GCC();
    156 
    157   void printVerboseInfo(raw_ostream &OS) const override;
    158 
    159   bool IsUnwindTablesDefault() const override;
    160   bool isPICDefault() const override;
    161   bool isPIEDefault() const override;
    162   bool isPICDefaultForced() const override;
    163   bool IsIntegratedAssemblerDefault() const override;
    164 
    165 protected:
    166   Tool *getTool(Action::ActionClass AC) const override;
    167   Tool *buildAssembler() const override;
    168   Tool *buildLinker() const override;
    169 
    170   /// \name ToolChain Implementation Helper Functions
    171   /// @{
    172 
    173   /// \brief Check whether the target triple's architecture is 64-bits.
    174   bool isTarget64Bit() const { return getTriple().isArch64Bit(); }
    175 
    176   /// \brief Check whether the target triple's architecture is 32-bits.
    177   bool isTarget32Bit() const { return getTriple().isArch32Bit(); }
    178 
    179   /// @}
    180 
    181 private:
    182   mutable std::unique_ptr<tools::gcc::Preprocess> Preprocess;
    183   mutable std::unique_ptr<tools::gcc::Compile> Compile;
    184 };
    185 
    186 class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
    187 protected:
    188   Tool *buildAssembler() const override;
    189   Tool *buildLinker() const override;
    190   Tool *getTool(Action::ActionClass AC) const override;
    191 private:
    192   mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
    193   mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
    194   mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
    195 
    196 public:
    197   MachO(const Driver &D, const llvm::Triple &Triple,
    198              const llvm::opt::ArgList &Args);
    199   ~MachO();
    200 
    201   /// @name MachO specific toolchain API
    202   /// {
    203 
    204   /// Get the "MachO" arch name for a particular compiler invocation. For
    205   /// example, Apple treats different ARM variations as distinct architectures.
    206   StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
    207 
    208 
    209   /// Add the linker arguments to link the ARC runtime library.
    210   virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
    211                               llvm::opt::ArgStringList &CmdArgs) const {}
    212 
    213   /// Add the linker arguments to link the compiler runtime library.
    214   virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
    215                                      llvm::opt::ArgStringList &CmdArgs) const;
    216 
    217   virtual void
    218   addStartObjectFileArgs(const llvm::opt::ArgList &Args,
    219                          llvm::opt::ArgStringList &CmdArgs) const {}
    220 
    221   virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
    222                                  llvm::opt::ArgStringList &CmdArgs) const {}
    223 
    224   /// On some iOS platforms, kernel and kernel modules were built statically. Is
    225   /// this such a target?
    226   virtual bool isKernelStatic() const {
    227     return false;
    228   }
    229 
    230   /// Is the target either iOS or an iOS simulator?
    231   bool isTargetIOSBased() const {
    232     return false;
    233   }
    234 
    235   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
    236                          llvm::opt::ArgStringList &CmdArgs,
    237                          StringRef DarwinStaticLib,
    238                          bool AlwaysLink = false,
    239                          bool IsEmbedded = false) const;
    240 
    241   /// }
    242   /// @name ToolChain Implementation
    243   /// {
    244 
    245   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
    246                                           types::ID InputType) const override;
    247 
    248   types::ID LookupTypeForExtension(const char *Ext) const override;
    249 
    250   bool HasNativeLLVMSupport() const override;
    251 
    252   llvm::opt::DerivedArgList *
    253   TranslateArgs(const llvm::opt::DerivedArgList &Args,
    254                 const char *BoundArch) const override;
    255 
    256   bool IsBlocksDefault() const override {
    257     // Always allow blocks on Apple; users interested in versioning are
    258     // expected to use /usr/include/Blocks.h.
    259     return true;
    260   }
    261   bool IsIntegratedAssemblerDefault() const override {
    262     // Default integrated assembler to on for Apple's MachO targets.
    263     return true;
    264   }
    265 
    266   bool IsMathErrnoDefault() const override {
    267     return false;
    268   }
    269 
    270   bool IsEncodeExtendedBlockSignatureDefault() const override {
    271     return true;
    272   }
    273 
    274   bool IsObjCNonFragileABIDefault() const override {
    275     // Non-fragile ABI is default for everything but i386.
    276     return getTriple().getArch() != llvm::Triple::x86;
    277   }
    278 
    279   bool UseObjCMixedDispatch() const override {
    280     return true;
    281   }
    282 
    283   bool IsUnwindTablesDefault() const override;
    284 
    285   RuntimeLibType GetDefaultRuntimeLibType() const override {
    286     return ToolChain::RLT_CompilerRT;
    287   }
    288 
    289   bool isPICDefault() const override;
    290   bool isPIEDefault() const override;
    291   bool isPICDefaultForced() const override;
    292 
    293   bool SupportsProfiling() const override;
    294 
    295   bool SupportsObjCGC() const override {
    296     return false;
    297   }
    298 
    299   bool UseDwarfDebugFlags() const override;
    300 
    301   bool UseSjLjExceptions() const override {
    302     return false;
    303   }
    304 
    305   /// }
    306 };
    307 
    308   /// Darwin - The base Darwin tool chain.
    309 class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
    310 public:
    311   /// The host version.
    312   unsigned DarwinVersion[3];
    313 
    314   /// Whether the information on the target has been initialized.
    315   //
    316   // FIXME: This should be eliminated. What we want to do is make this part of
    317   // the "default target for arguments" selection process, once we get out of
    318   // the argument translation business.
    319   mutable bool TargetInitialized;
    320 
    321   enum DarwinPlatformKind {
    322     MacOS,
    323     IPhoneOS,
    324     IPhoneOSSimulator
    325   };
    326 
    327   mutable DarwinPlatformKind TargetPlatform;
    328 
    329   /// The OS version we are targeting.
    330   mutable VersionTuple TargetVersion;
    331 
    332 private:
    333   /// The default macosx-version-min of this tool chain; empty until
    334   /// initialized.
    335   std::string MacosxVersionMin;
    336 
    337   /// The default ios-version-min of this tool chain; empty until
    338   /// initialized.
    339   std::string iOSVersionMin;
    340 
    341 private:
    342   void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
    343 
    344 public:
    345   Darwin(const Driver &D, const llvm::Triple &Triple,
    346          const llvm::opt::ArgList &Args);
    347   ~Darwin();
    348 
    349   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
    350                                           types::ID InputType) const override;
    351 
    352   /// @name Apple Specific Toolchain Implementation
    353   /// {
    354 
    355   void
    356   addMinVersionArgs(const llvm::opt::ArgList &Args,
    357                     llvm::opt::ArgStringList &CmdArgs) const override;
    358 
    359   void
    360   addStartObjectFileArgs(const llvm::opt::ArgList &Args,
    361                          llvm::opt::ArgStringList &CmdArgs) const override;
    362 
    363   bool isKernelStatic() const override {
    364     return !isTargetIPhoneOS() || isIPhoneOSVersionLT(6, 0) ||
    365            getTriple().getArch() == llvm::Triple::arm64;
    366   }
    367 
    368 protected:
    369   /// }
    370   /// @name Darwin specific Toolchain functions
    371   /// {
    372 
    373   // FIXME: Eliminate these ...Target functions and derive separate tool chains
    374   // for these targets and put version in constructor.
    375   void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor,
    376                  unsigned Micro) const {
    377     // FIXME: For now, allow reinitialization as long as values don't
    378     // change. This will go away when we move away from argument translation.
    379     if (TargetInitialized && TargetPlatform == Platform &&
    380         TargetVersion == VersionTuple(Major, Minor, Micro))
    381       return;
    382 
    383     assert(!TargetInitialized && "Target already initialized!");
    384     TargetInitialized = true;
    385     TargetPlatform = Platform;
    386     TargetVersion = VersionTuple(Major, Minor, Micro);
    387   }
    388 
    389   bool isTargetIPhoneOS() const {
    390     assert(TargetInitialized && "Target not initialized!");
    391     return TargetPlatform == IPhoneOS;
    392   }
    393 
    394   bool isTargetIOSSimulator() const {
    395     assert(TargetInitialized && "Target not initialized!");
    396     return TargetPlatform == IPhoneOSSimulator;
    397   }
    398 
    399   bool isTargetIOSBased() const {
    400     assert(TargetInitialized && "Target not initialized!");
    401     return isTargetIPhoneOS() || isTargetIOSSimulator();
    402   }
    403 
    404   bool isTargetMacOS() const {
    405     return TargetPlatform == MacOS;
    406   }
    407 
    408   bool isTargetInitialized() const { return TargetInitialized; }
    409 
    410   VersionTuple getTargetVersion() const {
    411     assert(TargetInitialized && "Target not initialized!");
    412     return TargetVersion;
    413   }
    414 
    415   bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
    416     assert(isTargetIOSBased() && "Unexpected call for non iOS target!");
    417     return TargetVersion < VersionTuple(V0, V1, V2);
    418   }
    419 
    420   bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const {
    421     assert(isTargetMacOS() && "Unexpected call for non OS X target!");
    422     return TargetVersion < VersionTuple(V0, V1, V2);
    423   }
    424 
    425 public:
    426   /// }
    427   /// @name ToolChain Implementation
    428   /// {
    429 
    430   llvm::opt::DerivedArgList *
    431   TranslateArgs(const llvm::opt::DerivedArgList &Args,
    432                 const char *BoundArch) const override;
    433 
    434   ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
    435   bool hasBlocksRuntime() const override;
    436 
    437   bool UseObjCMixedDispatch() const override {
    438     // This is only used with the non-fragile ABI and non-legacy dispatch.
    439 
    440     // Mixed dispatch is used everywhere except OS X before 10.6.
    441     return !(isTargetMacOS() && isMacosxVersionLT(10, 6));
    442   }
    443 
    444   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
    445     // Stack protectors default to on for user code on 10.5,
    446     // and for everything in 10.6 and beyond
    447     if (isTargetIOSBased())
    448       return 1;
    449     else if (isTargetMacOS() && !isMacosxVersionLT(10, 6))
    450       return 1;
    451     else if (isTargetMacOS() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
    452       return 1;
    453 
    454     return 0;
    455   }
    456 
    457   bool SupportsObjCGC() const override;
    458 
    459   void CheckObjCARC() const override;
    460 
    461   bool UseSjLjExceptions() const override;
    462 };
    463 
    464 /// DarwinClang - The Darwin toolchain used by Clang.
    465 class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
    466 public:
    467   DarwinClang(const Driver &D, const llvm::Triple &Triple,
    468               const llvm::opt::ArgList &Args);
    469 
    470   /// @name Apple ToolChain Implementation
    471   /// {
    472 
    473   void
    474   AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
    475                         llvm::opt::ArgStringList &CmdArgs) const override;
    476 
    477   void
    478   AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    479                       llvm::opt::ArgStringList &CmdArgs) const override;
    480 
    481   void
    482   AddCCKextLibArgs(const llvm::opt::ArgList &Args,
    483                    llvm::opt::ArgStringList &CmdArgs) const override;
    484 
    485   virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
    486 
    487   void
    488   AddLinkARCArgs(const llvm::opt::ArgList &Args,
    489                  llvm::opt::ArgStringList &CmdArgs) const override;
    490   /// }
    491 };
    492 
    493 class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
    494   virtual void anchor();
    495 public:
    496   Generic_ELF(const Driver &D, const llvm::Triple &Triple,
    497               const llvm::opt::ArgList &Args)
    498       : Generic_GCC(D, Triple, Args) {}
    499 
    500   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
    501                              llvm::opt::ArgStringList &CC1Args) const override;
    502 };
    503 
    504 class LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC {
    505 public:
    506   AuroraUX(const Driver &D, const llvm::Triple &Triple,
    507            const llvm::opt::ArgList &Args);
    508 
    509 protected:
    510   Tool *buildAssembler() const override;
    511   Tool *buildLinker() const override;
    512 };
    513 
    514 class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
    515 public:
    516   Solaris(const Driver &D, const llvm::Triple &Triple,
    517           const llvm::opt::ArgList &Args);
    518 
    519   bool IsIntegratedAssemblerDefault() const override { return true; }
    520 protected:
    521   Tool *buildAssembler() const override;
    522   Tool *buildLinker() const override;
    523 
    524 };
    525 
    526 
    527 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
    528 public:
    529   OpenBSD(const Driver &D, const llvm::Triple &Triple,
    530           const llvm::opt::ArgList &Args);
    531 
    532   bool IsMathErrnoDefault() const override { return false; }
    533   bool IsObjCNonFragileABIDefault() const override { return true; }
    534   bool isPIEDefault() const override { return true; }
    535 
    536   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
    537     return 2;
    538   }
    539 
    540   virtual bool IsIntegratedAssemblerDefault() const {
    541     if (getTriple().getArch() == llvm::Triple::ppc)
    542       return true;
    543     return Generic_ELF::IsIntegratedAssemblerDefault();
    544   }
    545 
    546 protected:
    547   Tool *buildAssembler() const override;
    548   Tool *buildLinker() const override;
    549 };
    550 
    551 class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF {
    552 public:
    553   Bitrig(const Driver &D, const llvm::Triple &Triple,
    554          const llvm::opt::ArgList &Args);
    555 
    556   bool IsMathErrnoDefault() const override { return false; }
    557   bool IsObjCNonFragileABIDefault() const override { return true; }
    558 
    559   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    560   void
    561   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    562                               llvm::opt::ArgStringList &CC1Args) const override;
    563   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    564                            llvm::opt::ArgStringList &CmdArgs) const override;
    565   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
    566      return 1;
    567   }
    568 
    569 protected:
    570   Tool *buildAssembler() const override;
    571   Tool *buildLinker() const override;
    572 };
    573 
    574 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
    575 public:
    576   FreeBSD(const Driver &D, const llvm::Triple &Triple,
    577           const llvm::opt::ArgList &Args);
    578   bool HasNativeLLVMSupport() const override;
    579 
    580   bool IsMathErrnoDefault() const override { return false; }
    581   bool IsObjCNonFragileABIDefault() const override { return true; }
    582 
    583   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    584   void
    585   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    586                                llvm::opt::ArgStringList &CC1Args) const override;
    587   bool IsIntegratedAssemblerDefault() const override {
    588     if (getTriple().getArch() == llvm::Triple::ppc ||
    589         getTriple().getArch() == llvm::Triple::ppc64)
    590       return true;
    591     return Generic_ELF::IsIntegratedAssemblerDefault();
    592   }
    593 
    594   bool UseSjLjExceptions() const override;
    595   bool isPIEDefault() const override;
    596 protected:
    597   Tool *buildAssembler() const override;
    598   Tool *buildLinker() const override;
    599 };
    600 
    601 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
    602 public:
    603   NetBSD(const Driver &D, const llvm::Triple &Triple,
    604          const llvm::opt::ArgList &Args);
    605 
    606   bool IsMathErrnoDefault() const override { return false; }
    607   bool IsObjCNonFragileABIDefault() const override { return true; }
    608 
    609   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    610 
    611   void
    612   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    613                               llvm::opt::ArgStringList &CC1Args) const override;
    614   bool IsUnwindTablesDefault() const override {
    615     return true;
    616   }
    617   bool IsIntegratedAssemblerDefault() const override {
    618     if (getTriple().getArch() == llvm::Triple::ppc)
    619       return true;
    620     return Generic_ELF::IsIntegratedAssemblerDefault();
    621   }
    622 
    623 protected:
    624   Tool *buildAssembler() const override;
    625   Tool *buildLinker() const override;
    626 };
    627 
    628 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
    629 public:
    630   Minix(const Driver &D, const llvm::Triple &Triple,
    631         const llvm::opt::ArgList &Args);
    632 
    633 protected:
    634   Tool *buildAssembler() const override;
    635   Tool *buildLinker() const override;
    636 };
    637 
    638 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
    639 public:
    640   DragonFly(const Driver &D, const llvm::Triple &Triple,
    641             const llvm::opt::ArgList &Args);
    642 
    643   bool IsMathErrnoDefault() const override { return false; }
    644 
    645 protected:
    646   Tool *buildAssembler() const override;
    647   Tool *buildLinker() const override;
    648 };
    649 
    650 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
    651 public:
    652   Linux(const Driver &D, const llvm::Triple &Triple,
    653         const llvm::opt::ArgList &Args);
    654 
    655   bool HasNativeLLVMSupport() const override;
    656 
    657   void
    658   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    659                             llvm::opt::ArgStringList &CC1Args) const override;
    660   void
    661   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    662                                llvm::opt::ArgStringList &CC1Args) const override;
    663   bool isPIEDefault() const override;
    664 
    665   std::string Linker;
    666   std::vector<std::string> ExtraOpts;
    667 
    668 protected:
    669   Tool *buildAssembler() const override;
    670   Tool *buildLinker() const override;
    671 
    672 private:
    673   static bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix,
    674                                        Twine TargetArchDir, Twine IncludeSuffix,
    675                                        const llvm::opt::ArgList &DriverArgs,
    676                                        llvm::opt::ArgStringList &CC1Args);
    677   static bool addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
    678                                        const llvm::opt::ArgList &DriverArgs,
    679                                        llvm::opt::ArgStringList &CC1Args);
    680 
    681   std::string computeSysRoot() const;
    682 };
    683 
    684 class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux {
    685 protected:
    686   GCCVersion GCCLibAndIncVersion;
    687   Tool *buildAssembler() const override;
    688   Tool *buildLinker() const override;
    689 
    690 public:
    691   Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
    692              const llvm::opt::ArgList &Args);
    693   ~Hexagon_TC();
    694 
    695   void
    696   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    697                             llvm::opt::ArgStringList &CC1Args) const override;
    698   void
    699   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    700                               llvm::opt::ArgStringList &CC1Args) const override;
    701   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    702 
    703   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
    704 
    705   static std::string GetGnuDir(const std::string &InstalledDir);
    706 
    707   static StringRef GetTargetCPU(const llvm::opt::ArgList &Args);
    708 };
    709 
    710 /// TCEToolChain - A tool chain using the llvm bitcode tools to perform
    711 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
    712 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
    713 public:
    714   TCEToolChain(const Driver &D, const llvm::Triple &Triple,
    715                const llvm::opt::ArgList &Args);
    716   ~TCEToolChain();
    717 
    718   bool IsMathErrnoDefault() const override;
    719   bool isPICDefault() const override;
    720   bool isPIEDefault() const override;
    721   bool isPICDefaultForced() const override;
    722 };
    723 
    724 class LLVM_LIBRARY_VISIBILITY Windows : public ToolChain {
    725 public:
    726   Windows(const Driver &D, const llvm::Triple &Triple,
    727           const llvm::opt::ArgList &Args);
    728 
    729   bool IsIntegratedAssemblerDefault() const override;
    730   bool IsUnwindTablesDefault() const override;
    731   bool isPICDefault() const override;
    732   bool isPIEDefault() const override;
    733   bool isPICDefaultForced() const override;
    734 
    735   void
    736   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    737                             llvm::opt::ArgStringList &CC1Args) const override;
    738   void
    739   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    740                                llvm::opt::ArgStringList &CC1Args) const override;
    741 
    742 protected:
    743   Tool *buildLinker() const override;
    744   Tool *buildAssembler() const override;
    745 };
    746 
    747 
    748 class LLVM_LIBRARY_VISIBILITY XCore : public ToolChain {
    749 public:
    750   XCore(const Driver &D, const llvm::Triple &Triple,
    751           const llvm::opt::ArgList &Args);
    752 protected:
    753   Tool *buildAssembler() const override;
    754   Tool *buildLinker() const override;
    755 public:
    756   bool isPICDefault() const override;
    757   bool isPIEDefault() const override;
    758   bool isPICDefaultForced() const override;
    759   bool SupportsProfiling() const override;
    760   bool hasBlocksRuntime() const override;
    761   void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    762                     llvm::opt::ArgStringList &CC1Args) const override;
    763   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
    764                              llvm::opt::ArgStringList &CC1Args) const override;
    765   void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    766                        llvm::opt::ArgStringList &CC1Args) const override;
    767   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    768                            llvm::opt::ArgStringList &CmdArgs) const override;
    769 };
    770 
    771 } // end namespace toolchains
    772 } // end namespace driver
    773 } // end namespace clang
    774 
    775 #endif
    776