clang  19.0.0git
ToolChain.h
Go to the documentation of this file.
1 //===- ToolChain.h - Collections of tools for one platform ------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
10 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H
11 
12 #include "clang/Basic/LLVM.h"
14 #include "clang/Basic/Sanitizers.h"
15 #include "clang/Driver/Action.h"
16 #include "clang/Driver/Multilib.h"
17 #include "clang/Driver/Types.h"
18 #include "llvm/ADT/APFloat.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/FloatingPointMode.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Frontend/Debug/Options.h"
24 #include "llvm/MC/MCTargetOptions.h"
25 #include "llvm/Option/Option.h"
26 #include "llvm/Support/VersionTuple.h"
27 #include "llvm/Target/TargetOptions.h"
28 #include "llvm/TargetParser/Triple.h"
29 #include <cassert>
30 #include <climits>
31 #include <memory>
32 #include <optional>
33 #include <string>
34 #include <utility>
35 
36 namespace llvm {
37 namespace opt {
38 
39 class Arg;
40 class ArgList;
41 class DerivedArgList;
42 
43 } // namespace opt
44 namespace vfs {
45 
46 class FileSystem;
47 
48 } // namespace vfs
49 } // namespace llvm
50 
51 namespace clang {
52 
53 class ObjCRuntime;
54 
55 namespace driver {
56 
57 class Driver;
58 class InputInfo;
59 class SanitizerArgs;
60 class Tool;
61 class XRayArgs;
62 
63 /// Helper structure used to pass information extracted from clang executable
64 /// name such as `i686-linux-android-g++`.
66  /// Target part of the executable name, as `i686-linux-android`.
67  std::string TargetPrefix;
68 
69  /// Driver mode part of the executable name, as `g++`.
70  std::string ModeSuffix;
71 
72  /// Corresponding driver mode argument, as '--driver-mode=g++'
73  const char *DriverMode = nullptr;
74 
75  /// True if TargetPrefix is recognized as a registered target name.
76  bool TargetIsValid = false;
77 
78  ParsedClangName() = default;
79  ParsedClangName(std::string Suffix, const char *Mode)
80  : ModeSuffix(Suffix), DriverMode(Mode) {}
81  ParsedClangName(std::string Target, std::string Suffix, const char *Mode,
82  bool IsRegistered)
83  : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
84  TargetIsValid(IsRegistered) {}
85 
86  bool isEmpty() const {
87  return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode == nullptr;
88  }
89 };
90 
91 /// ToolChain - Access to tools for a single platform.
92 class ToolChain {
93 public:
95 
99  };
100 
103  RLT_Libgcc
104  };
105 
109  UNW_Libgcc
110  };
111 
112  enum class UnwindTableLevel {
113  None,
114  Synchronous,
115  Asynchronous,
116  };
117 
118  enum RTTIMode {
121  };
122 
126  };
127 
129  std::string Path;
131  BitCodeLibraryInfo(StringRef Path, bool ShouldInternalize = true)
133  };
134 
136 
137 private:
139 
140  const Driver &D;
141  llvm::Triple Triple;
142  const llvm::opt::ArgList &Args;
143 
144  // We need to initialize CachedRTTIArg before CachedRTTIMode
145  const llvm::opt::Arg *const CachedRTTIArg;
146 
147  const RTTIMode CachedRTTIMode;
148 
149  const ExceptionsMode CachedExceptionsMode;
150 
151  /// The list of toolchain specific path prefixes to search for libraries.
152  path_list LibraryPaths;
153 
154  /// The list of toolchain specific path prefixes to search for files.
155  path_list FilePaths;
156 
157  /// The list of toolchain specific path prefixes to search for programs.
158  path_list ProgramPaths;
159 
160  mutable std::unique_ptr<Tool> Clang;
161  mutable std::unique_ptr<Tool> Flang;
162  mutable std::unique_ptr<Tool> Assemble;
163  mutable std::unique_ptr<Tool> Link;
164  mutable std::unique_ptr<Tool> StaticLibTool;
165  mutable std::unique_ptr<Tool> IfsMerge;
166  mutable std::unique_ptr<Tool> OffloadBundler;
167  mutable std::unique_ptr<Tool> OffloadWrapper;
168  mutable std::unique_ptr<Tool> OffloadPackager;
169  mutable std::unique_ptr<Tool> OffloadDeps;
170  mutable std::unique_ptr<Tool> SPIRVTranslator;
171  mutable std::unique_ptr<Tool> SYCLPostLink;
172  mutable std::unique_ptr<Tool> BackendCompiler;
173  mutable std::unique_ptr<Tool> AppendFooter;
174  mutable std::unique_ptr<Tool> FileTableTform;
175  mutable std::unique_ptr<Tool> SpirvToIrWrapper;
176  mutable std::unique_ptr<Tool> LinkerWrapper;
177 
178  Tool *getClang() const;
179  Tool *getFlang() const;
180  Tool *getAssemble() const;
181  Tool *getLink() const;
182  Tool *getStaticLibTool() const;
183  Tool *getIfsMerge() const;
184  Tool *getClangAs() const;
185  Tool *getOffloadBundler() const;
186  Tool *getOffloadWrapper() const;
187  Tool *getOffloadPackager() const;
188  Tool *getOffloadDeps() const;
189  Tool *getSPIRVTranslator() const;
190  Tool *getSYCLPostLink() const;
191  Tool *getBackendCompiler() const;
192  Tool *getAppendFooter() const;
193  Tool *getTableTform() const;
194  Tool *getSpirvToIrWrapper() const;
195  Tool *getLinkerWrapper() const;
196 
197  mutable bool SanitizerArgsChecked = false;
198  mutable std::unique_ptr<XRayArgs> XRayArguments;
199 
200  /// The effective clang triple for the current Job.
201  mutable llvm::Triple EffectiveTriple;
202 
203  /// Set the toolchain's effective clang triple.
204  void setEffectiveTriple(llvm::Triple ET) const {
205  EffectiveTriple = std::move(ET);
206  }
207 
208  std::optional<std::string>
209  getFallbackAndroidTargetPath(StringRef BaseDir) const;
210 
211  mutable std::optional<CXXStdlibType> cxxStdlibType;
212  mutable std::optional<RuntimeLibType> runtimeLibType;
213  mutable std::optional<UnwindLibType> unwindLibType;
214 
215 protected:
218 
219  ToolChain(const Driver &D, const llvm::Triple &T,
220  const llvm::opt::ArgList &Args);
221 
222  /// Executes the given \p Executable and returns the stdout.
224  executeToolChainProgram(StringRef Executable) const;
225 
226  void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
227 
228  virtual Tool *buildAssembler() const;
229  virtual Tool *buildLinker() const;
230  virtual Tool *buildBackendCompiler() const;
231  virtual Tool *buildStaticLibTool() const;
232  virtual Tool *getTool(Action::ActionClass AC) const;
233 
234  virtual std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args,
235  StringRef Component,
236  FileType Type,
237  bool AddArch) const;
238 
239  /// Find the target-specific subdirectory for the current target triple under
240  /// \p BaseDir, doing fallback triple searches as necessary.
241  /// \return The subdirectory path if it exists.
242  std::optional<std::string> getTargetSubDirPath(StringRef BaseDir) const;
243 
244  /// \name Utilities for implementing subclasses.
245  ///@{
246  static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
247  llvm::opt::ArgStringList &CC1Args,
248  const Twine &Path);
249  static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs,
250  llvm::opt::ArgStringList &CC1Args,
251  const Twine &Path);
252  static void
253  addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
254  llvm::opt::ArgStringList &CC1Args,
255  const Twine &Path);
256  static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
257  llvm::opt::ArgStringList &CC1Args,
258  ArrayRef<StringRef> Paths);
259 
260  static std::string concat(StringRef Path, const Twine &A, const Twine &B = "",
261  const Twine &C = "", const Twine &D = "");
262  ///@}
263 
264 public:
265  virtual ~ToolChain();
266 
267  // Accessors
268 
269  const Driver &getDriver() const { return D; }
270  llvm::vfs::FileSystem &getVFS() const;
271  const llvm::Triple &getTriple() const { return Triple; }
272 
273  /// Get the toolchain's aux triple, if it has one.
274  ///
275  /// Exactly what the aux triple represents depends on the toolchain, but for
276  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
277  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
278  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
279 
280  /// Some toolchains need to modify the file name, for example to replace the
281  /// extension for object files with .cubin for OpenMP offloading to Nvidia
282  /// GPUs.
283  virtual std::string getInputFilename(const InputInfo &Input) const;
284 
285  llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
286  StringRef getArchName() const { return Triple.getArchName(); }
287  StringRef getPlatform() const { return Triple.getVendorName(); }
288  StringRef getOS() const { return Triple.getOSName(); }
289 
290  /// Provide the default architecture name (as expected by -arch) for
291  /// this toolchain.
292  StringRef getDefaultUniversalArchName() const;
293 
294  std::string getTripleString() const {
295  return Triple.getTriple();
296  }
297 
298  /// Get the toolchain's effective clang triple.
299  const llvm::Triple &getEffectiveTriple() const {
300  assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
301  return EffectiveTriple;
302  }
303 
304  bool hasEffectiveTriple() const {
305  return !EffectiveTriple.getTriple().empty();
306  }
307 
308  path_list &getLibraryPaths() { return LibraryPaths; }
309  const path_list &getLibraryPaths() const { return LibraryPaths; }
310 
311  path_list &getFilePaths() { return FilePaths; }
312  const path_list &getFilePaths() const { return FilePaths; }
313 
314  path_list &getProgramPaths() { return ProgramPaths; }
315  const path_list &getProgramPaths() const { return ProgramPaths; }
316 
317  const MultilibSet &getMultilibs() const { return Multilibs; }
318 
320  return SelectedMultilibs;
321  }
322 
323  /// Get flags suitable for multilib selection, based on the provided clang
324  /// command line arguments. The command line arguments aren't suitable to be
325  /// used directly for multilib selection because they are not normalized and
326  /// normalization is a complex process. The result of this function is similar
327  /// to clang command line arguments except that the list of arguments is
328  /// incomplete. Only certain command line arguments are processed. If more
329  /// command line arguments are needed for multilib selection then this
330  /// function should be extended.
331  /// To allow users to find out what flags are returned, clang accepts a
332  /// -print-multi-flags-experimental argument.
333  Multilib::flags_list getMultilibFlags(const llvm::opt::ArgList &) const;
334 
335  SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const;
336 
337  const XRayArgs& getXRayArgs() const;
338 
339  // Returns the Arg * that explicitly turned on/off rtti, or nullptr.
340  const llvm::opt::Arg *getRTTIArg() const { return CachedRTTIArg; }
341 
342  // Returns the RTTIMode for the toolchain with the current arguments.
343  RTTIMode getRTTIMode() const { return CachedRTTIMode; }
344 
345  // Returns the ExceptionsMode for the toolchain with the current arguments.
346  ExceptionsMode getExceptionsMode() const { return CachedExceptionsMode; }
347 
348  /// Return any implicit target and/or mode flag for an invocation of
349  /// the compiler driver as `ProgName`.
350  ///
351  /// For example, when called with i686-linux-android-g++, the first element
352  /// of the return value will be set to `"i686-linux-android"` and the second
353  /// will be set to "--driver-mode=g++"`.
354  /// It is OK if the target name is not registered. In this case the return
355  /// value contains false in the field TargetIsValid.
356  ///
357  /// \pre `llvm::InitializeAllTargets()` has been called.
358  /// \param ProgName The name the Clang driver was invoked with (from,
359  /// e.g., argv[0]).
360  /// \return A structure of type ParsedClangName that contains the executable
361  /// name parts.
362  static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
363 
364  // Tool access.
365 
366  /// TranslateArgs - Create a new derived argument list for any argument
367  /// translations this ToolChain may wish to perform, or 0 if no tool chain
368  /// specific translations are needed. If \p DeviceOffloadKind is specified
369  /// the translation specific for that offload kind is performed.
370  ///
371  /// \param BoundArch - The bound architecture name, or 0.
372  /// \param DeviceOffloadKind - The device offload kind used for the
373  /// translation.
374  virtual llvm::opt::DerivedArgList *
375  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
376  Action::OffloadKind DeviceOffloadKind) const {
377  return nullptr;
378  }
379 
380  /// TranslateOffloadTargetArgs - Create a new derived argument list for
381  /// that contains the Offload target specific flags passed via
382  /// -Xopenmp-target -opt=val OR -Xopenmp-target=<triple> -opt=val
383  /// Also handles -Xsycl-target OR -Xsycl-target=<triple>
384  virtual llvm::opt::DerivedArgList *TranslateOffloadTargetArgs(
385  const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,
386  SmallVectorImpl<llvm::opt::Arg *> &AllocatedArgs,
387  Action::OffloadKind DeviceOffloadKind) const;
388 
389  /// Append the argument following \p A to \p DAL assuming \p A is an Xarch
390  /// argument. If \p AllocatedArgs is null pointer, synthesized arguments are
391  /// added to \p DAL, otherwise they are appended to \p AllocatedArgs.
392  virtual void TranslateXarchArgs(
393  const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
394  llvm::opt::DerivedArgList *DAL,
395  SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs = nullptr) const;
396 
397  /// Translate -Xarch_ arguments. If there are no such arguments, return
398  /// a null pointer, otherwise return a DerivedArgList containing the
399  /// translated arguments.
400  virtual llvm::opt::DerivedArgList *
401  TranslateXarchArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
402  Action::OffloadKind DeviceOffloadKind,
403  SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs) const;
404 
405  /// Choose a tool to use to handle the action \p JA.
406  ///
407  /// This can be overridden when a particular ToolChain needs to use
408  /// a compiler other than Clang.
409  virtual Tool *SelectTool(const JobAction &JA) const;
410 
411  // Helper methods
412 
413  std::string GetFilePath(const char *Name) const;
414  std::string GetProgramPath(const char *Name) const;
415 
416  /// Returns the linker path, respecting the -fuse-ld= argument to determine
417  /// the linker suffix or name.
418  /// If LinkerIsLLD is non-nullptr, it is set to true if the returned linker
419  /// is LLD. If it's set, it can be assumed that the linker is LLD built
420  /// at the same revision as clang, and clang can make assumptions about
421  /// LLD's supported flags, error output, etc.
422  std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const;
423 
424  /// Returns the linker path for emitting a static library.
425  std::string GetStaticLibToolPath() const;
426 
427  /// Dispatch to the specific toolchain for verbose printing.
428  ///
429  /// This is used when handling the verbose option to print detailed,
430  /// toolchain-specific information useful for understanding the behavior of
431  /// the driver on a specific platform.
432  virtual void printVerboseInfo(raw_ostream &OS) const {}
433 
434  // Platform defaults information
435 
436  /// Returns true if the toolchain is targeting a non-native
437  /// architecture.
438  virtual bool isCrossCompiling() const;
439 
440  /// HasNativeLTOLinker - Check whether the linker and related tools have
441  /// native LLVM support.
442  virtual bool HasNativeLLVMSupport() const;
443 
444  /// LookupTypeForExtension - Return the default language type to use for the
445  /// given extension.
446  virtual types::ID LookupTypeForExtension(StringRef Ext) const;
447 
448  /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
449  virtual bool IsBlocksDefault() const { return false; }
450 
451  /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
452  /// by default.
453  virtual bool IsIntegratedAssemblerDefault() const { return true; }
454 
455  /// IsIntegratedBackendDefault - Does this tool chain enable
456  /// -fintegrated-objemitter by default.
457  virtual bool IsIntegratedBackendDefault() const { return true; }
458 
459  /// IsIntegratedBackendSupported - Does this tool chain support
460  /// -fintegrated-objemitter.
461  virtual bool IsIntegratedBackendSupported() const { return true; }
462 
463  /// IsNonIntegratedBackendSupported - Does this tool chain support
464  /// -fno-integrated-objemitter.
465  virtual bool IsNonIntegratedBackendSupported() const { return false; }
466 
467  /// Check if the toolchain should use the integrated assembler.
468  virtual bool useIntegratedAs() const;
469 
470  /// Check if the toolchain should use the integrated backend.
471  virtual bool useIntegratedBackend() const;
472 
473  /// Check if the toolchain should use AsmParser to parse inlineAsm when
474  /// integrated assembler is not default.
475  virtual bool parseInlineAsmUsingAsmParser() const { return false; }
476 
477  /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
478  virtual bool IsMathErrnoDefault() const { return true; }
479 
480  /// IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable
481  /// -fencode-extended-block-signature by default.
482  virtual bool IsEncodeExtendedBlockSignatureDefault() const { return false; }
483 
484  /// IsObjCNonFragileABIDefault - Does this tool chain set
485  /// -fobjc-nonfragile-abi by default.
486  virtual bool IsObjCNonFragileABIDefault() const { return false; }
487 
488  /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
489  /// mixed dispatch method be used?
490  virtual bool UseObjCMixedDispatch() const { return false; }
491 
492  /// Check whether to enable x86 relax relocations by default.
493  virtual bool useRelaxRelocations() const;
494 
495  /// Check whether use IEEE binary128 as long double format by default.
496  bool defaultToIEEELongDouble() const;
497 
498  /// GetDefaultStackProtectorLevel - Get the default stack protector level for
499  /// this tool chain.
501  GetDefaultStackProtectorLevel(bool KernelOrKext) const {
502  return LangOptions::SSPOff;
503  }
504 
505  /// Get the default trivial automatic variable initialization.
509  }
510 
511  /// GetDefaultLinker - Get the default linker to use.
512  virtual const char *getDefaultLinker() const { return "ld"; }
513 
514  /// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
516  return ToolChain::RLT_Libgcc;
517  }
518 
521  }
522 
524  return ToolChain::UNW_None;
525  }
526 
527  virtual std::string getCompilerRTPath() const;
528 
529  virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
530  StringRef Component,
532 
533  const char *
534  getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component,
536 
537  std::string getCompilerRTBasename(const llvm::opt::ArgList &Args,
538  StringRef Component,
540 
541  // Returns the target specific runtime path if it exists.
542  std::optional<std::string> getRuntimePath() const;
543 
544  // Returns target specific standard library path if it exists.
545  std::optional<std::string> getStdlibPath() const;
546 
547  // Returns <ResourceDir>/lib/<OSName>/<arch> or <ResourceDir>/lib/<triple>.
548  // This is used by runtimes (such as OpenMP) to find arch-specific libraries.
549  virtual path_list getArchSpecificLibPaths() const;
550 
551  // Returns <OSname> part of above.
552  virtual StringRef getOSLibName() const;
553 
554  /// needsProfileRT - returns true if instrumentation profile is on.
555  static bool needsProfileRT(const llvm::opt::ArgList &Args);
556 
557  /// Returns true if gcov instrumentation (-fprofile-arcs or --coverage) is on.
558  static bool needsGCovInstrumentation(const llvm::opt::ArgList &Args);
559 
560  /// How detailed should the unwind tables be by default.
561  virtual UnwindTableLevel
562  getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const;
563 
564  /// Test whether this toolchain supports outline atomics by default.
565  virtual bool
566  IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const {
567  return false;
568  }
569 
570  /// Test whether this toolchain defaults to PIC.
571  virtual bool isPICDefault() const = 0;
572 
573  /// Test whether this toolchain defaults to PIE.
574  virtual bool isPIEDefault(const llvm::opt::ArgList &Args) const = 0;
575 
576  /// Tests whether this toolchain forces its default for PIC, PIE or
577  /// non-PIC. If this returns true, any PIC related flags should be ignored
578  /// and instead the results of \c isPICDefault() and \c isPIEDefault(const
579  /// llvm::opt::ArgList &Args) are used exclusively.
580  virtual bool isPICDefaultForced() const = 0;
581 
582  /// SupportsProfiling - Does this tool chain support -pg.
583  virtual bool SupportsProfiling() const { return true; }
584 
585  /// Complain if this tool chain doesn't support Objective-C ARC.
586  virtual void CheckObjCARC() const {}
587 
588  /// Get the default debug info format. Typically, this is DWARF.
589  virtual llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const {
590  return llvm::codegenoptions::DIF_DWARF;
591  }
592 
593  /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
594  /// compile unit information.
595  virtual bool UseDwarfDebugFlags() const { return false; }
596 
597  /// Add an additional -fdebug-prefix-map entry.
598  virtual std::string GetGlobalDebugPathRemapping() const { return {}; }
599 
600  // Return the DWARF version to emit, in the absence of arguments
601  // to the contrary.
602  virtual unsigned GetDefaultDwarfVersion() const { return 5; }
603 
604  // Some toolchains may have different restrictions on the DWARF version and
605  // may need to adjust it. E.g. NVPTX may need to enforce DWARF2 even when host
606  // compilation uses DWARF5.
607  virtual unsigned getMaxDwarfVersion() const { return UINT_MAX; }
608 
609  // True if the driver should assume "-fstandalone-debug"
610  // in the absence of an option specifying otherwise,
611  // provided that debugging was requested in the first place.
612  // i.e. a value of 'true' does not imply that debugging is wanted.
613  virtual bool GetDefaultStandaloneDebug() const { return false; }
614 
615  // Return the default debugger "tuning."
616  virtual llvm::DebuggerKind getDefaultDebuggerTuning() const {
617  return llvm::DebuggerKind::GDB;
618  }
619 
620  /// Does this toolchain supports given debug info option or not.
621  virtual bool supportsDebugInfoOption(const llvm::opt::Arg *) const {
622  return true;
623  }
624 
625  /// Adjust debug information kind considering all passed options.
626  virtual void
627  adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
628  const llvm::opt::ArgList &Args) const {}
629 
630  /// GetExceptionModel - Return the tool chain exception model.
631  virtual llvm::ExceptionHandling
632  GetExceptionModel(const llvm::opt::ArgList &Args) const;
633 
634  /// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
635  virtual bool SupportsEmbeddedBitcode() const { return false; }
636 
637  /// getThreadModel() - Which thread model does this target use?
638  virtual std::string getThreadModel() const { return "posix"; }
639 
640  /// isThreadModelSupported() - Does this target support a thread model?
641  virtual bool isThreadModelSupported(const StringRef Model) const;
642 
643  /// isBareMetal - Is this a bare metal target.
644  virtual bool isBareMetal() const { return false; }
645 
646  virtual std::string getMultiarchTriple(const Driver &D,
647  const llvm::Triple &TargetTriple,
648  StringRef SysRoot) const {
649  return TargetTriple.str();
650  }
651 
652  /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
653  /// command line arguments into account.
654  virtual std::string
655  ComputeLLVMTriple(const llvm::opt::ArgList &Args,
656  types::ID InputType = types::TY_INVALID) const;
657 
658  /// ComputeEffectiveClangTriple - Return the Clang triple to use for this
659  /// target, which may take into account the command line arguments. For
660  /// example, on Darwin the -mmacosx-version-min= command line argument (which
661  /// sets the deployment target) determines the version in the triple passed to
662  /// Clang.
663  virtual std::string ComputeEffectiveClangTriple(
664  const llvm::opt::ArgList &Args,
665  types::ID InputType = types::TY_INVALID) const;
666 
667  /// getDefaultObjCRuntime - Return the default Objective-C runtime
668  /// for this platform.
669  ///
670  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
671  virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const;
672 
673  /// hasBlocksRuntime - Given that the user is compiling with
674  /// -fblocks, does this tool chain guarantee the existence of a
675  /// blocks runtime?
676  ///
677  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
678  virtual bool hasBlocksRuntime() const { return true; }
679 
680  /// Return the sysroot, possibly searching for a default sysroot using
681  /// target-specific logic.
682  virtual std::string computeSysRoot() const;
683 
684  /// Add the clang cc1 arguments for system include paths.
685  ///
686  /// This routine is responsible for adding the necessary cc1 arguments to
687  /// include headers from standard system header directories.
688  virtual void
689  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
690  llvm::opt::ArgStringList &CC1Args) const;
691 
692  /// Add options that need to be passed to cc1 for this target.
693  virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
694  llvm::opt::ArgStringList &CC1Args,
695  Action::OffloadKind DeviceOffloadKind) const;
696 
697  /// Add options that need to be passed to cc1as for this target.
698  virtual void
699  addClangCC1ASTargetOptions(const llvm::opt::ArgList &Args,
700  llvm::opt::ArgStringList &CC1ASArgs) const;
701 
702  /// Add warning options that need to be passed to cc1 for this target.
703  virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
704 
705  // GetRuntimeLibType - Determine the runtime library type to use with the
706  // given compilation arguments.
707  virtual RuntimeLibType
708  GetRuntimeLibType(const llvm::opt::ArgList &Args) const;
709 
710  // GetCXXStdlibType - Determine the C++ standard library type to use with the
711  // given compilation arguments.
712  virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
713 
714  // GetUnwindLibType - Determine the unwind library type to use with the
715  // given compilation arguments.
716  virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const;
717 
718  // Detect the highest available version of libc++ in include path.
719  virtual std::string detectLibcxxVersion(StringRef IncludePath) const;
720 
721  /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
722  /// the include paths to use for the given C++ standard library type.
723  virtual void
724  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
725  llvm::opt::ArgStringList &CC1Args) const;
726 
727  /// AddClangCXXStdlibIsystemArgs - Add the clang -cc1 level arguments to set
728  /// the specified include paths for the C++ standard library.
729  void AddClangCXXStdlibIsystemArgs(const llvm::opt::ArgList &DriverArgs,
730  llvm::opt::ArgStringList &CC1Args) const;
731 
732  /// Returns if the C++ standard library should be linked in.
733  /// Note that e.g. -lm should still be linked even if this returns false.
734  bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const;
735 
736  /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
737  /// for the given C++ standard library type.
738  virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
739  llvm::opt::ArgStringList &CmdArgs) const;
740 
741  /// AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
742  void AddFilePathLibArgs(const llvm::opt::ArgList &Args,
743  llvm::opt::ArgStringList &CmdArgs) const;
744 
745  /// AddCCKextLibArgs - Add the system specific linker arguments to use
746  /// for kernel extensions (Darwin-specific).
747  virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
748  llvm::opt::ArgStringList &CmdArgs) const;
749 
750  /// If a runtime library exists that sets global flags for unsafe floating
751  /// point math, return true.
752  ///
753  /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
754  virtual bool isFastMathRuntimeAvailable(
755  const llvm::opt::ArgList &Args, std::string &Path) const;
756 
757  /// AddFastMathRuntimeIfAvailable - If a runtime library exists that sets
758  /// global flags for unsafe floating point math, add it and return true.
759  ///
760  /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
762  const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
763 
764  /// getSystemGPUArchs - Use a tool to detect the user's availible GPUs.
766  getSystemGPUArchs(const llvm::opt::ArgList &Args) const;
767 
768  /// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
769  /// a suitable profile runtime library to the linker.
770  virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
771  llvm::opt::ArgStringList &CmdArgs) const;
772 
773  /// Add arguments to use system-specific CUDA includes.
774  virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
775  llvm::opt::ArgStringList &CC1Args) const;
776 
777  /// Add arguments to use system-specific HIP includes.
778  virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
779  llvm::opt::ArgStringList &CC1Args) const;
780 
781  /// Add arguments to use MCU GCC toolchain includes.
782  virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
783  llvm::opt::ArgStringList &CC1Args) const;
784 
785  /// On Windows, returns the MSVC compatibility version.
786  virtual VersionTuple computeMSVCVersion(const Driver *D,
787  const llvm::opt::ArgList &Args) const;
788 
789  /// Get paths for device libraries.
791  getDeviceLibs(const llvm::opt::ArgList &Args,
792  const Action::OffloadKind DeviceOffloadingKind) const;
793 
794  /// Add the system specific linker arguments to use
795  /// for the given HIP runtime library type.
796  virtual void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args,
797  llvm::opt::ArgStringList &CmdArgs) const {}
798 
799  /// Return sanitizers which are available in this toolchain.
800  virtual SanitizerMask getSupportedSanitizers() const;
801 
802  /// Return sanitizers which are enabled by default.
804  return SanitizerMask();
805  }
806 
807  /// Returns true when it's possible to split LTO unit to use whole
808  /// program devirtualization and CFI santiizers.
809  virtual bool canSplitThinLTOUnit() const { return true; }
810 
811  /// Returns the output denormal handling type in the default floating point
812  /// environment for the given \p FPType if given. Otherwise, the default
813  /// assumed mode for any floating point type.
814  virtual llvm::DenormalMode getDefaultDenormalModeForType(
815  const llvm::opt::ArgList &DriverArgs, const JobAction &JA,
816  const llvm::fltSemantics *FPType = nullptr) const {
817  return llvm::DenormalMode::getIEEE();
818  }
819 
820  // We want to expand the shortened versions of the triples passed in to
821  // the values used for the bitcode libraries.
822  static llvm::Triple getOpenMPTriple(StringRef TripleStr) {
823  llvm::Triple TT(TripleStr);
824  if (TT.getVendor() == llvm::Triple::UnknownVendor ||
825  TT.getOS() == llvm::Triple::UnknownOS) {
826  if (TT.getArch() == llvm::Triple::nvptx)
827  return llvm::Triple("nvptx-nvidia-cuda");
828  if (TT.getArch() == llvm::Triple::nvptx64)
829  return llvm::Triple("nvptx64-nvidia-cuda");
830  if (TT.getArch() == llvm::Triple::amdgcn)
831  return llvm::Triple("amdgcn-amd-amdhsa");
832  }
833  return TT;
834  }
835 };
836 
837 /// Set a ToolChain's effective triple. Reset it when the registration object
838 /// is destroyed.
840  const ToolChain &TC;
841 
842 public:
843  RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
844  TC.setEffectiveTriple(std::move(T));
845  }
846 
847  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
848 };
849 
850 } // namespace driver
851 
852 } // namespace clang
853 
854 #endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H
const Environment & Env
Definition: HTMLLogger.cpp:148
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::raw_ostream & OS
Definition: Logger.cpp:24
llvm::MachO::FileType FileType
Definition: MachO.h:45
llvm::MachO::Target Target
Definition: MachO.h:50
Defines the clang::SanitizerKind enum.
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:28
The base class of the type hierarchy.
Definition: Type.h:1813
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
See also MultilibSetBuilder for combining multilibs into a set.
Definition: Multilib.h:92
std::vector< std::string > flags_list
Definition: Multilib.h:34
Set a ToolChain's effective triple.
Definition: ToolChain.h:839
RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)
Definition: ToolChain.h:843
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
virtual bool isFastMathRuntimeAvailable(const llvm::opt::ArgList &Args, std::string &Path) const
If a runtime library exists that sets global flags for unsafe floating point math,...
Definition: ToolChain.cpp:1386
virtual std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, types::ID InputType=types::TY_INVALID) const
ComputeEffectiveClangTriple - Return the Clang triple to use for this target, which may take into acc...
Definition: ToolChain.cpp:1128
virtual Tool * buildBackendCompiler() const
Definition: ToolChain.cpp:477
const Driver & getDriver() const
Definition: ToolChain.h:269
virtual std::string GetGlobalDebugPathRemapping() const
Add an additional -fdebug-prefix-map entry.
Definition: ToolChain.h:598
virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddCCKextLibArgs - Add the system specific linker arguments to use for kernel extensions (Darwin-spec...
Definition: ToolChain.cpp:1381
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const
Add warning options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:1149
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory to CC1 arguments.
Definition: ToolChain.cpp:1247
virtual unsigned getMaxDwarfVersion() const
Definition: ToolChain.h:607
const llvm::opt::Arg * getRTTIArg() const
Definition: ToolChain.h:340
virtual llvm::opt::DerivedArgList * TranslateOffloadTargetArgs(const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost, SmallVectorImpl< llvm::opt::Arg * > &AllocatedArgs, Action::OffloadKind DeviceOffloadKind) const
TranslateOffloadTargetArgs - Create a new derived argument list for that contains the Offload target ...
Definition: ToolChain.cpp:1533
virtual void adjustDebugInfoKind(llvm::codegenoptions::DebugInfoKind &DebugInfoKind, const llvm::opt::ArgList &Args) const
Adjust debug information kind considering all passed options.
Definition: ToolChain.h:627
path_list & getFilePaths()
Definition: ToolChain.h:311
virtual std::string computeSysRoot() const
Return the sysroot, possibly searching for a default sysroot using target-specific logic.
Definition: ToolChain.cpp:1133
virtual bool useIntegratedAs() const
Check if the toolchain should use the integrated assembler.
Definition: ToolChain.cpp:146
virtual void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Add the system specific linker arguments to use for the given HIP runtime library type.
Definition: ToolChain.h:796
static llvm::Triple getOpenMPTriple(StringRef TripleStr)
Definition: ToolChain.h:822
virtual llvm::DenormalMode getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs, const JobAction &JA, const llvm::fltSemantics *FPType=nullptr) const
Returns the output denormal handling type in the default floating point environment for the given FPT...
Definition: ToolChain.h:814
std::optional< std::string > getStdlibPath() const
Definition: ToolChain.cpp:886
virtual unsigned GetDefaultDwarfVersion() const
Definition: ToolChain.h:602
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1159
virtual UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const
How detailed should the unwind tables be by default.
Definition: ToolChain.cpp:453
const char * getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:782
bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const
Returns if the C++ standard library should be linked in.
Definition: ToolChain.cpp:1349
static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory with extern "C" semantics to CC1 arguments.
Definition: ToolChain.cpp:1262
virtual std::string getInputFilename(const InputInfo &Input) const
Some toolchains need to modify the file name, for example to replace the extension for object files w...
Definition: ToolChain.cpp:448
virtual Tool * buildStaticLibTool() const
Definition: ToolChain.cpp:481
virtual bool IsIntegratedBackendSupported() const
IsIntegratedBackendSupported - Does this tool chain support -fintegrated-objemitter.
Definition: ToolChain.h:461
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:938
virtual llvm::codegenoptions::DebugInfoFormat getDefaultDebugFormat() const
Get the default debug info format. Typically, this is DWARF.
Definition: ToolChain.h:589
virtual Tool * SelectTool(const JobAction &JA) const
Choose a tool to use to handle the action JA.
Definition: ToolChain.cpp:928
path_list & getLibraryPaths()
Definition: ToolChain.h:308
virtual bool supportsDebugInfoOption(const llvm::opt::Arg *) const
Does this toolchain supports given debug info option or not.
Definition: ToolChain.h:621
static bool needsProfileRT(const llvm::opt::ArgList &Args)
needsProfileRT - returns true if instrumentation profile is on.
Definition: ToolChain.cpp:908
StringRef getOS() const
Definition: ToolChain.h:288
virtual bool IsObjCNonFragileABIDefault() const
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChain.h:486
virtual bool isBareMetal() const
isBareMetal - Is this a bare metal target.
Definition: ToolChain.h:644
virtual bool isThreadModelSupported(const StringRef Model) const
isThreadModelSupported() - Does this target support a thread model?
Definition: ToolChain.cpp:1067
const MultilibSet & getMultilibs() const
Definition: ToolChain.h:317
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:285
virtual llvm::opt::DerivedArgList * TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind) const
TranslateArgs - Create a new derived argument list for any argument translations this ToolChain may w...
Definition: ToolChain.h:375
const path_list & getProgramPaths() const
Definition: ToolChain.h:315
const llvm::Triple & getTriple() const
Definition: ToolChain.h:271
virtual std::string detectLibcxxVersion(StringRef IncludePath) const
Definition: ToolChain.cpp:1294
static std::string concat(StringRef Path, const Twine &A, const Twine &B="", const Twine &C="", const Twine &D="")
Definition: ToolChain.cpp:1286
RTTIMode getRTTIMode() const
Definition: ToolChain.h:343
ExceptionsMode getExceptionsMode() const
Definition: ToolChain.h:346
llvm::vfs::FileSystem & getVFS() const
Definition: ToolChain.cpp:142
Multilib::flags_list getMultilibFlags(const llvm::opt::ArgList &) const
Get flags suitable for multilib selection, based on the provided clang command line arguments.
Definition: ToolChain.cpp:259
static bool needsGCovInstrumentation(const llvm::opt::ArgList &Args)
Returns true if gcov instrumentation (-fprofile-arcs or –coverage) is on.
Definition: ToolChain.cpp:922
virtual void printVerboseInfo(raw_ostream &OS) const
Dispatch to the specific toolchain for verbose printing.
Definition: ToolChain.h:432
virtual std::string ComputeLLVMTriple(const llvm::opt::ArgList &Args, types::ID InputType=types::TY_INVALID) const
ComputeLLVMTriple - Return the LLVM target triple to use, after taking command line arguments into ac...
Definition: ToolChain.cpp:1080
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition: ToolChain.cpp:89
const XRayArgs & getXRayArgs() const
Definition: ToolChain.cpp:307
virtual llvm::DebuggerKind getDefaultDebuggerTuning() const
Definition: ToolChain.h:616
virtual bool isPIEDefault(const llvm::opt::ArgList &Args) const =0
Test whether this toolchain defaults to PIE.
virtual bool SupportsEmbeddedBitcode() const
SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
Definition: ToolChain.h:635
const path_list & getFilePaths() const
Definition: ToolChain.h:312
virtual bool isPICDefaultForced() const =0
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
void AddClangCXXStdlibIsystemArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
AddClangCXXStdlibIsystemArgs - Add the clang -cc1 level arguments to set the specified include paths ...
Definition: ToolChain.cpp:1331
bool addFastMathRuntimeIfAvailable(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFastMathRuntimeIfAvailable - If a runtime library exists that sets global flags for unsafe floatin...
Definition: ToolChain.cpp:1422
static void addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Definition: ToolChain.cpp:1269
bool hasEffectiveTriple() const
Definition: ToolChain.h:304
virtual bool useIntegratedBackend() const
Check if the toolchain should use the integrated backend.
Definition: ToolChain.cpp:152
virtual LangOptions::TrivialAutoVarInitKind GetDefaultTrivialAutoVarInit() const
Get the default trivial automatic variable initialization.
Definition: ToolChain.h:507
std::string GetStaticLibToolPath() const
Returns the linker path for emitting a static library.
Definition: ToolChain.cpp:1018
virtual llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const
GetExceptionModel - Return the tool chain exception model.
Definition: ToolChain.cpp:1063
virtual bool IsMathErrnoDefault() const
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChain.h:478
virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddCXXStdlibLibArgs - Add the system specific linker arguments to use for the given C++ standard libr...
Definition: ToolChain.cpp:1355
const path_list & getLibraryPaths() const
Definition: ToolChain.h:309
static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName)
Return any implicit target and/or mode flag for an invocation of the compiler driver as ProgName.
Definition: ToolChain.cpp:399
const llvm::Triple & getEffectiveTriple() const
Get the toolchain's effective clang triple.
Definition: ToolChain.h:299
virtual bool IsIntegratedBackendDefault() const
IsIntegratedBackendDefault - Does this tool chain enable -fintegrated-objemitter by default.
Definition: ToolChain.h:457
virtual std::string getThreadModel() const
getThreadModel() - Which thread model does this target use?
Definition: ToolChain.h:638
virtual bool GetDefaultStandaloneDebug() const
Definition: ToolChain.h:613
virtual Tool * buildLinker() const
Definition: ToolChain.cpp:473
bool defaultToIEEELongDouble() const
Check whether use IEEE binary128 as long double format by default.
Definition: ToolChain.cpp:184
virtual types::ID LookupTypeForExtension(StringRef Ext) const
LookupTypeForExtension - Return the default language type to use for the given extension.
Definition: ToolChain.cpp:1025
virtual bool HasNativeLLVMSupport() const
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: ToolChain.cpp:1037
virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1185
std::optional< std::string > getTargetSubDirPath(StringRef BaseDir) const
Find the target-specific subdirectory for the current target triple under BaseDir,...
Definition: ToolChain.cpp:833
virtual void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass a suitable profile runtime ...
Definition: ToolChain.cpp:1151
virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use system-specific CUDA includes.
Definition: ToolChain.cpp:1463
virtual std::string getCompilerRTPath() const
Definition: ToolChain.cpp:695
virtual std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args, StringRef Component, FileType Type, bool AddArch) const
Definition: ToolChain.cpp:717
std::string GetLinkerPath(bool *LinkerIsLLD=nullptr) const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name.
Definition: ToolChain.cpp:946
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:751
virtual Expected< SmallVector< std::string > > getSystemGPUArchs(const llvm::opt::ArgList &Args) const
getSystemGPUArchs - Use a tool to detect the user's availible GPUs.
Definition: ToolChain.cpp:1434
std::string GetProgramPath(const char *Name) const
Definition: ToolChain.cpp:942
virtual LangOptions::StackProtectorMode GetDefaultStackProtectorLevel(bool KernelOrKext) const
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain.
Definition: ToolChain.h:501
virtual bool hasBlocksRuntime() const
hasBlocksRuntime - Given that the user is compiling with -fblocks, does this tool chain guarantee the...
Definition: ToolChain.h:678
virtual bool UseDwarfDebugFlags() const
UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf compile unit information.
Definition: ToolChain.h:595
static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, ArrayRef< StringRef > Paths)
Utility function to add a list of system include directories to CC1.
Definition: ToolChain.cpp:1277
virtual bool SupportsProfiling() const
SupportsProfiling - Does this tool chain support -pg.
Definition: ToolChain.h:583
virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use system-specific HIP includes.
Definition: ToolChain.cpp:1466
virtual bool canSplitThinLTOUnit() const
Returns true when it's possible to split LTO unit to use whole program devirtualization and CFI santi...
Definition: ToolChain.h:809
virtual void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: ToolChain.cpp:1317
virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const
On Windows, returns the MSVC compatibility version.
Definition: ToolChain.cpp:1493
virtual StringRef getOSLibName() const
Definition: ToolChain.cpp:675
virtual bool UseObjCMixedDispatch() const
UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the mixed dispatch method be use...
Definition: ToolChain.h:490
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use MCU GCC toolchain includes.
Definition: ToolChain.cpp:1476
virtual CXXStdlibType GetDefaultCXXStdlibType() const
Definition: ToolChain.h:519
void AddFilePathLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
Definition: ToolChain.cpp:1374
std::string getTripleString() const
Definition: ToolChain.h:294
virtual RuntimeLibType GetDefaultRuntimeLibType() const
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: ToolChain.h:515
StringRef getDefaultUniversalArchName() const
Provide the default architecture name (as expected by -arch) for this toolchain.
Definition: ToolChain.cpp:423
virtual const llvm::Triple * getAuxTriple() const
Get the toolchain's aux triple, if it has one.
Definition: ToolChain.h:278
virtual Tool * buildAssembler() const
Definition: ToolChain.cpp:469
void setTripleEnvironment(llvm::Triple::EnvironmentType Env)
Definition: ToolChain.cpp:134
virtual void addClangCC1ASTargetOptions(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1ASArgs) const
Add options that need to be passed to cc1as for this target.
Definition: ToolChain.cpp:1146
virtual bool IsIntegratedAssemblerDefault() const
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChain.h:453
path_list & getProgramPaths()
Definition: ToolChain.h:314
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const
Definition: ToolChain.cpp:301
virtual llvm::SmallVector< BitCodeLibraryInfo, 12 > getDeviceLibs(const llvm::opt::ArgList &Args, const Action::OffloadKind DeviceOffloadingKind) const
Get paths for device libraries.
Definition: ToolChain.cpp:1470
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1221
llvm::SmallVector< Multilib > SelectedMultilibs
Definition: ToolChain.h:217
virtual void CheckObjCARC() const
Complain if this tool chain doesn't support Objective-C ARC.
Definition: ToolChain.h:586
virtual bool IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const
Test whether this toolchain supports outline atomics by default.
Definition: ToolChain.h:566
llvm::Expected< std::unique_ptr< llvm::MemoryBuffer > > executeToolChainProgram(StringRef Executable) const
Executes the given Executable and returns the stdout.
Definition: ToolChain.cpp:108
virtual const char * getDefaultLinker() const
GetDefaultLinker - Get the default linker to use.
Definition: ToolChain.h:512
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const
Add options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:1142
virtual void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add the clang cc1 arguments for system include paths.
Definition: ToolChain.cpp:1137
virtual UnwindLibType GetDefaultUnwindLibType() const
Definition: ToolChain.h:523
std::optional< std::string > getRuntimePath() const
Definition: ToolChain.cpp:874
virtual Tool * getTool(Action::ActionClass AC) const
Definition: ToolChain.cpp:581
virtual bool IsEncodeExtendedBlockSignatureDefault() const
IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable -fencode-extended-block-signature...
Definition: ToolChain.h:482
const llvm::SmallVector< Multilib > & getSelectedMultilibs() const
Definition: ToolChain.h:319
StringRef getPlatform() const
Definition: ToolChain.h:287
virtual bool IsBlocksDefault() const
IsBlocksDefault - Does this tool chain enable -fblocks by default.
Definition: ToolChain.h:449
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1438
virtual path_list getArchSpecificLibPaths() const
Definition: ToolChain.cpp:892
virtual std::string getMultiarchTriple(const Driver &D, const llvm::Triple &TargetTriple, StringRef SysRoot) const
Definition: ToolChain.h:646
virtual bool isCrossCompiling() const
Returns true if the toolchain is targeting a non-native architecture.
Definition: ToolChain.cpp:1041
std::string getCompilerRTBasename(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:710
virtual bool IsNonIntegratedBackendSupported() const
IsNonIntegratedBackendSupported - Does this tool chain support -fno-integrated-objemitter.
Definition: ToolChain.h:465
virtual SanitizerMask getDefaultSanitizers() const
Return sanitizers which are enabled by default.
Definition: ToolChain.h:803
virtual void TranslateXarchArgs(const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A, llvm::opt::DerivedArgList *DAL, SmallVectorImpl< llvm::opt::Arg * > *AllocatedArgs=nullptr) const
Append the argument following A to DAL assuming A is an Xarch argument.
Definition: ToolChain.cpp:1672
virtual bool useRelaxRelocations() const
Check whether to enable x86 relax relocations by default.
Definition: ToolChain.cpp:180
virtual bool isPICDefault() const =0
Test whether this toolchain defaults to PIC.
StringRef getArchName() const
Definition: ToolChain.h:286
virtual bool parseInlineAsmUsingAsmParser() const
Check if the toolchain should use AsmParser to parse inlineAsm when integrated assembler is not defau...
Definition: ToolChain.h:475
SmallVector< std::string, 16 > path_list
Definition: ToolChain.h:94
virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const
getDefaultObjCRuntime - Return the default Objective-C runtime for this platform.
Definition: ToolChain.cpp:1057
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
#define UINT_MAX
Definition: limits.h:64
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Definition: ToolChain.h:65
ParsedClangName(std::string Suffix, const char *Mode)
Definition: ToolChain.h:79
const char * DriverMode
Corresponding driver mode argument, as '–driver-mode=g++'.
Definition: ToolChain.h:73
std::string ModeSuffix
Driver mode part of the executable name, as g++.
Definition: ToolChain.h:70
std::string TargetPrefix
Target part of the executable name, as i686-linux-android.
Definition: ToolChain.h:67
bool TargetIsValid
True if TargetPrefix is recognized as a registered target name.
Definition: ToolChain.h:76
ParsedClangName(std::string Target, std::string Suffix, const char *Mode, bool IsRegistered)
Definition: ToolChain.h:81
BitCodeLibraryInfo(StringRef Path, bool ShouldInternalize=true)
Definition: ToolChain.h:131