clang  3.9.0
ToolChains.h
Go to the documentation of this file.
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"
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.
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,
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:
161 
162  // \brief A class to find a viable CUDA installation
164  private:
165  const Driver &D;
166  bool IsValid = false;
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 
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 
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 
388  WatchOSSimulator
389  };
390 
392 
393  /// The OS version we are targeting.
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 
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 
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;
638  SanitizerMask getSupportedSanitizers() const override;
639  SanitizerMask getDefaultSanitizers() const override;
640 
641 protected:
642  Tool *buildLinker() const override;
643 };
644 
645 class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
646 public:
647  Solaris(const Driver &D, const llvm::Triple &Triple,
648  const llvm::opt::ArgList &Args);
649 
650  bool IsIntegratedAssemblerDefault() const override { return true; }
651 
652  void AddClangCXXStdlibIncludeArgs(
653  const llvm::opt::ArgList &DriverArgs,
654  llvm::opt::ArgStringList &CC1Args) const override;
655 
656  unsigned GetDefaultDwarfVersion() const override { return 2; }
657 
658 protected:
659  Tool *buildAssembler() const override;
660  Tool *buildLinker() const override;
661 };
662 
663 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
664 public:
665  MinGW(const Driver &D, const llvm::Triple &Triple,
666  const llvm::opt::ArgList &Args);
667 
668  bool IsIntegratedAssemblerDefault() const override;
669  bool IsUnwindTablesDefault() const override;
670  bool isPICDefault() const override;
671  bool isPIEDefault() const override;
672  bool isPICDefaultForced() const override;
673  bool UseSEHExceptions() const;
674 
675  void
676  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
677  llvm::opt::ArgStringList &CC1Args) const override;
678  void AddClangCXXStdlibIncludeArgs(
679  const llvm::opt::ArgList &DriverArgs,
680  llvm::opt::ArgStringList &CC1Args) const override;
681 
682 protected:
683  Tool *getTool(Action::ActionClass AC) const override;
684  Tool *buildLinker() const override;
685  Tool *buildAssembler() const override;
686 
687 private:
688  std::string Base;
689  std::string GccLibDir;
690  std::string Ver;
691  std::string Arch;
692  mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
693  mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
694  void findGccLibDir();
695 };
696 
697 class LLVM_LIBRARY_VISIBILITY Haiku : public Generic_ELF {
698 public:
699  Haiku(const Driver &D, const llvm::Triple &Triple,
700  const llvm::opt::ArgList &Args);
701 
702  bool isPIEDefault() const override { return getTriple().getArch() == llvm::Triple::x86_64; }
703 
704  void
705  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
706  llvm::opt::ArgStringList &CC1Args) const override;
707 };
708 
709 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
710 public:
711  OpenBSD(const Driver &D, const llvm::Triple &Triple,
712  const llvm::opt::ArgList &Args);
713 
714  bool IsMathErrnoDefault() const override { return false; }
715  bool IsObjCNonFragileABIDefault() const override { return true; }
716  bool isPIEDefault() const override { return true; }
717 
718  unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
719  return 2;
720  }
721  unsigned GetDefaultDwarfVersion() const override { return 2; }
722 
723 protected:
724  Tool *buildAssembler() const override;
725  Tool *buildLinker() const override;
726 };
727 
728 class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF {
729 public:
730  Bitrig(const Driver &D, const llvm::Triple &Triple,
731  const llvm::opt::ArgList &Args);
732 
733  bool IsMathErrnoDefault() const override { return false; }
734  bool IsObjCNonFragileABIDefault() const override { return true; }
735 
736  CXXStdlibType GetDefaultCXXStdlibType() const override;
737  void AddClangCXXStdlibIncludeArgs(
738  const llvm::opt::ArgList &DriverArgs,
739  llvm::opt::ArgStringList &CC1Args) const override;
740  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
741  llvm::opt::ArgStringList &CmdArgs) const override;
742  unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
743  return 1;
744  }
745 
746 protected:
747  Tool *buildAssembler() const override;
748  Tool *buildLinker() const override;
749 };
750 
751 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
752 public:
753  FreeBSD(const Driver &D, const llvm::Triple &Triple,
754  const llvm::opt::ArgList &Args);
755  bool HasNativeLLVMSupport() const override;
756 
757  bool IsMathErrnoDefault() const override { return false; }
758  bool IsObjCNonFragileABIDefault() const override { return true; }
759 
760  CXXStdlibType GetDefaultCXXStdlibType() const override;
761  void AddClangCXXStdlibIncludeArgs(
762  const llvm::opt::ArgList &DriverArgs,
763  llvm::opt::ArgStringList &CC1Args) const override;
764  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
765  llvm::opt::ArgStringList &CmdArgs) const override;
766 
767  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
768  bool isPIEDefault() const override;
769  SanitizerMask getSupportedSanitizers() const override;
770  unsigned GetDefaultDwarfVersion() const override { return 2; }
771  // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
772  // FreeBSD defaults to standalone/full debug info.
773  bool GetDefaultStandaloneDebug() const override { return true; }
774 
775 protected:
776  Tool *buildAssembler() const override;
777  Tool *buildLinker() const override;
778 };
779 
780 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
781 public:
782  NetBSD(const Driver &D, const llvm::Triple &Triple,
783  const llvm::opt::ArgList &Args);
784 
785  bool IsMathErrnoDefault() const override { return false; }
786  bool IsObjCNonFragileABIDefault() const override { return true; }
787 
788  CXXStdlibType GetDefaultCXXStdlibType() const override;
789 
790  void AddClangCXXStdlibIncludeArgs(
791  const llvm::opt::ArgList &DriverArgs,
792  llvm::opt::ArgStringList &CC1Args) const override;
793  bool IsUnwindTablesDefault() const override { return true; }
794 
795 protected:
796  Tool *buildAssembler() const override;
797  Tool *buildLinker() const override;
798 };
799 
800 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
801 public:
802  Minix(const Driver &D, const llvm::Triple &Triple,
803  const llvm::opt::ArgList &Args);
804 
805 protected:
806  Tool *buildAssembler() const override;
807  Tool *buildLinker() const override;
808 };
809 
810 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
811 public:
812  DragonFly(const Driver &D, const llvm::Triple &Triple,
813  const llvm::opt::ArgList &Args);
814 
815  bool IsMathErrnoDefault() const override { return false; }
816 
817 protected:
818  Tool *buildAssembler() const override;
819  Tool *buildLinker() const override;
820 };
821 
822 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
823 public:
824  Linux(const Driver &D, const llvm::Triple &Triple,
825  const llvm::opt::ArgList &Args);
826 
827  bool HasNativeLLVMSupport() const override;
828 
829  void
830  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
831  llvm::opt::ArgStringList &CC1Args) const override;
832  void AddClangCXXStdlibIncludeArgs(
833  const llvm::opt::ArgList &DriverArgs,
834  llvm::opt::ArgStringList &CC1Args) const override;
835  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
836  llvm::opt::ArgStringList &CC1Args) const override;
837  void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
838  llvm::opt::ArgStringList &CC1Args) const override;
839  bool isPIEDefault() const override;
840  SanitizerMask getSupportedSanitizers() const override;
841  void addProfileRTLibs(const llvm::opt::ArgList &Args,
842  llvm::opt::ArgStringList &CmdArgs) const override;
843  virtual std::string computeSysRoot() const;
844 
845  virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const;
846 
847  std::vector<std::string> ExtraOpts;
848 
849 protected:
850  Tool *buildAssembler() const override;
851  Tool *buildLinker() const override;
852 };
853 
854 class LLVM_LIBRARY_VISIBILITY CudaToolChain : public Linux {
855 public:
856  CudaToolChain(const Driver &D, const llvm::Triple &Triple,
857  const llvm::opt::ArgList &Args);
858 
859  llvm::opt::DerivedArgList *
860  TranslateArgs(const llvm::opt::DerivedArgList &Args,
861  const char *BoundArch) const override;
862  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
863  llvm::opt::ArgStringList &CC1Args) const override;
864 
865  // Never try to use the integrated assembler with CUDA; always fork out to
866  // ptxas.
867  bool useIntegratedAs() const override { return false; }
868 
869  void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
870  llvm::opt::ArgStringList &CC1Args) const override;
871 
873  return CudaInstallation;
874  }
876  return CudaInstallation;
877  }
878 
879 protected:
880  Tool *buildAssembler() const override; // ptxas
881  Tool *buildLinker() const override; // fatbinary (ok, not really a linker)
882 };
883 
884 class LLVM_LIBRARY_VISIBILITY MipsLLVMToolChain : public Linux {
885 protected:
886  Tool *buildLinker() const override;
887 
888 public:
889  MipsLLVMToolChain(const Driver &D, const llvm::Triple &Triple,
890  const llvm::opt::ArgList &Args);
891 
892  void
893  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
894  llvm::opt::ArgStringList &CC1Args) const override;
895 
896  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
897 
898  void AddClangCXXStdlibIncludeArgs(
899  const llvm::opt::ArgList &DriverArgs,
900  llvm::opt::ArgStringList &CC1Args) const override;
901 
902  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
903  llvm::opt::ArgStringList &CmdArgs) const override;
904 
905  std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
906  bool Shared = false) const override;
907 
908  std::string computeSysRoot() const override;
909 
911  return GCCInstallation.isValid() ? RuntimeLibType::RLT_Libgcc
912  : RuntimeLibType::RLT_CompilerRT;
913  }
914 
915 private:
916  Multilib SelectedMultilib;
917  std::string LibSuffix;
918 };
919 
920 class LLVM_LIBRARY_VISIBILITY LanaiToolChain : public Generic_ELF {
921 public:
922  LanaiToolChain(const Driver &D, const llvm::Triple &Triple,
923  const llvm::opt::ArgList &Args)
924  : Generic_ELF(D, Triple, Args) {}
925  bool IsIntegratedAssemblerDefault() const override { return true; }
926 };
927 
928 class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
929 protected:
931  Tool *buildAssembler() const override;
932  Tool *buildLinker() const override;
933 
934 public:
935  HexagonToolChain(const Driver &D, const llvm::Triple &Triple,
936  const llvm::opt::ArgList &Args);
937  ~HexagonToolChain() override;
938 
939  void
940  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
941  llvm::opt::ArgStringList &CC1Args) const override;
942  void AddClangCXXStdlibIncludeArgs(
943  const llvm::opt::ArgList &DriverArgs,
944  llvm::opt::ArgStringList &CC1Args) const override;
945  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
946 
947  StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
948  bool IsIntegratedAssemblerDefault() const override {
949  return true;
950  }
951 
952  std::string getHexagonTargetDir(
953  const std::string &InstalledDir,
954  const SmallVectorImpl<std::string> &PrefixDirs) const;
955  void getHexagonLibraryPaths(const llvm::opt::ArgList &Args,
956  ToolChain::path_list &LibPaths) const;
957 
958  static const StringRef GetDefaultCPU();
959  static const StringRef GetTargetCPUVersion(const llvm::opt::ArgList &Args);
960 
961  static Optional<unsigned> getSmallDataThreshold(
962  const llvm::opt::ArgList &Args);
963 };
964 
965 class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public Generic_ELF {
966 protected:
967  Tool *buildLinker() const override;
968 
969 public:
970  AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
971  const llvm::opt::ArgList &Args);
972  unsigned GetDefaultDwarfVersion() const override { return 2; }
973  bool IsIntegratedAssemblerDefault() const override { return true; }
974 };
975 
976 class LLVM_LIBRARY_VISIBILITY NaClToolChain : public Generic_ELF {
977 public:
978  NaClToolChain(const Driver &D, const llvm::Triple &Triple,
979  const llvm::opt::ArgList &Args);
980 
981  void
982  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
983  llvm::opt::ArgStringList &CC1Args) const override;
984  void AddClangCXXStdlibIncludeArgs(
985  const llvm::opt::ArgList &DriverArgs,
986  llvm::opt::ArgStringList &CC1Args) const override;
987 
988  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
989 
990  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
991  llvm::opt::ArgStringList &CmdArgs) const override;
992 
993  bool IsIntegratedAssemblerDefault() const override {
994  return getTriple().getArch() == llvm::Triple::mipsel;
995  }
996 
997  // Get the path to the file containing NaCl's ARM macros.
998  // It lives in NaClToolChain because the ARMAssembler tool needs a
999  // const char * that it can pass around,
1000  const char *GetNaClArmMacrosPath() const { return NaClArmMacrosPath.c_str(); }
1001 
1002  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
1003  types::ID InputType) const override;
1004 
1005 protected:
1006  Tool *buildLinker() const override;
1007  Tool *buildAssembler() const override;
1008 
1009 private:
1010  std::string NaClArmMacrosPath;
1011 };
1012 
1013 /// TCEToolChain - A tool chain using the llvm bitcode tools to perform
1014 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
1015 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
1016 public:
1017  TCEToolChain(const Driver &D, const llvm::Triple &Triple,
1018  const llvm::opt::ArgList &Args);
1019  ~TCEToolChain() override;
1020 
1021  bool IsMathErrnoDefault() const override;
1022  bool isPICDefault() const override;
1023  bool isPIEDefault() const override;
1024  bool isPICDefaultForced() const override;
1025 };
1026 
1027 class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
1028 public:
1029  MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
1030  const llvm::opt::ArgList &Args);
1031 
1032  llvm::opt::DerivedArgList *
1033  TranslateArgs(const llvm::opt::DerivedArgList &Args,
1034  const char *BoundArch) const override;
1035 
1036  bool IsIntegratedAssemblerDefault() const override;
1037  bool IsUnwindTablesDefault() const override;
1038  bool isPICDefault() const override;
1039  bool isPIEDefault() const override;
1040  bool isPICDefaultForced() const override;
1041 
1042  void
1043  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
1044  llvm::opt::ArgStringList &CC1Args) const override;
1045  void AddClangCXXStdlibIncludeArgs(
1046  const llvm::opt::ArgList &DriverArgs,
1047  llvm::opt::ArgStringList &CC1Args) const override;
1048 
1049  bool getWindowsSDKDir(std::string &path, int &major,
1050  std::string &windowsSDKIncludeVersion,
1051  std::string &windowsSDKLibVersion) const;
1052  bool getWindowsSDKLibraryPath(std::string &path) const;
1053  /// \brief Check if Universal CRT should be used if available
1054  bool useUniversalCRT(std::string &visualStudioDir) const;
1055  bool getUniversalCRTSdkDir(std::string &path, std::string &ucrtVersion) const;
1056  bool getUniversalCRTLibraryPath(std::string &path) const;
1057  bool getVisualStudioInstallDir(std::string &path) const;
1058  bool getVisualStudioBinariesFolder(const char *clangProgramPath,
1059  std::string &path) const;
1060  VersionTuple getMSVCVersionFromExe() const override;
1061 
1062  std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
1063  types::ID InputType) const override;
1064  SanitizerMask getSupportedSanitizers() const override;
1065 
1066 protected:
1067  void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
1068  llvm::opt::ArgStringList &CC1Args,
1069  const std::string &folder,
1070  const Twine &subfolder1,
1071  const Twine &subfolder2 = "",
1072  const Twine &subfolder3 = "") const;
1073 
1074  Tool *buildLinker() const override;
1075  Tool *buildAssembler() const override;
1076 };
1077 
1078 class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC {
1079 public:
1080  CrossWindowsToolChain(const Driver &D, const llvm::Triple &T,
1081  const llvm::opt::ArgList &Args);
1082 
1083  bool IsIntegratedAssemblerDefault() const override { return true; }
1084  bool IsUnwindTablesDefault() const override;
1085  bool isPICDefault() const override;
1086  bool isPIEDefault() const override;
1087  bool isPICDefaultForced() const override;
1088 
1089  unsigned int GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
1090  return 0;
1091  }
1092 
1093  void
1094  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
1095  llvm::opt::ArgStringList &CC1Args) const override;
1096  void AddClangCXXStdlibIncludeArgs(
1097  const llvm::opt::ArgList &DriverArgs,
1098  llvm::opt::ArgStringList &CC1Args) const override;
1099  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
1100  llvm::opt::ArgStringList &CmdArgs) const override;
1101 
1102  SanitizerMask getSupportedSanitizers() const override;
1103 
1104 protected:
1105  Tool *buildLinker() const override;
1106  Tool *buildAssembler() const override;
1107 };
1108 
1109 class LLVM_LIBRARY_VISIBILITY XCoreToolChain : public ToolChain {
1110 public:
1111  XCoreToolChain(const Driver &D, const llvm::Triple &Triple,
1112  const llvm::opt::ArgList &Args);
1113 
1114 protected:
1115  Tool *buildAssembler() const override;
1116  Tool *buildLinker() const override;
1117 
1118 public:
1119  bool isPICDefault() const override;
1120  bool isPIEDefault() const override;
1121  bool isPICDefaultForced() const override;
1122  bool SupportsProfiling() const override;
1123  bool hasBlocksRuntime() const override;
1124  void
1125  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
1126  llvm::opt::ArgStringList &CC1Args) const override;
1127  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
1128  llvm::opt::ArgStringList &CC1Args) const override;
1129  void AddClangCXXStdlibIncludeArgs(
1130  const llvm::opt::ArgList &DriverArgs,
1131  llvm::opt::ArgStringList &CC1Args) const override;
1132  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
1133  llvm::opt::ArgStringList &CmdArgs) const override;
1134 };
1135 
1136 /// MyriadToolChain - A tool chain using either clang or the external compiler
1137 /// installed by the Movidius SDK to perform all subcommands.
1138 class LLVM_LIBRARY_VISIBILITY MyriadToolChain : public Generic_ELF {
1139 public:
1140  MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
1141  const llvm::opt::ArgList &Args);
1142  ~MyriadToolChain() override;
1143 
1144  void
1145  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
1146  llvm::opt::ArgStringList &CC1Args) const override;
1147  void AddClangCXXStdlibIncludeArgs(
1148  const llvm::opt::ArgList &DriverArgs,
1149  llvm::opt::ArgStringList &CC1Args) const override;
1150  Tool *SelectTool(const JobAction &JA) const override;
1151  unsigned GetDefaultDwarfVersion() const override { return 2; }
1152 
1153 protected:
1154  Tool *buildLinker() const override;
1155  bool isShaveCompilation(const llvm::Triple &T) const {
1156  return T.getArch() == llvm::Triple::shave;
1157  }
1158 
1159 private:
1160  mutable std::unique_ptr<Tool> Compiler;
1161  mutable std::unique_ptr<Tool> Assembler;
1162 };
1163 
1164 class LLVM_LIBRARY_VISIBILITY WebAssembly final : public ToolChain {
1165 public:
1166  WebAssembly(const Driver &D, const llvm::Triple &Triple,
1167  const llvm::opt::ArgList &Args);
1168 
1169 private:
1170  bool IsMathErrnoDefault() const override;
1171  bool IsObjCNonFragileABIDefault() const override;
1172  bool UseObjCMixedDispatch() const override;
1173  bool isPICDefault() const override;
1174  bool isPIEDefault() const override;
1175  bool isPICDefaultForced() const override;
1176  bool IsIntegratedAssemblerDefault() const override;
1177  bool hasBlocksRuntime() const override;
1178  bool SupportsObjCGC() const override;
1179  bool SupportsProfiling() const override;
1180  bool HasNativeLLVMSupport() const override;
1181  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
1182  llvm::opt::ArgStringList &CC1Args) const override;
1183  RuntimeLibType GetDefaultRuntimeLibType() const override;
1184  CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
1185  void AddClangSystemIncludeArgs(
1186  const llvm::opt::ArgList &DriverArgs,
1187  llvm::opt::ArgStringList &CC1Args) const override;
1188  void AddClangCXXStdlibIncludeArgs(
1189  const llvm::opt::ArgList &DriverArgs,
1190  llvm::opt::ArgStringList &CC1Args) const override;
1191 
1192  Tool *buildLinker() const override;
1193 };
1194 
1195 class LLVM_LIBRARY_VISIBILITY PS4CPU : public Generic_ELF {
1196 public:
1197  PS4CPU(const Driver &D, const llvm::Triple &Triple,
1198  const llvm::opt::ArgList &Args);
1199 
1200  bool IsMathErrnoDefault() const override { return false; }
1201  bool IsObjCNonFragileABIDefault() const override { return true; }
1202  bool HasNativeLLVMSupport() const override;
1203  bool isPICDefault() const override;
1204 
1205  unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
1206  return 2; // SSPStrong
1207  }
1208 
1209  llvm::DebuggerKind getDefaultDebuggerTuning() const override {
1210  return llvm::DebuggerKind::SCE;
1211  }
1212 
1213  SanitizerMask getSupportedSanitizers() const override;
1214 
1215 protected:
1216  Tool *buildAssembler() const override;
1217  Tool *buildLinker() const override;
1218 };
1219 
1220 } // end namespace toolchains
1221 } // end namespace driver
1222 } // end namespace clang
1223 
1224 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:624
unsigned GetDefaultDwarfVersion() const override
Definition: ToolChains.h:656
bool IsEncodeExtendedBlockSignatureDefault() const override
IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable -fencode-extended-block-signature...
Definition: ToolChains.h:339
DarwinClang - The Darwin toolchain used by Clang.
Definition: ToolChains.h:568
CudaArch
Definition: Cuda.h:30
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
Generic_GCC::CudaInstallationDetector & cudaInstallation()
Definition: ToolChains.h:875
unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain (0=off...
Definition: ToolChains.h:543
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:815
Generic_GCC - A tool chain using the 'gcc' command to perform all subcommands; this relies on gcc tra...
Definition: ToolChains.h:33
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:733
bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override
UseSjLjExceptions - Does this tool chain use SjLj exceptions.
Definition: ToolChains.h:364
SmallString< 128 > getCompilerRT(const ToolChain &TC, const llvm::opt::ArgList &Args, StringRef Component, bool Shared=false)
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: ToolChains.h:350
unsigned int GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain (0=off...
Definition: ToolChains.h:1089
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: ToolChains.h:526
Struct to store and manipulate GCC versions.
Definition: ToolChains.h:50
MyriadToolChain - A tool chain using either clang or the external compiler installed by the Movidius ...
Definition: ToolChains.h:1138
StringRef getInstallPath() const
Get the detected GCC installation path.
Definition: ToolChains.h:116
bool operator<=(const GCCVersion &RHS) const
Definition: ToolChains.h:70
bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const
Definition: ToolChains.h:503
bool IsBlocksDefault() const override
IsBlocksDefault - Does this tool chain enable -fblocks by default.
Definition: ToolChains.h:327
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:714
unsigned GetDefaultDwarfVersion() const override
Definition: ToolChains.h:770
std::string PatchSuffix
Any textual suffix on the patch number.
Definition: ToolChains.h:61
unsigned GetDefaultDwarfVersion() const override
Definition: ToolChains.h:1151
unsigned GetDefaultDwarfVersion() const override
Definition: ToolChains.h:972
bool TargetInitialized
Whether the information on the target has been initialized.
Definition: ToolChains.h:379
unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain (0=off...
Definition: ToolChains.h:1205
const llvm::Triple & getTriple() const
Get the GCC triple for the detected install.
Definition: ToolChains.h:113
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:625
GCCInstallationDetector GCCInstallation
Definition: ToolChains.h:160
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:715
void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Add any profiling runtime libraries that are needed.
Definition: ToolChains.h:307
virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition: ToolChains.h:286
Darwin - The base Darwin tool chain.
Definition: ToolChains.h:372
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: ToolChains.h:910
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:993
StringRef getInstallPath() const
Get the detected Cuda installation path.
Definition: ToolChains.h:197
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:650
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:337
bool isValid() const
Check whether we detected a valid Cuda install.
Definition: ToolChains.h:190
const Multilib & getMultilib() const
Get the detected Multilib.
Definition: ToolChains.h:122
unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain (0=off...
Definition: ToolChains.h:718
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:66
const char * GetNaClArmMacrosPath() const
Definition: ToolChains.h:1000
std::string getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
Definition: ToolChains.h:207
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:734
const MultilibSet & getMultilibs() const
Get the whole MultilibSet.
Definition: ToolChains.h:125
llvm::DebuggerKind getDefaultDebuggerTuning() const override
Definition: ToolChains.h:594
CudaInstallationDetector CudaInstallation
Definition: ToolChains.h:212
llvm::DebuggerKind getDefaultDebuggerTuning() const override
Definition: ToolChains.h:1209
StringRef getLibDevicePath() const
Get the detected Cuda device library path.
Definition: ToolChains.h:205
bool SupportsObjCGC() const override
Does this tool chain support Objective-C garbage collection.
Definition: ToolChains.h:360
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:948
bool isValid() const
Check whether we detected a valid GCC install.
Definition: ToolChains.h:110
VersionTuple getTargetVersion() const
Definition: ToolChains.h:498
VersionTuple TargetVersion
The OS version we are targeting.
Definition: ToolChains.h:394
const Generic_GCC::CudaInstallationDetector & cudaInstallation() const
Definition: ToolChains.h:872
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: ToolChains.h:628
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag...
Definition: Multilib.h:26
bool IsUnwindTablesDefault() const override
IsUnwindTablesDefault - Does this tool chain use -funwind-tables by default.
Definition: ToolChains.h:793
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:757
bool GetDefaultStandaloneDebug() const override
Definition: ToolChains.h:773
virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Add the linker arguments to link the ARC runtime library.
Definition: ToolChains.h:279
bool UseObjCMixedDispatch() const override
UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the mixed dispatch method be use...
Definition: ToolChains.h:536
void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor, unsigned Micro) const
Definition: ToolChains.h:431
#define false
Definition: stdbool.h:33
bool isKernelStatic() const override
On some iOS platforms, kernel and kernel modules were built statically.
Definition: ToolChains.h:416
bool isTargetIOSBased() const
Is the target either iOS or an iOS simulator?
Definition: ToolChains.h:298
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: ToolChains.h:622
This is a class to find a viable GCC installation for Clang to use.
Definition: ToolChains.h:80
CudaVersion
Definition: Cuda.h:19
TCEToolChain - A tool chain using the llvm bitcode tools to perform all subcommands.
Definition: ToolChains.h:1015
bool operator>=(const GCCVersion &RHS) const
Definition: ToolChains.h:71
bool isTarget32Bit() const
Check whether the target triple's architecture is 32-bits.
Definition: ToolChains.h:239
unsigned GetDefaultDwarfVersion() const override
Definition: ToolChains.h:590
unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain (0=off...
Definition: ToolChains.h:742
virtual bool isKernelStatic() const
On some iOS platforms, kernel and kernel modules were built statically.
Definition: ToolChains.h:295
StringRef getLibPath() const
Get the detected Cuda library path.
Definition: ToolChains.h:203
LanaiToolChain(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition: ToolChains.h:922
StringRef getBinPath() const
Get the detected path to Cuda's bin directory.
Definition: ToolChains.h:199
DarwinPlatformKind TargetPlatform
Definition: ToolChains.h:391
uint64_t SanitizerMask
Definition: Sanitizers.h:24
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:341
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:1201
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:25
bool GetDefaultStandaloneDebug() const override
Definition: ToolChains.h:593
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
virtual void addMinVersionArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition: ToolChains.h:290
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:973
bool operator>(const GCCVersion &RHS) const
Definition: ToolChains.h:69
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:332
StringRef getIncludePath() const
Get the detected Cuda Include path.
Definition: ToolChains.h:201
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:1200
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:925
std::string Text
The unparsed text of the version.
Definition: ToolChains.h:52
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChains.h:785
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: ToolChains.h:867
bool isTarget64Bit() const
Check whether the target triple's architecture is 64-bits.
Definition: ToolChains.h:236
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: ToolChains.h:702
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChains.h:1083
CudaVersion version() const
Get the deteced Cuda install's version.
Definition: ToolChains.h:195
const GCCVersion & getVersion() const
Get the detected GCC version string.
Definition: ToolChains.h:132
bool isShaveCompilation(const llvm::Triple &T) const
Definition: ToolChains.h:1155
Generic_ELF(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition: ToolChains.h:610
bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const
Definition: ToolChains.h:509
bool operator<(const GCCVersion &RHS) const
Definition: ToolChains.h:66
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: ToolChains.h:716
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
bool isTargetWatchOSSimulator() const
Definition: ToolChains.h:481
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:786
bool UseObjCMixedDispatch() const override
UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the mixed dispatch method be use...
Definition: ToolChains.h:346
std::vector< std::string > ExtraOpts
Definition: ToolChains.h:847
int Major
The parsed major, minor, and patch numbers.
Definition: ToolChains.h:55
StringRef getParentLibPath() const
Get the detected GCC parent lib path.
Definition: ToolChains.h:119
bool IsObjCNonFragileABIDefault() const override
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChains.h:758
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:97
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:48
unsigned GetDefaultDwarfVersion() const override
Definition: ToolChains.h:721