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