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 *
407 const llvm::opt::DerivedArgList &Args,
const llvm::Triple &HostTriple,
414 const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
415 llvm::opt::DerivedArgList *DAL,
421 virtual llvm::opt::DerivedArgList *
444 std::string
GetLinkerPath(
bool *LinkerIsLLD =
nullptr)
const;
474 bool isUsingLTO(
const llvm::opt::ArgList &Args,
562 virtual std::string
getCompilerRT(
const llvm::opt::ArgList &Args,
565 bool IsFortran =
false)
const;
569 llvm::opt::ArgStringList &CmdArgs)
const;
574 llvm::opt::ArgStringList &CmdArgs)
const;
578 llvm::opt::ArgStringList &CmdArgs)
const;
583 bool IsFortran =
false)
const;
648 return llvm::codegenoptions::DIF_DWARF;
679 return llvm::DebuggerKind::GDB;
690 const llvm::opt::ArgList &Args)
const {}
693 virtual llvm::ExceptionHandling
709 const llvm::Triple &TargetTriple,
710 StringRef SysRoot)
const {
711 return TargetTriple.str();
752 llvm::opt::ArgStringList &CC1Args)
const;
757 llvm::opt::ArgStringList &CC1Args,
BoundArch BA,
763 llvm::opt::ArgStringList &CC1ASArgs)
const;
804 llvm::opt::ArgStringList &CC1Args)
const;
809 llvm::opt::ArgStringList &CC1Args)
const;
818 llvm::opt::ArgStringList &CmdArgs)
const;
822 llvm::opt::ArgStringList &CmdArgs)
const;
827 llvm::opt::ArgStringList &CmdArgs)
const;
834 const llvm::opt::ArgList &Args, std::string &Path)
const;
841 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
850 llvm::opt::ArgStringList &CmdArgs)
const;
854 llvm::opt::ArgStringList &CC1Args)
const;
858 llvm::opt::ArgStringList &CC1Args)
const;
862 llvm::opt::ArgStringList &CC1Args)
const;
866 llvm::opt::ArgStringList &CC1Args)
const;
870 const llvm::opt::ArgList &Args)
const;
879 const llvm::opt::ArgList &Args,
880 llvm::opt::ArgStringList &CmdArgs)
const {}
900 const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
901 const llvm::fltSemantics *FPType =
nullptr)
const {
902 return llvm::DenormalMode::getIEEE();
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);
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);
928 llvm::Triple TT(OrigTT);
941 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)