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