9#ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H
10#define LLVM_CLANG_DRIVER_TOOLCHAIN_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"
149 const llvm::opt::ArgList &Args;
152 const llvm::opt::Arg *
const CachedRTTIArg;
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;
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;
190 mutable bool SanitizerArgsChecked =
false;
193 mutable llvm::SmallSet<StringRef, 4> BoundArchSanitizerArgsChecked;
196 mutable llvm::Triple EffectiveTriple;
199 void setEffectiveTriple(llvm::Triple ET)
const {
200 EffectiveTriple = std::move(ET);
203 std::optional<std::string>
204 getFallbackAndroidTargetPath(StringRef BaseDir)
const;
206 mutable std::optional<CXXStdlibType> cxxStdlibType;
207 mutable std::optional<RuntimeLibType> runtimeLibType;
208 mutable std::optional<UnwindLibType> unwindLibType;
209 mutable std::optional<CStdlibType> cStdlibType;
217 llvm::iterator_range<llvm::SmallVector<Multilib>::const_reverse_iterator>;
224 StringRef Fallback = {});
229 StringRef FallbackDir = {});
231 ToolChain(
const Driver &D,
const llvm::Triple &
T,
232 const llvm::opt::ArgList &Args);
244 bool IsFortran =
false)
const;
254 llvm::opt::ArgStringList &CC1Args,
257 llvm::opt::ArgStringList &CC1Args,
261 llvm::opt::ArgStringList &CC1Args,
264 llvm::opt::ArgStringList &CC1Args,
267 llvm::opt::ArgStringList &CC1Args,
270 static std::string
concat(StringRef Path,
const Twine &A,
const Twine &B =
"",
271 const Twine &
C =
"",
const Twine &D =
"");
276 llvm::opt::ArgStringList &CC1Args,
283 llvm::vfs::FileSystem &
getVFS()
const;
284 const llvm::Triple &
getTriple()
const {
return Triple; }
298 llvm::Triple::ArchType
getArch()
const {
return Triple.getArch(); }
301 StringRef
getOS()
const {
return Triple.getOSName(); }
311 assert(!EffectiveTriple.getTriple().empty() &&
"No effective triple");
312 return EffectiveTriple;
316 return !EffectiveTriple.getTriple().empty();
347 const llvm::opt::ArgList &JobArgs,
BoundArch BA = {},
362 const llvm::opt::Arg *
getRTTIArg()
const {
return CachedRTTIArg; }
396 virtual llvm::opt::DerivedArgList *
406 const llvm::opt::DerivedArgList &Args,
bool SameTripleAsHost,
413 const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
414 llvm::opt::DerivedArgList *DAL,
420 virtual llvm::opt::DerivedArgList *
443 std::string
GetLinkerPath(
bool *LinkerIsLLD =
nullptr)
const;
473 bool isUsingLTO(
const llvm::opt::ArgList &Args,
561 virtual std::string
getCompilerRT(
const llvm::opt::ArgList &Args,
564 bool IsFortran =
false)
const;
568 llvm::opt::ArgStringList &CmdArgs)
const;
573 llvm::opt::ArgStringList &CmdArgs)
const;
577 llvm::opt::ArgStringList &CmdArgs)
const;
582 bool IsFortran =
false)
const;
647 return llvm::codegenoptions::DIF_DWARF;
678 return llvm::DebuggerKind::GDB;
689 const llvm::opt::ArgList &Args)
const {}
692 virtual llvm::ExceptionHandling
708 const llvm::Triple &TargetTriple,
709 StringRef SysRoot)
const {
710 return TargetTriple.str();
751 llvm::opt::ArgStringList &CC1Args)
const;
756 llvm::opt::ArgStringList &CC1Args,
BoundArch BA,
762 llvm::opt::ArgStringList &CC1ASArgs)
const;
803 llvm::opt::ArgStringList &CC1Args)
const;
808 llvm::opt::ArgStringList &CC1Args)
const;
817 llvm::opt::ArgStringList &CmdArgs)
const;
821 llvm::opt::ArgStringList &CmdArgs)
const;
826 llvm::opt::ArgStringList &CmdArgs)
const;
833 const llvm::opt::ArgList &Args, std::string &Path)
const;
840 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
849 llvm::opt::ArgStringList &CmdArgs)
const;
853 llvm::opt::ArgStringList &CC1Args)
const;
857 llvm::opt::ArgStringList &CC1Args)
const;
861 llvm::opt::ArgStringList &CC1Args)
const;
865 llvm::opt::ArgStringList &CC1Args)
const;
869 const llvm::opt::ArgList &Args)
const;
878 const llvm::opt::ArgList &Args,
879 llvm::opt::ArgStringList &CmdArgs)
const {}
899 const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
900 const llvm::fltSemantics *FPType =
nullptr)
const {
901 return llvm::DenormalMode::getIEEE();
908 if (TT.getVendor() == llvm::Triple::UnknownVendor)
909 TT.setVendor(llvm::Triple::NVIDIA);
910 if (TT.getOS() == llvm::Triple::UnknownOS)
911 TT.setOS(llvm::Triple::CUDA);
917 TT.setArch(llvm::Triple::amdgpu, TT.getSubArch());
918 if (TT.getVendor() == llvm::Triple::UnknownVendor)
919 TT.setVendor(llvm::Triple::AMD);
920 if (TT.getOS() == llvm::Triple::UnknownOS)
921 TT.setOS(llvm::Triple::AMDHSA);
927 llvm::Triple TT(OrigTT);
940 TC.setEffectiveTriple(std::move(
T));
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
llvm::MachO::FileType FileType
Defines the clang::SanitizerKind enum.
The basic abstraction for the target Objective-C runtime.
The base class of the type hierarchy.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
See also MultilibSetBuilder for combining multilibs into a set.
std::vector< std::string > flags_list
~RegisterEffectiveTriple()
RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
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...
ParsedClangName(std::string Suffix, const char *Mode)
ParsedClangName()=default
const char * DriverMode
Corresponding driver mode argument, as '–driver-mode=g++'.
std::string ModeSuffix
Driver mode part of the executable name, as g++.
std::string TargetPrefix
Target part of the executable name, as i686-linux-android.
bool TargetIsValid
True if TargetPrefix is recognized as a registered target name.
ParsedClangName(std::string Target, std::string Suffix, const char *Mode, bool IsRegistered)