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