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