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