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