clang  5.0.0
ToolChain.h
Go to the documentation of this file.
1 //===--- ToolChain.h - Collections of tools for one platform ----*- 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_DRIVER_TOOLCHAIN_H
11 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H
12 
13 #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 "clang/Driver/Util.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/Target/TargetOptions.h"
22 #include <memory>
23 #include <string>
24 
25 namespace llvm {
26 namespace opt {
27  class ArgList;
28  class DerivedArgList;
29  class InputArgList;
30 }
31 }
32 
33 namespace clang {
34 class ObjCRuntime;
35 namespace vfs {
36 class FileSystem;
37 }
38 
39 namespace driver {
40  class Compilation;
41  class CudaInstallationDetector;
42  class Driver;
43  class JobAction;
44  class RegisterEffectiveTriple;
45  class SanitizerArgs;
46  class Tool;
47  class XRayArgs;
48 
49 /// ToolChain - Access to tools for a single platform.
50 class ToolChain {
51 public:
53 
57  };
58 
62  };
63 
64  enum RTTIMode {
69  };
70 
71 private:
72  const Driver &D;
73  const llvm::Triple Triple;
74  const llvm::opt::ArgList &Args;
75  // We need to initialize CachedRTTIArg before CachedRTTIMode
76  const llvm::opt::Arg *const CachedRTTIArg;
77  const RTTIMode CachedRTTIMode;
78 
79  /// The list of toolchain specific path prefixes to search for
80  /// files.
81  path_list FilePaths;
82 
83  /// The list of toolchain specific path prefixes to search for
84  /// programs.
85  path_list ProgramPaths;
86 
87  mutable std::unique_ptr<Tool> Clang;
88  mutable std::unique_ptr<Tool> Assemble;
89  mutable std::unique_ptr<Tool> Link;
90  mutable std::unique_ptr<Tool> OffloadBundler;
91  Tool *getClang() const;
92  Tool *getAssemble() const;
93  Tool *getLink() const;
94  Tool *getClangAs() const;
95  Tool *getOffloadBundler() const;
96 
97  mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
98  mutable std::unique_ptr<XRayArgs> XRayArguments;
99 
100  /// The effective clang triple for the current Job.
101  mutable llvm::Triple EffectiveTriple;
102 
103  /// Set the toolchain's effective clang triple.
104  void setEffectiveTriple(llvm::Triple ET) const {
105  EffectiveTriple = std::move(ET);
106  }
107 
109 
110 protected:
112 
113  ToolChain(const Driver &D, const llvm::Triple &T,
114  const llvm::opt::ArgList &Args);
115 
116  virtual Tool *buildAssembler() const;
117  virtual Tool *buildLinker() const;
118  virtual Tool *getTool(Action::ActionClass AC) const;
119 
120  /// \name Utilities for implementing subclasses.
121  ///@{
122  static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
123  llvm::opt::ArgStringList &CC1Args,
124  const Twine &Path);
125  static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs,
126  llvm::opt::ArgStringList &CC1Args,
127  const Twine &Path);
128  static void
129  addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
130  llvm::opt::ArgStringList &CC1Args,
131  const Twine &Path);
132  static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
133  llvm::opt::ArgStringList &CC1Args,
134  ArrayRef<StringRef> Paths);
135  ///@}
136 
137 public:
138  virtual ~ToolChain();
139 
140  // Accessors
141 
142  const Driver &getDriver() const { return D; }
143  vfs::FileSystem &getVFS() const;
144  const llvm::Triple &getTriple() const { return Triple; }
145 
146  /// Get the toolchain's aux triple, if it has one.
147  ///
148  /// Exactly what the aux triple represents depends on the toolchain, but for
149  /// example when compiling CUDA code for the GPU, the triple might be NVPTX,
150  /// while the aux triple is the host (CPU) toolchain, e.g. x86-linux-gnu.
151  virtual const llvm::Triple *getAuxTriple() const { return nullptr; }
152 
153  llvm::Triple::ArchType getArch() const { return Triple.getArch(); }
154  StringRef getArchName() const { return Triple.getArchName(); }
155  StringRef getPlatform() const { return Triple.getVendorName(); }
156  StringRef getOS() const { return Triple.getOSName(); }
157 
158  /// \brief Provide the default architecture name (as expected by -arch) for
159  /// this toolchain.
160  StringRef getDefaultUniversalArchName() const;
161 
162  std::string getTripleString() const {
163  return Triple.getTriple();
164  }
165 
166  /// Get the toolchain's effective clang triple.
167  const llvm::Triple &getEffectiveTriple() const {
168  assert(!EffectiveTriple.getTriple().empty() && "No effective triple");
169  return EffectiveTriple;
170  }
171 
172  path_list &getFilePaths() { return FilePaths; }
173  const path_list &getFilePaths() const { return FilePaths; }
174 
175  path_list &getProgramPaths() { return ProgramPaths; }
176  const path_list &getProgramPaths() const { return ProgramPaths; }
177 
178  const MultilibSet &getMultilibs() const { return Multilibs; }
179 
180  const SanitizerArgs& getSanitizerArgs() const;
181 
182  const XRayArgs& getXRayArgs() const;
183 
184  // Returns the Arg * that explicitly turned on/off rtti, or nullptr.
185  const llvm::opt::Arg *getRTTIArg() const { return CachedRTTIArg; }
186 
187  // Returns the RTTIMode for the toolchain with the current arguments.
188  RTTIMode getRTTIMode() const { return CachedRTTIMode; }
189 
190  /// \brief Return any implicit target and/or mode flag for an invocation of
191  /// the compiler driver as `ProgName`.
192  ///
193  /// For example, when called with i686-linux-android-g++, the first element
194  /// of the return value will be set to `"i686-linux-android"` and the second
195  /// will be set to "--driver-mode=g++"`.
196  ///
197  /// \pre `llvm::InitializeAllTargets()` has been called.
198  /// \param ProgName The name the Clang driver was invoked with (from,
199  /// e.g., argv[0])
200  /// \return A pair of (`target`, `mode-flag`), where one or both may be empty.
201  static std::pair<std::string, std::string>
202  getTargetAndModeFromProgramName(StringRef ProgName);
203 
204  // Tool access.
205 
206  /// TranslateArgs - Create a new derived argument list for any argument
207  /// translations this ToolChain may wish to perform, or 0 if no tool chain
208  /// specific translations are needed. If \p DeviceOffloadKind is specified
209  /// the translation specific for that offload kind is performed.
210  ///
211  /// \param BoundArch - The bound architecture name, or 0.
212  /// \param DeviceOffloadKind - The device offload kind used for the
213  /// translation.
214  virtual llvm::opt::DerivedArgList *
215  TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
216  Action::OffloadKind DeviceOffloadKind) const {
217  return nullptr;
218  }
219 
220  /// Choose a tool to use to handle the action \p JA.
221  ///
222  /// This can be overridden when a particular ToolChain needs to use
223  /// a compiler other than Clang.
224  virtual Tool *SelectTool(const JobAction &JA) const;
225 
226  // Helper methods
227 
228  std::string GetFilePath(const char *Name) const;
229  std::string GetProgramPath(const char *Name) const;
230 
231  /// Returns the linker path, respecting the -fuse-ld= argument to determine
232  /// the linker suffix or name.
233  std::string GetLinkerPath() const;
234 
235  /// \brief Dispatch to the specific toolchain for verbose printing.
236  ///
237  /// This is used when handling the verbose option to print detailed,
238  /// toolchain-specific information useful for understanding the behavior of
239  /// the driver on a specific platform.
240  virtual void printVerboseInfo(raw_ostream &OS) const {}
241 
242  // Platform defaults information
243 
244  /// \brief Returns true if the toolchain is targeting a non-native
245  /// architecture.
246  virtual bool isCrossCompiling() const;
247 
248  /// HasNativeLTOLinker - Check whether the linker and related tools have
249  /// native LLVM support.
250  virtual bool HasNativeLLVMSupport() const;
251 
252  /// LookupTypeForExtension - Return the default language type to use for the
253  /// given extension.
254  virtual types::ID LookupTypeForExtension(StringRef Ext) const;
255 
256  /// IsBlocksDefault - Does this tool chain enable -fblocks by default.
257  virtual bool IsBlocksDefault() const { return false; }
258 
259  /// IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as
260  /// by default.
261  virtual bool IsIntegratedAssemblerDefault() const { return false; }
262 
263  /// \brief Check if the toolchain should use the integrated assembler.
264  virtual bool useIntegratedAs() const;
265 
266  /// IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
267  virtual bool IsMathErrnoDefault() const { return true; }
268 
269  /// IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable
270  /// -fencode-extended-block-signature by default.
271  virtual bool IsEncodeExtendedBlockSignatureDefault() const { return false; }
272 
273  /// IsObjCNonFragileABIDefault - Does this tool chain set
274  /// -fobjc-nonfragile-abi by default.
275  virtual bool IsObjCNonFragileABIDefault() const { return false; }
276 
277  /// UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the
278  /// mixed dispatch method be used?
279  virtual bool UseObjCMixedDispatch() const { return false; }
280 
281  /// GetDefaultStackProtectorLevel - Get the default stack protector level for
282  /// this tool chain (0=off, 1=on, 2=strong, 3=all).
283  virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const {
284  return 0;
285  }
286 
287  /// GetDefaultLinker - Get the default linker to use.
288  virtual const char *getDefaultLinker() const {
289  return "ld";
290  }
291 
292  /// GetDefaultRuntimeLibType - Get the default runtime library variant to use.
294  return ToolChain::RLT_Libgcc;
295  }
296 
299  }
300 
301  virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
302  StringRef Component,
303  bool Shared = false) const;
304 
305  const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
306  StringRef Component,
307  bool Shared = false) const;
308 
309  // Returns <ResourceDir>/lib/<OSName>/<arch>. This is used by runtimes (such
310  // as OpenMP) to find arch-specific libraries.
311  std::string getArchSpecificLibPath() const;
312 
313  /// needsProfileRT - returns true if instrumentation profile is on.
314  static bool needsProfileRT(const llvm::opt::ArgList &Args);
315 
316  /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
317  /// by default.
318  virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
319 
320  /// \brief Test whether this toolchain defaults to PIC.
321  virtual bool isPICDefault() const = 0;
322 
323  /// \brief Test whether this toolchain defaults to PIE.
324  virtual bool isPIEDefault() const = 0;
325 
326  /// \brief Tests whether this toolchain forces its default for PIC, PIE or
327  /// non-PIC. If this returns true, any PIC related flags should be ignored
328  /// and instead the results of \c isPICDefault() and \c isPIEDefault() are
329  /// used exclusively.
330  virtual bool isPICDefaultForced() const = 0;
331 
332  /// SupportsProfiling - Does this tool chain support -pg.
333  virtual bool SupportsProfiling() const { return true; }
334 
335  /// Does this tool chain support Objective-C garbage collection.
336  virtual bool SupportsObjCGC() const { return true; }
337 
338  /// Complain if this tool chain doesn't support Objective-C ARC.
339  virtual void CheckObjCARC() const {}
340 
341  /// UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf
342  /// compile unit information.
343  virtual bool UseDwarfDebugFlags() const { return false; }
344 
345  // Return the DWARF version to emit, in the absence of arguments
346  // to the contrary.
347  virtual unsigned GetDefaultDwarfVersion() const { return 4; }
348 
349  // True if the driver should assume "-fstandalone-debug"
350  // in the absence of an option specifying otherwise,
351  // provided that debugging was requested in the first place.
352  // i.e. a value of 'true' does not imply that debugging is wanted.
353  virtual bool GetDefaultStandaloneDebug() const { return false; }
354 
355  // Return the default debugger "tuning."
356  virtual llvm::DebuggerKind getDefaultDebuggerTuning() const {
357  return llvm::DebuggerKind::GDB;
358  }
359 
360  /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
361  virtual bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const {
362  return false;
363  }
364 
365  /// SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
366  virtual bool SupportsEmbeddedBitcode() const {
367  return false;
368  }
369 
370  /// getThreadModel() - Which thread model does this target use?
371  virtual std::string getThreadModel() const { return "posix"; }
372 
373  /// isThreadModelSupported() - Does this target support a thread model?
374  virtual bool isThreadModelSupported(const StringRef Model) const;
375 
376  /// ComputeLLVMTriple - Return the LLVM target triple to use, after taking
377  /// command line arguments into account.
378  virtual std::string
379  ComputeLLVMTriple(const llvm::opt::ArgList &Args,
380  types::ID InputType = types::TY_INVALID) const;
381 
382  /// ComputeEffectiveClangTriple - Return the Clang triple to use for this
383  /// target, which may take into account the command line arguments. For
384  /// example, on Darwin the -mmacosx-version-min= command line argument (which
385  /// sets the deployment target) determines the version in the triple passed to
386  /// Clang.
387  virtual std::string ComputeEffectiveClangTriple(
388  const llvm::opt::ArgList &Args,
389  types::ID InputType = types::TY_INVALID) const;
390 
391  /// getDefaultObjCRuntime - Return the default Objective-C runtime
392  /// for this platform.
393  ///
394  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
395  virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const;
396 
397  /// hasBlocksRuntime - Given that the user is compiling with
398  /// -fblocks, does this tool chain guarantee the existence of a
399  /// blocks runtime?
400  ///
401  /// FIXME: this really belongs on some sort of DeploymentTarget abstraction
402  virtual bool hasBlocksRuntime() const { return true; }
403 
404  /// \brief Add the clang cc1 arguments for system include paths.
405  ///
406  /// This routine is responsible for adding the necessary cc1 arguments to
407  /// include headers from standard system header directories.
408  virtual void
409  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
410  llvm::opt::ArgStringList &CC1Args) const;
411 
412  /// \brief Add options that need to be passed to cc1 for this target.
413  virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
414  llvm::opt::ArgStringList &CC1Args,
415  Action::OffloadKind DeviceOffloadKind) const;
416 
417  /// \brief Add warning options that need to be passed to cc1 for this target.
418  virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
419 
420  // GetRuntimeLibType - Determine the runtime library type to use with the
421  // given compilation arguments.
422  virtual RuntimeLibType
423  GetRuntimeLibType(const llvm::opt::ArgList &Args) const;
424 
425  // GetCXXStdlibType - Determine the C++ standard library type to use with the
426  // given compilation arguments.
427  virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
428 
429  /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
430  /// the include paths to use for the given C++ standard library type.
431  virtual void
432  AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
433  llvm::opt::ArgStringList &CC1Args) const;
434 
435  /// AddCXXStdlibLibArgs - Add the system specific linker arguments to use
436  /// for the given C++ standard library type.
437  virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
438  llvm::opt::ArgStringList &CmdArgs) const;
439 
440  /// AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
441  void AddFilePathLibArgs(const llvm::opt::ArgList &Args,
442  llvm::opt::ArgStringList &CmdArgs) const;
443 
444  /// AddCCKextLibArgs - Add the system specific linker arguments to use
445  /// for kernel extensions (Darwin-specific).
446  virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
447  llvm::opt::ArgStringList &CmdArgs) const;
448 
449  /// AddFastMathRuntimeIfAvailable - If a runtime library exists that sets
450  /// global flags for unsafe floating point math, add it and return true.
451  ///
452  /// This checks for presence of the -Ofast, -ffast-math or -funsafe-math flags.
453  virtual bool AddFastMathRuntimeIfAvailable(
454  const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const;
455  /// addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass
456  /// a suitable profile runtime library to the linker.
457  virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
458  llvm::opt::ArgStringList &CmdArgs) const;
459 
460  /// \brief Add arguments to use system-specific CUDA includes.
461  virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
462  llvm::opt::ArgStringList &CC1Args) const;
463 
464  /// \brief Add arguments to use MCU GCC toolchain includes.
465  virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs,
466  llvm::opt::ArgStringList &CC1Args) const;
467 
468  /// \brief On Windows, returns the MSVC compatibility version.
469  virtual VersionTuple computeMSVCVersion(const Driver *D,
470  const llvm::opt::ArgList &Args) const;
471 
472  /// \brief Return sanitizers which are available in this toolchain.
473  virtual SanitizerMask getSupportedSanitizers() const;
474 
475  /// \brief Return sanitizers which are enabled by default.
476  virtual SanitizerMask getDefaultSanitizers() const { return 0; }
477 };
478 
479 /// Set a ToolChain's effective triple. Reset it when the registration object
480 /// is destroyed.
482  const ToolChain &TC;
483 
484 public:
485  RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T) : TC(TC) {
486  TC.setEffectiveTriple(std::move(T));
487  }
488 
489  ~RegisterEffectiveTriple() { TC.setEffectiveTriple(llvm::Triple()); }
490 };
491 
492 } // end namespace driver
493 } // end namespace clang
494 
495 #endif
const llvm::Triple & getTriple() const
Definition: ToolChain.h:144
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:613
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:553
virtual Tool * getTool(Action::ActionClass AC) const
Definition: ToolChain.cpp:262
virtual Tool * SelectTool(const JobAction &JA) const
Choose a tool to use to handle the action JA.
Definition: ToolChain.cpp:359
SmallVector< std::string, 16 > path_list
Definition: ToolChain.h:52
static void addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Definition: ToolChain.cpp:620
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
std::string GetProgramPath(const char *Name) const
Definition: ToolChain.cpp:371
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:579
virtual 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:678
Set a ToolChain's effective triple.
Definition: ToolChain.h:481
const llvm::Triple & getEffectiveTriple() const
Get the toolchain's effective clang triple.
Definition: ToolChain.h:167
virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const
GetDefaultStackProtectorLevel - Get the default stack protector level for this tool chain (0=off...
Definition: ToolChain.h:283
virtual bool hasBlocksRuntime() const
hasBlocksRuntime - Given that the user is compiling with -fblocks, does this tool chain guarantee the...
Definition: ToolChain.h:402
virtual bool useIntegratedAs() const
Check if the toolchain should use the integrated assembler.
Definition: ToolChain.cpp:92
RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)
Definition: ToolChain.h:485
virtual bool IsMathErrnoDefault() const
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChain.h:267
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:153
virtual Tool * buildAssembler() const
Definition: ToolChain.cpp:230
virtual SanitizerMask getDefaultSanitizers() const
Return sanitizers which are enabled by default.
Definition: ToolChain.h:476
virtual bool isPICDefaultForced() const =0
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:702
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:673
virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const
IsUnwindTablesDefault - Does this tool chain use -funwind-tables by default.
Definition: ToolChain.cpp:220
virtual bool isThreadModelSupported(const StringRef Model) const
isThreadModelSupported() - Does this target support a thread model?
Definition: ToolChain.cpp:432
Defines the clang::SanitizerKind enum.
The virtual file system interface.
virtual bool SupportsObjCGC() const
Does this tool chain support Objective-C garbage collection.
Definition: ToolChain.h:336
virtual void printVerboseInfo(raw_ostream &OS) const
Dispatch to the specific toolchain for verbose printing.
Definition: ToolChain.h:240
path_list & getProgramPaths()
Definition: ToolChain.h:175
virtual bool HasNativeLLVMSupport() const
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: ToolChain.cpp:407
virtual std::string getThreadModel() const
getThreadModel() - Which thread model does this target use?
Definition: ToolChain.h:371
virtual bool isCrossCompiling() const
Returns true if the toolchain is targeting a non-native architecture.
Definition: ToolChain.cpp:411
static bool needsProfileRT(const llvm::opt::ArgList &Args)
needsProfileRT - returns true if instrumentation profile is on.
Definition: ToolChain.cpp:345
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:651
virtual bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const
UseSjLjExceptions - Does this tool chain use SjLj exceptions.
Definition: ToolChain.h:361
std::string getTripleString() const
Definition: ToolChain.h:162
path_list & getFilePaths()
Definition: ToolChain.h:172
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:65
const Driver & getDriver() const
Definition: ToolChain.h:142
std::string getArchSpecificLibPath() const
Definition: ToolChain.cpp:337
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:547
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition: ToolChain.cpp:72
StringRef getArchName() const
Definition: ToolChain.h:154
virtual RuntimeLibType GetDefaultRuntimeLibType() const
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: ToolChain.h:293
virtual const char * getDefaultLinker() const
GetDefaultLinker - Get the default linker to use.
Definition: ToolChain.h:288
virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const
On Windows, returns the MSVC compatibility version.
Definition: ToolChain.cpp:739
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, bool Shared=false) const
Definition: ToolChain.cpp:311
StringRef getOS() const
Definition: ToolChain.h:156
virtual CXXStdlibType GetDefaultCXXStdlibType() const
Definition: ToolChain.h:297
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:560
virtual bool isPICDefault() const =0
Test whether this toolchain defaults to PIC.
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:628
const path_list & getProgramPaths() const
Definition: ToolChain.h:176
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use MCU GCC toolchain includes.
Definition: ToolChain.cpp:722
virtual const llvm::Triple * getAuxTriple() const
Get the toolchain's aux triple, if it has one.
Definition: ToolChain.h:151
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const
Add warning options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:551
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:215
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:447
static std::pair< std::string, std::string > getTargetAndModeFromProgramName(StringRef ProgName)
Return any implicit target and/or mode flag for an invocation of the compiler driver as ProgName...
Definition: ToolChain.cpp:180
virtual void CheckObjCARC() const
Complain if this tool chain doesn't support Objective-C ARC.
Definition: ToolChain.h:339
virtual bool IsBlocksDefault() const
IsBlocksDefault - Does this tool chain enable -fblocks by default.
Definition: ToolChain.h:257
const llvm::opt::Arg * getRTTIArg() const
Definition: ToolChain.h:185
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:637
virtual bool UseObjCMixedDispatch() const
UseObjCMixedDispatchDefault - When using non-legacy dispatch, should the mixed dispatch method be use...
Definition: ToolChain.h:279
StringRef getDefaultUniversalArchName() const
Provide the default architecture name (as expected by -arch) for this toolchain.
Definition: ToolChain.cpp:203
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:537
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:598
virtual bool IsEncodeExtendedBlockSignatureDefault() const
IsEncodeExtendedBlockSignatureDefault - Does this tool chain enable -fencode-extended-block-signature...
Definition: ToolChain.h:271
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:542
const MultilibSet & getMultilibs() const
Definition: ToolChain.h:178
RTTIMode getRTTIMode() const
Definition: ToolChain.h:188
uint64_t SanitizerMask
Definition: Sanitizers.h:24
StringRef Name
Definition: USRFinder.cpp:123
virtual bool SupportsEmbeddedBitcode() const
SupportsEmbeddedBitcode - Does this tool chain support embedded bitcode.
Definition: ToolChain.h:366
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:25
const char * getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, bool Shared=false) const
Definition: ToolChain.cpp:331
const XRayArgs & getXRayArgs() const
Definition: ToolChain.cpp:104
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
virtual llvm::DebuggerKind getDefaultDebuggerTuning() const
Definition: ToolChain.h:356
virtual bool IsObjCNonFragileABIDefault() const
IsObjCNonFragileABIDefault - Does this tool chain set -fobjc-nonfragile-abi by default.
Definition: ToolChain.h:275
virtual bool isPIEDefault() const =0
Test whether this toolchain defaults to PIE.
virtual bool SupportsProfiling() const
SupportsProfiling - Does this tool chain support -pg.
Definition: ToolChain.h:333
virtual Tool * buildLinker() const
Definition: ToolChain.cpp:234
virtual types::ID LookupTypeForExtension(StringRef Ext) const
LookupTypeForExtension - Return the default language type to use for the given extension.
Definition: ToolChain.cpp:403
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:666
Defines the clang::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
vfs::FileSystem & getVFS() const
Definition: ToolChain.cpp:90
virtual bool GetDefaultStandaloneDebug() const
Definition: ToolChain.h:353
const path_list & getFilePaths() const
Definition: ToolChain.h:173
virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const
getDefaultObjCRuntime - Return the default Objective-C runtime for this platform. ...
Definition: ToolChain.cpp:427
virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use system-specific CUDA includes.
Definition: ToolChain.cpp:719
virtual bool IsIntegratedAssemblerDefault() const
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChain.h:261
virtual bool UseDwarfDebugFlags() const
UseDwarfDebugFlags - Embed the compile options to clang into the Dwarf compile unit information...
Definition: ToolChain.h:343
virtual unsigned GetDefaultDwarfVersion() const
Definition: ToolChain.h:347
std::string GetLinkerPath() const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name...
Definition: ToolChain.cpp:375
StringRef getPlatform() const
Definition: ToolChain.h:155
const SanitizerArgs & getSanitizerArgs() const
Definition: ToolChain.cpp:98
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:367
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:50