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 LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
     11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
     12 
     13 #include "Tools.h"
     14 #include "clang/Basic/Cuda.h"
     15 #include "clang/Basic/VersionTuple.h"
     16 #include "clang/Driver/Action.h"
     17 #include "clang/Driver/Multilib.h"
     18 #include "clang/Driver/ToolChain.h"
     19 #include "llvm/ADT/DenseMap.h"
     20 #include "llvm/ADT/Optional.h"
     21 #include "llvm/ADT/SmallSet.h"
     22 #include "llvm/Support/Compiler.h"
     23 #include <set>
     24 #include <vector>
     25 
     26 namespace clang {
     27 namespace driver {
     28 namespace toolchains {
     29 
     30 /// Generic_GCC - A tool chain using the 'gcc' command to perform
     31 /// all subcommands; this relies on gcc translating the majority of
     32 /// command line options.
     33 class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
     34 public:
     35   /// \brief Struct to store and manipulate GCC versions.
     36   ///
     37   /// We rely on assumptions about the form and structure of GCC version
     38   /// numbers: they consist of at most three '.'-separated components, and each
     39   /// component is a non-negative integer except for the last component. For
     40   /// the last component we are very flexible in order to tolerate release
     41   /// candidates or 'x' wildcards.
     42   ///
     43   /// Note that the ordering established among GCCVersions is based on the
     44   /// preferred version string to use. For example we prefer versions without
     45   /// a hard-coded patch number to those with a hard coded patch number.
     46   ///
     47   /// Currently this doesn't provide any logic for textual suffixes to patches
     48   /// in the way that (for example) Debian's version format does. If that ever
     49   /// becomes necessary, it can be added.
     50   struct GCCVersion {
     51     /// \brief The unparsed text of the version.
     52     std::string Text;
     53 
     54     /// \brief The parsed major, minor, and patch numbers.
     55     int Major, Minor, Patch;
     56 
     57     /// \brief The text of the parsed major, and major+minor versions.
     58     std::string MajorStr, MinorStr;
     59 
     60     /// \brief Any textual suffix on the patch number.
     61     std::string PatchSuffix;
     62 
     63     static GCCVersion Parse(StringRef VersionText);
     64     bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch,
     65                      StringRef RHSPatchSuffix = StringRef()) const;
     66     bool operator<(const GCCVersion &RHS) const {
     67       return isOlderThan(RHS.Major, RHS.Minor, RHS.Patch, RHS.PatchSuffix);
     68     }
     69     bool operator>(const GCCVersion &RHS) const { return RHS < *this; }
     70     bool operator<=(const GCCVersion &RHS) const { return !(*this > RHS); }
     71     bool operator>=(const GCCVersion &RHS) const { return !(*this < RHS); }
     72   };
     73 
     74   /// \brief This is a class to find a viable GCC installation for Clang to
     75   /// use.
     76   ///
     77   /// This class tries to find a GCC installation on the system, and report
     78   /// information about it. It starts from the host information provided to the
     79   /// Driver, and has logic for fuzzing that where appropriate.
     80   class GCCInstallationDetector {
     81     bool IsValid;
     82     llvm::Triple GCCTriple;
     83     const Driver &D;
     84 
     85     // FIXME: These might be better as path objects.
     86     std::string GCCInstallPath;
     87     std::string GCCParentLibPath;
     88 
     89     /// The primary multilib appropriate for the given flags.
     90     Multilib SelectedMultilib;
     91     /// On Biarch systems, this corresponds to the default multilib when
     92     /// targeting the non-default multilib. Otherwise, it is empty.
     93     llvm::Optional<Multilib> BiarchSibling;
     94 
     95     GCCVersion Version;
     96 
     97     // We retain the list of install paths that were considered and rejected in
     98     // order to print out detailed information in verbose mode.
     99     std::set<std::string> CandidateGCCInstallPaths;
    100 
    101     /// The set of multilibs that the detected installation supports.
    102     MultilibSet Multilibs;
    103 
    104   public:
    105     explicit GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {}
    106     void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args,
    107               ArrayRef<std::string> ExtraTripleAliases = None);
    108 
    109     /// \brief Check whether we detected a valid GCC install.
    110     bool isValid() const { return IsValid; }
    111 
    112     /// \brief Get the GCC triple for the detected install.
    113     const llvm::Triple &getTriple() const { return GCCTriple; }
    114 
    115     /// \brief Get the detected GCC installation path.
    116     StringRef getInstallPath() const { return GCCInstallPath; }
    117 
    118     /// \brief Get the detected GCC parent lib path.
    119     StringRef getParentLibPath() const { return GCCParentLibPath; }
    120 
    121     /// \brief Get the detected Multilib
    122     const Multilib &getMultilib() const { return SelectedMultilib; }
    123 
    124     /// \brief Get the whole MultilibSet
    125     const MultilibSet &getMultilibs() const { return Multilibs; }
    126 
    127     /// Get the biarch sibling multilib (if it exists).
    128     /// \return true iff such a sibling exists
    129     bool getBiarchSibling(Multilib &M) const;
    130 
    131     /// \brief Get the detected GCC version string.
    132     const GCCVersion &getVersion() const { return Version; }
    133 
    134     /// \brief Print information about the detected GCC installation.
    135     void print(raw_ostream &OS) const;
    136 
    137   private:
    138     static void
    139     CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
    140                              const llvm::Triple &BiarchTriple,
    141                              SmallVectorImpl<StringRef> &LibDirs,
    142                              SmallVectorImpl<StringRef> &TripleAliases,
    143                              SmallVectorImpl<StringRef> &BiarchLibDirs,
    144                              SmallVectorImpl<StringRef> &BiarchTripleAliases);
    145 
    146     void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
    147                                 const llvm::opt::ArgList &Args,
    148                                 const std::string &LibDir,
    149                                 StringRef CandidateTriple,
    150                                 bool NeedsBiarchSuffix = false);
    151 
    152     void scanLibDirForGCCTripleSolaris(const llvm::Triple &TargetArch,
    153                                        const llvm::opt::ArgList &Args,
    154                                        const std::string &LibDir,
    155                                        StringRef CandidateTriple,
    156                                        bool NeedsBiarchSuffix = false);
    157   };
    158 
    159 protected:
    160   GCCInstallationDetector GCCInstallation;
    161 
    162   // \brief A class to find a viable CUDA installation
    163   class CudaInstallationDetector {
    164   private:
    165     const Driver &D;
    166     bool IsValid = false;
    167     CudaVersion Version = CudaVersion::UNKNOWN;
    168     std::string InstallPath;
    169     std::string BinPath;
    170     std::string LibPath;
    171     std::string LibDevicePath;
    172     std::string IncludePath;
    173     llvm::StringMap<std::string> LibDeviceMap;
    174 
    175     // CUDA architectures for which we have raised an error in
    176     // CheckCudaVersionSupportsArch.
    177     mutable llvm::SmallSet<CudaArch, 4> ArchsWithVersionTooLowErrors;
    178 
    179   public:
    180     CudaInstallationDetector(const Driver &D) : D(D) {}
    181     void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args);
    182 
    183     /// \brief Emit an error if Version does not support the given Arch.
    184     ///
    185     /// If either Version or Arch is unknown, does not emit an error.  Emits at
    186     /// most one error per Arch.
    187     void CheckCudaVersionSupportsArch(CudaArch Arch) const;
    188 
    189     /// \brief Check whether we detected a valid Cuda install.
    190     bool isValid() const { return IsValid; }
    191     /// \brief Print information about the detected CUDA installation.
    192     void print(raw_ostream &OS) const;
    193 
    194     /// \brief Get the deteced Cuda install's version.
    195     CudaVersion version() const { return Version; }
    196     /// \brief Get the detected Cuda installation path.
    197     StringRef getInstallPath() const { return InstallPath; }
    198     /// \brief Get the detected path to Cuda's bin directory.
    199     StringRef getBinPath() const { return BinPath; }
    200     /// \brief Get the detected Cuda Include path.
    201     StringRef getIncludePath() const { return IncludePath; }
    202     /// \brief Get the detected Cuda library path.
    203     StringRef getLibPath() const { return LibPath; }
    204     /// \brief Get the detected Cuda device library path.
    205     StringRef getLibDevicePath() const { return LibDevicePath; }
    206     /// \brief Get libdevice file for given architecture
    207     std::string getLibDeviceFile(StringRef Gpu) const {
    208       return LibDeviceMap.lookup(Gpu);
    209     }
    210   };
    211 
    212   CudaInstallationDetector CudaInstallation;
    213 
    214 public:
    215   Generic_GCC(const Driver &D, const llvm::Triple &Triple,
    216               const llvm::opt::ArgList &Args);
    217   ~Generic_GCC() override;
    218 
    219   void printVerboseInfo(raw_ostream &OS) const override;
    220 
    221   bool IsUnwindTablesDefault() const override;
    222   bool isPICDefault() const override;
    223   bool isPIEDefault() const override;
    224   bool isPICDefaultForced() const override;
    225   bool IsIntegratedAssemblerDefault() const override;
    226 
    227 protected:
    228   Tool *getTool(Action::ActionClass AC) const override;
    229   Tool *buildAssembler() const override;
    230   Tool *buildLinker() const override;
    231 
    232   /// \name ToolChain Implementation Helper Functions
    233   /// @{
    234 
    235   /// \brief Check whether the target triple's architecture is 64-bits.
    236   bool isTarget64Bit() const { return getTriple().isArch64Bit(); }
    237 
    238   /// \brief Check whether the target triple's architecture is 32-bits.
    239   bool isTarget32Bit() const { return getTriple().isArch32Bit(); }
    240 
    241   bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix, StringRef GCCTriple,
    242                                 StringRef GCCMultiarchTriple,
    243                                 StringRef TargetMultiarchTriple,
    244                                 Twine IncludeSuffix,
    245                                 const llvm::opt::ArgList &DriverArgs,
    246                                 llvm::opt::ArgStringList &CC1Args) const;
    247 
    248   /// @}
    249 
    250 private:
    251   mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocess;
    252   mutable std::unique_ptr<tools::gcc::Compiler> Compile;
    253 };
    254 
    255 class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
    256 protected:
    257   Tool *buildAssembler() const override;
    258   Tool *buildLinker() const override;
    259   Tool *getTool(Action::ActionClass AC) const override;
    260 
    261 private:
    262   mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
    263   mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
    264   mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
    265 
    266 public:
    267   MachO(const Driver &D, const llvm::Triple &Triple,
    268         const llvm::opt::ArgList &Args);
    269   ~MachO() override;
    270 
    271   /// @name MachO specific toolchain API
    272   /// {
    273 
    274   /// Get the "MachO" arch name for a particular compiler invocation. For
    275   /// example, Apple treats different ARM variations as distinct architectures.
    276   StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
    277 
    278   /// Add the linker arguments to link the ARC runtime library.
    279   virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
    280                               llvm::opt::ArgStringList &CmdArgs) const {}
    281 
    282   /// Add the linker arguments to link the compiler runtime library.
    283   virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
    284                                      llvm::opt::ArgStringList &CmdArgs) const;
    285 
    286   virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
    287                                       llvm::opt::ArgStringList &CmdArgs) const {
    288   }
    289 
    290   virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
    291                                  llvm::opt::ArgStringList &CmdArgs) const {}
    292 
    293   /// On some iOS platforms, kernel and kernel modules were built statically. Is
    294   /// this such a target?
    295   virtual bool isKernelStatic() const { return false; }
    296 
    297   /// Is the target either iOS or an iOS simulator?
    298   bool isTargetIOSBased() const { return false; }
    299 
    300   void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
    301                          llvm::opt::ArgStringList &CmdArgs,
    302                          StringRef DarwinLibName, bool AlwaysLink = false,
    303                          bool IsEmbedded = false, bool AddRPath = false) const;
    304 
    305   /// Add any profiling runtime libraries that are needed. This is essentially a
    306   /// MachO specific version of addProfileRT in Tools.cpp.
    307   void addProfileRTLibs(const llvm::opt::ArgList &Args,
    308                         llvm::opt::ArgStringList &CmdArgs) const override {
    309     // There aren't any profiling libs for embedded targets currently.
    310   }
    311 
    312   /// }
    313   /// @name ToolChain Implementation
    314   /// {
    315 
    316   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
    317                                           types::ID InputType) const override;
    318 
    319   types::ID LookupTypeForExtension(const char *Ext) const override;
    320 
    321   bool HasNativeLLVMSupport() const override;
    322 
    323   llvm::opt::DerivedArgList *
    324   TranslateArgs(const llvm::opt::DerivedArgList &Args,
    325                 const char *BoundArch) const override;
    326 
    327   bool IsBlocksDefault() const override {
    328     // Always allow blocks on Apple; users interested in versioning are
    329     // expected to use /usr/include/Block.h.
    330     return true;
    331   }
    332   bool IsIntegratedAssemblerDefault() const override {
    333     // Default integrated assembler to on for Apple's MachO targets.
    334     return true;
    335   }
    336 
    337   bool IsMathErrnoDefault() const override { return false; }
    338 
    339   bool IsEncodeExtendedBlockSignatureDefault() const override { return true; }
    340 
    341   bool IsObjCNonFragileABIDefault() const override {
    342     // Non-fragile ABI is default for everything but i386.
    343     return getTriple().getArch() != llvm::Triple::x86;
    344   }
    345 
    346   bool UseObjCMixedDispatch() const override { return true; }
    347 
    348   bool IsUnwindTablesDefault() const override;
    349 
    350   RuntimeLibType GetDefaultRuntimeLibType() const override {
    351     return ToolChain::RLT_CompilerRT;
    352   }
    353 
    354   bool isPICDefault() const override;
    355   bool isPIEDefault() const override;
    356   bool isPICDefaultForced() const override;
    357 
    358   bool SupportsProfiling() const override;
    359 
    360   bool SupportsObjCGC() const override { return false; }
    361 
    362   bool UseDwarfDebugFlags() const override;
    363 
    364   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override {
    365     return false;
    366   }
    367 
    368   /// }
    369 };
    370 
    371 /// Darwin - The base Darwin tool chain.
    372 class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
    373 public:
    374   /// Whether the information on the target has been initialized.
    375   //
    376   // FIXME: This should be eliminated. What we want to do is make this part of
    377   // the "default target for arguments" selection process, once we get out of
    378   // the argument translation business.
    379   mutable bool TargetInitialized;
    380 
    381   enum DarwinPlatformKind {
    382     MacOS,
    383     IPhoneOS,
    384     IPhoneOSSimulator,
    385     TvOS,
    386     TvOSSimulator,
    387     WatchOS,
    388     WatchOSSimulator
    389   };
    390 
    391   mutable DarwinPlatformKind TargetPlatform;
    392 
    393   /// The OS version we are targeting.
    394   mutable VersionTuple TargetVersion;
    395 
    396 private:
    397   void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
    398 
    399 public:
    400   Darwin(const Driver &D, const llvm::Triple &Triple,
    401          const llvm::opt::ArgList &Args);
    402   ~Darwin() override;
    403 
    404   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
    405                                           types::ID InputType) const override;
    406 
    407   /// @name Apple Specific Toolchain Implementation
    408   /// {
    409 
    410   void addMinVersionArgs(const llvm::opt::ArgList &Args,
    411                          llvm::opt::ArgStringList &CmdArgs) const override;
    412 
    413   void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
    414                               llvm::opt::ArgStringList &CmdArgs) const override;
    415 
    416   bool isKernelStatic() const override {
    417     return (!(isTargetIPhoneOS() && !isIPhoneOSVersionLT(6, 0)) &&
    418             !isTargetWatchOS());
    419   }
    420 
    421   void addProfileRTLibs(const llvm::opt::ArgList &Args,
    422                         llvm::opt::ArgStringList &CmdArgs) const override;
    423 
    424 protected:
    425   /// }
    426   /// @name Darwin specific Toolchain functions
    427   /// {
    428 
    429   // FIXME: Eliminate these ...Target functions and derive separate tool chains
    430   // for these targets and put version in constructor.
    431   void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor,
    432                  unsigned Micro) const {
    433     // FIXME: For now, allow reinitialization as long as values don't
    434     // change. This will go away when we move away from argument translation.
    435     if (TargetInitialized && TargetPlatform == Platform &&
    436         TargetVersion == VersionTuple(Major, Minor, Micro))
    437       return;
    438 
    439     assert(!TargetInitialized && "Target already initialized!");
    440     TargetInitialized = true;
    441     TargetPlatform = Platform;
    442     TargetVersion = VersionTuple(Major, Minor, Micro);
    443   }
    444 
    445   bool isTargetIPhoneOS() const {
    446     assert(TargetInitialized && "Target not initialized!");
    447     return TargetPlatform == IPhoneOS || TargetPlatform == TvOS;
    448   }
    449 
    450   bool isTargetIOSSimulator() const {
    451     assert(TargetInitialized && "Target not initialized!");
    452     return TargetPlatform == IPhoneOSSimulator ||
    453            TargetPlatform == TvOSSimulator;
    454   }
    455 
    456   bool isTargetIOSBased() const {
    457     assert(TargetInitialized && "Target not initialized!");
    458     return isTargetIPhoneOS() || isTargetIOSSimulator();
    459   }
    460 
    461   bool isTargetTvOS() const {
    462     assert(TargetInitialized && "Target not initialized!");
    463     return TargetPlatform == TvOS;
    464   }
    465 
    466   bool isTargetTvOSSimulator() const {
    467     assert(TargetInitialized && "Target not initialized!");
    468     return TargetPlatform == TvOSSimulator;
    469   }
    470 
    471   bool isTargetTvOSBased() const {
    472     assert(TargetInitialized && "Target not initialized!");
    473     return TargetPlatform == TvOS || TargetPlatform == TvOSSimulator;
    474   }
    475 
    476   bool isTargetWatchOS() const {
    477     assert(TargetInitialized && "Target not initialized!");
    478     return TargetPlatform == WatchOS;
    479   }
    480 
    481   bool isTargetWatchOSSimulator() const {
    482     assert(TargetInitialized && "Target not initialized!");
    483     return TargetPlatform == WatchOSSimulator;
    484   }
    485 
    486   bool isTargetWatchOSBased() const {
    487     assert(TargetInitialized && "Target not initialized!");
    488     return TargetPlatform == WatchOS || TargetPlatform == WatchOSSimulator;
    489   }
    490 
    491   bool isTargetMacOS() const {
    492     assert(TargetInitialized && "Target not initialized!");
    493     return TargetPlatform == MacOS;
    494   }
    495 
    496   bool isTargetInitialized() const { return TargetInitialized; }
    497 
    498   VersionTuple getTargetVersion() const {
    499     assert(TargetInitialized && "Target not initialized!");
    500     return TargetVersion;
    501   }
    502 
    503   bool isIPhoneOSVersionLT(unsigned V0, unsigned V1 = 0,
    504                            unsigned V2 = 0) const {
    505     assert(isTargetIOSBased() && "Unexpected call for non iOS target!");
    506     return TargetVersion < VersionTuple(V0, V1, V2);
    507   }
    508 
    509   bool isMacosxVersionLT(unsigned V0, unsigned V1 = 0, unsigned V2 = 0) const {
    510     assert(isTargetMacOS() && "Unexpected call for non OS X target!");
    511     return TargetVersion < VersionTuple(V0, V1, V2);
    512   }
    513 
    514   StringRef getPlatformFamily() const;
    515   static StringRef getSDKName(StringRef isysroot);
    516   StringRef getOSLibraryNameSuffix() const;
    517 
    518 public:
    519   /// }
    520   /// @name ToolChain Implementation
    521   /// {
    522 
    523   // Darwin tools support multiple architecture (e.g., i386 and x86_64) and
    524   // most development is done against SDKs, so compiling for a different
    525   // architecture should not get any special treatment.
    526   bool isCrossCompiling() const override { return false; }
    527 
    528   llvm::opt::DerivedArgList *
    529   TranslateArgs(const llvm::opt::DerivedArgList &Args,
    530                 const char *BoundArch) const override;
    531 
    532   CXXStdlibType GetDefaultCXXStdlibType() const override;
    533   ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
    534   bool hasBlocksRuntime() const override;
    535 
    536   bool UseObjCMixedDispatch() const override {
    537     // This is only used with the non-fragile ABI and non-legacy dispatch.
    538 
    539     // Mixed dispatch is used everywhere except OS X before 10.6.
    540     return !(isTargetMacOS() && isMacosxVersionLT(10, 6));
    541   }
    542 
    543   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
    544     // Stack protectors default to on for user code on 10.5,
    545     // and for everything in 10.6 and beyond
    546     if (isTargetIOSBased() || isTargetWatchOSBased())
    547       return 1;
    548     else if (isTargetMacOS() && !isMacosxVersionLT(10, 6))
    549       return 1;
    550     else if (isTargetMacOS() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
    551       return 1;
    552 
    553     return 0;
    554   }
    555 
    556   bool SupportsObjCGC() const override;
    557 
    558   void CheckObjCARC() const override;
    559 
    560   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
    561 
    562   bool SupportsEmbeddedBitcode() const override;
    563 
    564   SanitizerMask getSupportedSanitizers() const override;
    565 };
    566 
    567 /// DarwinClang - The Darwin toolchain used by Clang.
    568 class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
    569 public:
    570   DarwinClang(const Driver &D, const llvm::Triple &Triple,
    571               const llvm::opt::ArgList &Args);
    572 
    573   /// @name Apple ToolChain Implementation
    574   /// {
    575 
    576   void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
    577                              llvm::opt::ArgStringList &CmdArgs) const override;
    578 
    579   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    580                            llvm::opt::ArgStringList &CmdArgs) const override;
    581 
    582   void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
    583                         llvm::opt::ArgStringList &CmdArgs) const override;
    584 
    585   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
    586 
    587   void AddLinkARCArgs(const llvm::opt::ArgList &Args,
    588                       llvm::opt::ArgStringList &CmdArgs) const override;
    589 
    590   unsigned GetDefaultDwarfVersion() const override { return 2; }
    591   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
    592   // Darwin defaults to standalone/full debug info.
    593   bool GetDefaultStandaloneDebug() const override { return true; }
    594   llvm::DebuggerKind getDefaultDebuggerTuning() const override {
    595     return llvm::DebuggerKind::LLDB;
    596   }
    597 
    598   /// }
    599 
    600 private:
    601   void AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
    602                                llvm::opt::ArgStringList &CmdArgs,
    603                                StringRef Sanitizer) const;
    604 };
    605 
    606 class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
    607   virtual void anchor();
    608 
    609 public:
    610   Generic_ELF(const Driver &D, const llvm::Triple &Triple,
    611               const llvm::opt::ArgList &Args)
    612       : Generic_GCC(D, Triple, Args) {}
    613 
    614   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
    615                              llvm::opt::ArgStringList &CC1Args) const override;
    616 };
    617 
    618 class LLVM_LIBRARY_VISIBILITY CloudABI : public Generic_ELF {
    619 public:
    620   CloudABI(const Driver &D, const llvm::Triple &Triple,
    621            const llvm::opt::ArgList &Args);
    622   bool HasNativeLLVMSupport() const override { return true; }
    623 
    624   bool IsMathErrnoDefault() const override { return false; }
    625   bool IsObjCNonFragileABIDefault() const override { return true; }
    626 
    627   CXXStdlibType
    628   GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
    629     return ToolChain::CST_Libcxx;
    630   }
    631   void AddClangCXXStdlibIncludeArgs(
    632       const llvm::opt::ArgList &DriverArgs,
    633       llvm::opt::ArgStringList &CC1Args) const override;
    634   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    635                            llvm::opt::ArgStringList &CmdArgs) const override;
    636 
    637   bool isPIEDefault() const override { return true; }
    638 
    639   SanitizerMask getSupportedSanitizers() const override;
    640   SanitizerMask getDefaultSanitizers() const override;
    641 
    642 protected:
    643   Tool *buildLinker() const override;
    644 };
    645 
    646 class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
    647 public:
    648   Solaris(const Driver &D, const llvm::Triple &Triple,
    649           const llvm::opt::ArgList &Args);
    650 
    651   bool IsIntegratedAssemblerDefault() const override { return true; }
    652 
    653   void AddClangCXXStdlibIncludeArgs(
    654       const llvm::opt::ArgList &DriverArgs,
    655       llvm::opt::ArgStringList &CC1Args) const override;
    656 
    657   unsigned GetDefaultDwarfVersion() const override { return 2; }
    658 
    659 protected:
    660   Tool *buildAssembler() const override;
    661   Tool *buildLinker() const override;
    662 };
    663 
    664 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
    665 public:
    666   MinGW(const Driver &D, const llvm::Triple &Triple,
    667         const llvm::opt::ArgList &Args);
    668 
    669   bool IsIntegratedAssemblerDefault() const override;
    670   bool IsUnwindTablesDefault() const override;
    671   bool isPICDefault() const override;
    672   bool isPIEDefault() const override;
    673   bool isPICDefaultForced() const override;
    674   bool UseSEHExceptions() const;
    675 
    676   void
    677   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    678                             llvm::opt::ArgStringList &CC1Args) const override;
    679   void AddClangCXXStdlibIncludeArgs(
    680       const llvm::opt::ArgList &DriverArgs,
    681       llvm::opt::ArgStringList &CC1Args) const override;
    682 
    683 protected:
    684   Tool *getTool(Action::ActionClass AC) const override;
    685   Tool *buildLinker() const override;
    686   Tool *buildAssembler() const override;
    687 
    688 private:
    689   std::string Base;
    690   std::string GccLibDir;
    691   std::string Ver;
    692   std::string Arch;
    693   mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
    694   mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
    695   void findGccLibDir();
    696 };
    697 
    698 class LLVM_LIBRARY_VISIBILITY Haiku : public Generic_ELF {
    699 public:
    700   Haiku(const Driver &D, const llvm::Triple &Triple,
    701           const llvm::opt::ArgList &Args);
    702 
    703   bool isPIEDefault() const override { return getTriple().getArch() == llvm::Triple::x86_64; }
    704 
    705   void
    706   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    707                               llvm::opt::ArgStringList &CC1Args) const override;
    708 };
    709 
    710 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
    711 public:
    712   OpenBSD(const Driver &D, const llvm::Triple &Triple,
    713           const llvm::opt::ArgList &Args);
    714 
    715   bool IsMathErrnoDefault() const override { return false; }
    716   bool IsObjCNonFragileABIDefault() const override { return true; }
    717   bool isPIEDefault() const override { return true; }
    718 
    719   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
    720     return 2;
    721   }
    722   unsigned GetDefaultDwarfVersion() const override { return 2; }
    723 
    724 protected:
    725   Tool *buildAssembler() const override;
    726   Tool *buildLinker() const override;
    727 };
    728 
    729 class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF {
    730 public:
    731   Bitrig(const Driver &D, const llvm::Triple &Triple,
    732          const llvm::opt::ArgList &Args);
    733 
    734   bool IsMathErrnoDefault() const override { return false; }
    735   bool IsObjCNonFragileABIDefault() const override { return true; }
    736 
    737   CXXStdlibType GetDefaultCXXStdlibType() const override;
    738   void AddClangCXXStdlibIncludeArgs(
    739       const llvm::opt::ArgList &DriverArgs,
    740       llvm::opt::ArgStringList &CC1Args) const override;
    741   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    742                            llvm::opt::ArgStringList &CmdArgs) const override;
    743   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
    744     return 1;
    745   }
    746 
    747 protected:
    748   Tool *buildAssembler() const override;
    749   Tool *buildLinker() const override;
    750 };
    751 
    752 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
    753 public:
    754   FreeBSD(const Driver &D, const llvm::Triple &Triple,
    755           const llvm::opt::ArgList &Args);
    756   bool HasNativeLLVMSupport() const override;
    757 
    758   bool IsMathErrnoDefault() const override { return false; }
    759   bool IsObjCNonFragileABIDefault() const override { return true; }
    760 
    761   CXXStdlibType GetDefaultCXXStdlibType() const override;
    762   void AddClangCXXStdlibIncludeArgs(
    763       const llvm::opt::ArgList &DriverArgs,
    764       llvm::opt::ArgStringList &CC1Args) const override;
    765   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    766                            llvm::opt::ArgStringList &CmdArgs) const override;
    767 
    768   bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
    769   bool isPIEDefault() const override;
    770   SanitizerMask getSupportedSanitizers() const override;
    771   unsigned GetDefaultDwarfVersion() const override { return 2; }
    772   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
    773   // FreeBSD defaults to standalone/full debug info.
    774   bool GetDefaultStandaloneDebug() const override { return true; }
    775 
    776 protected:
    777   Tool *buildAssembler() const override;
    778   Tool *buildLinker() const override;
    779 };
    780 
    781 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
    782 public:
    783   NetBSD(const Driver &D, const llvm::Triple &Triple,
    784          const llvm::opt::ArgList &Args);
    785 
    786   bool IsMathErrnoDefault() const override { return false; }
    787   bool IsObjCNonFragileABIDefault() const override { return true; }
    788 
    789   CXXStdlibType GetDefaultCXXStdlibType() const override;
    790 
    791   void AddClangCXXStdlibIncludeArgs(
    792       const llvm::opt::ArgList &DriverArgs,
    793       llvm::opt::ArgStringList &CC1Args) const override;
    794   bool IsUnwindTablesDefault() const override { return true; }
    795 
    796 protected:
    797   Tool *buildAssembler() const override;
    798   Tool *buildLinker() const override;
    799 };
    800 
    801 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
    802 public:
    803   Minix(const Driver &D, const llvm::Triple &Triple,
    804         const llvm::opt::ArgList &Args);
    805 
    806 protected:
    807   Tool *buildAssembler() const override;
    808   Tool *buildLinker() const override;
    809 };
    810 
    811 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
    812 public:
    813   DragonFly(const Driver &D, const llvm::Triple &Triple,
    814             const llvm::opt::ArgList &Args);
    815 
    816   bool IsMathErrnoDefault() const override { return false; }
    817 
    818 protected:
    819   Tool *buildAssembler() const override;
    820   Tool *buildLinker() const override;
    821 };
    822 
    823 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
    824 public:
    825   Linux(const Driver &D, const llvm::Triple &Triple,
    826         const llvm::opt::ArgList &Args);
    827 
    828   bool HasNativeLLVMSupport() const override;
    829 
    830   void
    831   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    832                             llvm::opt::ArgStringList &CC1Args) const override;
    833   void AddClangCXXStdlibIncludeArgs(
    834       const llvm::opt::ArgList &DriverArgs,
    835       llvm::opt::ArgStringList &CC1Args) const override;
    836   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    837                           llvm::opt::ArgStringList &CC1Args) const override;
    838   void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    839                            llvm::opt::ArgStringList &CC1Args) const override;
    840   bool isPIEDefault() const override;
    841   SanitizerMask getSupportedSanitizers() const override;
    842   void addProfileRTLibs(const llvm::opt::ArgList &Args,
    843                         llvm::opt::ArgStringList &CmdArgs) const override;
    844   virtual std::string computeSysRoot() const;
    845 
    846   virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const;
    847 
    848   std::vector<std::string> ExtraOpts;
    849 
    850 protected:
    851   Tool *buildAssembler() const override;
    852   Tool *buildLinker() const override;
    853 };
    854 
    855 class LLVM_LIBRARY_VISIBILITY CudaToolChain : public Linux {
    856 public:
    857   CudaToolChain(const Driver &D, const llvm::Triple &Triple,
    858                 const llvm::opt::ArgList &Args);
    859 
    860   llvm::opt::DerivedArgList *
    861   TranslateArgs(const llvm::opt::DerivedArgList &Args,
    862                 const char *BoundArch) const override;
    863   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
    864                              llvm::opt::ArgStringList &CC1Args) const override;
    865 
    866   // Never try to use the integrated assembler with CUDA; always fork out to
    867   // ptxas.
    868   bool useIntegratedAs() const override { return false; }
    869 
    870   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    871                           llvm::opt::ArgStringList &CC1Args) const override;
    872 
    873   const Generic_GCC::CudaInstallationDetector &cudaInstallation() const {
    874     return CudaInstallation;
    875   }
    876   Generic_GCC::CudaInstallationDetector &cudaInstallation() {
    877     return CudaInstallation;
    878   }
    879 
    880 protected:
    881   Tool *buildAssembler() const override;  // ptxas
    882   Tool *buildLinker() const override;     // fatbinary (ok, not really a linker)
    883 };
    884 
    885 class LLVM_LIBRARY_VISIBILITY MipsLLVMToolChain : public Linux {
    886 protected:
    887   Tool *buildLinker() const override;
    888 
    889 public:
    890   MipsLLVMToolChain(const Driver &D, const llvm::Triple &Triple,
    891                     const llvm::opt::ArgList &Args);
    892 
    893   void
    894   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    895                             llvm::opt::ArgStringList &CC1Args) const override;
    896 
    897   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    898 
    899   void AddClangCXXStdlibIncludeArgs(
    900       const llvm::opt::ArgList &DriverArgs,
    901       llvm::opt::ArgStringList &CC1Args) const override;
    902 
    903   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    904                            llvm::opt::ArgStringList &CmdArgs) const override;
    905 
    906   std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
    907                             bool Shared = false) const override;
    908 
    909   std::string computeSysRoot() const override;
    910 
    911   RuntimeLibType GetDefaultRuntimeLibType() const override {
    912     return GCCInstallation.isValid() ? RuntimeLibType::RLT_Libgcc
    913                                      : RuntimeLibType::RLT_CompilerRT;
    914   }
    915 
    916 private:
    917   Multilib SelectedMultilib;
    918   std::string LibSuffix;
    919 };
    920 
    921 class LLVM_LIBRARY_VISIBILITY LanaiToolChain : public Generic_ELF {
    922 public:
    923   LanaiToolChain(const Driver &D, const llvm::Triple &Triple,
    924                  const llvm::opt::ArgList &Args)
    925       : Generic_ELF(D, Triple, Args) {}
    926   bool IsIntegratedAssemblerDefault() const override { return true; }
    927 };
    928 
    929 class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
    930 protected:
    931   GCCVersion GCCLibAndIncVersion;
    932   Tool *buildAssembler() const override;
    933   Tool *buildLinker() const override;
    934 
    935 public:
    936   HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
    937                    const llvm::opt::ArgList &Args);
    938   ~HexagonToolChain() override;
    939 
    940   void
    941   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    942                             llvm::opt::ArgStringList &CC1Args) const override;
    943   void AddClangCXXStdlibIncludeArgs(
    944       const llvm::opt::ArgList &DriverArgs,
    945       llvm::opt::ArgStringList &CC1Args) const override;
    946   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    947 
    948   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
    949   bool IsIntegratedAssemblerDefault() const override {
    950     return true;
    951   }
    952 
    953   std::string getHexagonTargetDir(
    954       const std::string &InstalledDir,
    955       const SmallVectorImpl<std::string> &PrefixDirs) const;
    956   void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
    957       ToolChain::path_list &LibPaths) const;
    958 
    959   static const StringRef GetDefaultCPU();
    960   static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
    961 
    962   static Optional<unsigned> getSmallDataThreshold(
    963       const llvm::opt::ArgList &Args);
    964 };
    965 
    966 class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
    967 protected:
    968   Tool *buildLinker() const override;
    969 
    970 public:
    971   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
    972             const llvm::opt::ArgList &Args);
    973   unsigned GetDefaultDwarfVersion() const override { return 2; }
    974   bool IsIntegratedAssemblerDefault() const override { return true; }
    975 };
    976 
    977 class LLVM_LIBRARY_VISIBILITY NaClToolChain : public Generic_ELF {
    978 public:
    979   NaClToolChain(const Driver &D, const llvm::Triple &Triple,
    980                 const llvm::opt::ArgList &Args);
    981 
    982   void
    983   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
    984                             llvm::opt::ArgStringList &CC1Args) const override;
    985   void AddClangCXXStdlibIncludeArgs(
    986       const llvm::opt::ArgList &DriverArgs,
    987       llvm::opt::ArgStringList &CC1Args) const override;
    988 
    989   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
    990 
    991   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
    992                            llvm::opt::ArgStringList &CmdArgs) const override;
    993 
    994   bool IsIntegratedAssemblerDefault() const override {
    995     return getTriple().getArch() == llvm::Triple::mipsel;
    996   }
    997 
    998   // Get the path to the file containing NaCl's ARM macros.
    999   // It lives in NaClToolChain because the ARMAssembler tool needs a
   1000   // const char * that it can pass around,
   1001   const char *GetNaClArmMacrosPath() const { return NaClArmMacrosPath.c_str(); }
   1002 
   1003   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
   1004                                           types::ID InputType) const override;
   1005 
   1006 protected:
   1007   Tool *buildLinker() const override;
   1008   Tool *buildAssembler() const override;
   1009 
   1010 private:
   1011   std::string NaClArmMacrosPath;
   1012 };
   1013 
   1014 /// TCEToolChain - A tool chain using the llvm bitcode tools to perform
   1015 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
   1016 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
   1017 public:
   1018   TCEToolChain(const Driver &D, const llvm::Triple &Triple,
   1019                const llvm::opt::ArgList &Args);
   1020   ~TCEToolChain() override;
   1021 
   1022   bool IsMathErrnoDefault() const override;
   1023   bool isPICDefault() const override;
   1024   bool isPIEDefault() const override;
   1025   bool isPICDefaultForced() const override;
   1026 };
   1027 
   1028 class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
   1029 public:
   1030   MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
   1031                 const llvm::opt::ArgList &Args);
   1032 
   1033   llvm::opt::DerivedArgList *
   1034   TranslateArgs(const llvm::opt::DerivedArgList &Args,
   1035                 const char *BoundArch) const override;
   1036 
   1037   bool IsIntegratedAssemblerDefault() const override;
   1038   bool IsUnwindTablesDefault() const override;
   1039   bool isPICDefault() const override;
   1040   bool isPIEDefault() const override;
   1041   bool isPICDefaultForced() const override;
   1042 
   1043   void
   1044   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   1045                             llvm::opt::ArgStringList &CC1Args) const override;
   1046   void AddClangCXXStdlibIncludeArgs(
   1047       const llvm::opt::ArgList &DriverArgs,
   1048       llvm::opt::ArgStringList &CC1Args) const override;
   1049 
   1050   bool getWindowsSDKDir(std::string &path, int &major,
   1051                         std::string &windowsSDKIncludeVersion,
   1052                         std::string &windowsSDKLibVersion) const;
   1053   bool getWindowsSDKLibraryPath(std::string &path) const;
   1054   /// \brief Check if Universal CRT should be used if available
   1055   bool useUniversalCRT(std::string &visualStudioDir) const;
   1056   bool getUniversalCRTSdkDir(std::string &path, std::string &ucrtVersion) const;
   1057   bool getUniversalCRTLibraryPath(std::string &path) const;
   1058   bool getVisualStudioInstallDir(std::string &path) const;
   1059   bool getVisualStudioBinariesFolder(const char *clangProgramPath,
   1060                                      std::string &path) const;
   1061   VersionTuple getMSVCVersionFromExe() const override;
   1062 
   1063   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
   1064                                           types::ID InputType) const override;
   1065   SanitizerMask getSupportedSanitizers() const override;
   1066 
   1067 protected:
   1068   void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
   1069                                      llvm::opt::ArgStringList &CC1Args,
   1070                                      const std::string &folder,
   1071                                      const Twine &subfolder1,
   1072                                      const Twine &subfolder2 = "",
   1073                                      const Twine &subfolder3 = "") const;
   1074 
   1075   Tool *buildLinker() const override;
   1076   Tool *buildAssembler() const override;
   1077 };
   1078 
   1079 class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC {
   1080 public:
   1081   CrossWindowsToolChain(const Driver &D, const llvm::Triple &T,
   1082                         const llvm::opt::ArgList &Args);
   1083 
   1084   bool IsIntegratedAssemblerDefault() const override { return true; }
   1085   bool IsUnwindTablesDefault() const override;
   1086   bool isPICDefault() const override;
   1087   bool isPIEDefault() const override;
   1088   bool isPICDefaultForced() const override;
   1089 
   1090   unsigned int GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
   1091     return 0;
   1092   }
   1093 
   1094   void
   1095   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   1096                             llvm::opt::ArgStringList &CC1Args) const override;
   1097   void AddClangCXXStdlibIncludeArgs(
   1098       const llvm::opt::ArgList &DriverArgs,
   1099       llvm::opt::ArgStringList &CC1Args) const override;
   1100   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
   1101                            llvm::opt::ArgStringList &CmdArgs) const override;
   1102 
   1103   SanitizerMask getSupportedSanitizers() const override;
   1104 
   1105 protected:
   1106   Tool *buildLinker() const override;
   1107   Tool *buildAssembler() const override;
   1108 };
   1109 
   1110 class LLVM_LIBRARY_VISIBILITY XCoreToolChain : public ToolChain {
   1111 public:
   1112   XCoreToolChain(const Driver &D, const llvm::Triple &Triple,
   1113                  const llvm::opt::ArgList &Args);
   1114 
   1115 protected:
   1116   Tool *buildAssembler() const override;
   1117   Tool *buildLinker() const override;
   1118 
   1119 public:
   1120   bool isPICDefault() const override;
   1121   bool isPIEDefault() const override;
   1122   bool isPICDefaultForced() const override;
   1123   bool SupportsProfiling() const override;
   1124   bool hasBlocksRuntime() const override;
   1125   void
   1126   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   1127                             llvm::opt::ArgStringList &CC1Args) const override;
   1128   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
   1129                              llvm::opt::ArgStringList &CC1Args) const override;
   1130   void AddClangCXXStdlibIncludeArgs(
   1131       const llvm::opt::ArgList &DriverArgs,
   1132       llvm::opt::ArgStringList &CC1Args) const override;
   1133   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
   1134                            llvm::opt::ArgStringList &CmdArgs) const override;
   1135 };
   1136 
   1137 /// MyriadToolChain - A tool chain using either clang or the external compiler
   1138 /// installed by the Movidius SDK to perform all subcommands.
   1139 class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_ELF {
   1140 public:
   1141   MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
   1142                   const llvm::opt::ArgList &Args);
   1143   ~MyriadToolChain() override;
   1144 
   1145   void
   1146   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   1147                             llvm::opt::ArgStringList &CC1Args) const override;
   1148   void AddClangCXXStdlibIncludeArgs(
   1149       const llvm::opt::ArgList &DriverArgs,
   1150       llvm::opt::ArgStringList &CC1Args) const override;
   1151   Tool *SelectTool(const JobAction &JA) const override;
   1152   unsigned GetDefaultDwarfVersion() const override { return 2; }
   1153 
   1154 protected:
   1155   Tool *buildLinker() const override;
   1156   bool isShaveCompilation(const llvm::Triple &T) const {
   1157     return T.getArch() == llvm::Triple::shave;
   1158   }
   1159 
   1160 private:
   1161   mutable std::unique_ptr<Tool> Compiler;
   1162   mutable std::unique_ptr<Tool> Assembler;
   1163 };
   1164 
   1165 class LLVM_LIBRARY_VISIBILITY WebAssembly final : public ToolChain {
   1166 public:
   1167   WebAssembly(const Driver &D, const llvm::Triple &Triple,
   1168               const llvm::opt::ArgList &Args);
   1169 
   1170 private:
   1171   bool IsMathErrnoDefault() const override;
   1172   bool IsObjCNonFragileABIDefault() const override;
   1173   bool UseObjCMixedDispatch() const override;
   1174   bool isPICDefault() const override;
   1175   bool isPIEDefault() const override;
   1176   bool isPICDefaultForced() const override;
   1177   bool IsIntegratedAssemblerDefault() const override;
   1178   bool hasBlocksRuntime() const override;
   1179   bool SupportsObjCGC() const override;
   1180   bool SupportsProfiling() const override;
   1181   bool HasNativeLLVMSupport() const override;
   1182   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
   1183                              llvm::opt::ArgStringList &CC1Args) const override;
   1184   RuntimeLibType GetDefaultRuntimeLibType() const override;
   1185   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
   1186   void AddClangSystemIncludeArgs(
   1187       const llvm::opt::ArgList &DriverArgs,
   1188       llvm::opt::ArgStringList &CC1Args) const override;
   1189   void AddClangCXXStdlibIncludeArgs(
   1190       const llvm::opt::ArgList &DriverArgs,
   1191       llvm::opt::ArgStringList &CC1Args) const override;
   1192 
   1193   Tool *buildLinker() const override;
   1194 };
   1195 
   1196 class LLVM_LIBRARY_VISIBILITY PS4CPU : public Generic_ELF {
   1197 public:
   1198   PS4CPU(const Driver &D, const llvm::Triple &Triple,
   1199          const llvm::opt::ArgList &Args);
   1200 
   1201   bool IsMathErrnoDefault() const override { return false; }
   1202   bool IsObjCNonFragileABIDefault() const override { return true; }
   1203   bool HasNativeLLVMSupport() const override;
   1204   bool isPICDefault() const override;
   1205 
   1206   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
   1207     return 2; // SSPStrong
   1208   }
   1209 
   1210   llvm::DebuggerKind getDefaultDebuggerTuning() const override {
   1211     return llvm::DebuggerKind::SCE;
   1212   }
   1213 
   1214   SanitizerMask getSupportedSanitizers() const override;
   1215 
   1216 protected:
   1217   Tool *buildAssembler() const override;
   1218   Tool *buildLinker() const override;
   1219 };
   1220 
   1221 } // end namespace toolchains
   1222 } // end namespace driver
   1223 } // end namespace clang
   1224 
   1225 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
   1226