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"
146 const llvm::opt::ArgList &Args;
149 const llvm::opt::Arg *
const CachedRTTIArg;
164 mutable std::unique_ptr<Tool> Clang;
165 mutable std::unique_ptr<Tool> Flang;
166 mutable std::unique_ptr<Tool> Assemble;
167 mutable std::unique_ptr<Tool> Link;
168 mutable std::unique_ptr<Tool> StaticLibTool;
169 mutable std::unique_ptr<Tool> IfsMerge;
170 mutable std::unique_ptr<Tool> OffloadBundler;
171 mutable std::unique_ptr<Tool> OffloadPackager;
172 mutable std::unique_ptr<Tool> LinkerWrapper;
174 Tool *getClang()
const;
175 Tool *getFlang()
const;
176 Tool *getAssemble()
const;
177 Tool *getLink()
const;
178 Tool *getStaticLibTool()
const;
179 Tool *getIfsMerge()
const;
180 Tool *getClangAs()
const;
181 Tool *getOffloadBundler()
const;
182 Tool *getOffloadPackager()
const;
183 Tool *getLinkerWrapper()
const;
187 mutable bool SanitizerArgsChecked =
false;
190 mutable llvm::SmallSet<StringRef, 4> BoundArchSanitizerArgsChecked;
193 mutable llvm::Triple EffectiveTriple;
196 void setEffectiveTriple(llvm::Triple ET)
const {
197 EffectiveTriple = std::move(ET);
200 std::optional<std::string>
201 getFallbackAndroidTargetPath(StringRef BaseDir)
const;
203 mutable std::optional<CXXStdlibType> cxxStdlibType;
204 mutable std::optional<RuntimeLibType> runtimeLibType;
205 mutable std::optional<UnwindLibType> unwindLibType;
206 mutable std::optional<CStdlibType> cStdlibType;
214 llvm::iterator_range<llvm::SmallVector<Multilib>::const_reverse_iterator>;
221 StringRef Fallback = {});
226 StringRef FallbackDir = {});
228 ToolChain(
const Driver &D,
const llvm::Triple &T,
229 const llvm::opt::ArgList &Args);
241 bool IsFortran =
false)
const;
251 llvm::opt::ArgStringList &CC1Args,
254 llvm::opt::ArgStringList &CC1Args,
258 llvm::opt::ArgStringList &CC1Args,
261 llvm::opt::ArgStringList &CC1Args,
264 llvm::opt::ArgStringList &CC1Args,
267 static std::string
concat(StringRef Path,
const Twine &A,
const Twine &B =
"",
268 const Twine &
C =
"",
const Twine &D =
"");
273 llvm::opt::ArgStringList &CC1Args,
280 llvm::vfs::FileSystem &
getVFS()
const;
281 const llvm::Triple &
getTriple()
const {
return Triple; }
295 llvm::Triple::ArchType
getArch()
const {
return Triple.getArch(); }
298 StringRef
getOS()
const {
return Triple.getOSName(); }
308 assert(!EffectiveTriple.getTriple().empty() &&
"No effective triple");
309 return EffectiveTriple;
313 return !EffectiveTriple.getTriple().empty();
344 const llvm::opt::ArgList &JobArgs,
BoundArch BA = {},
359 const llvm::opt::Arg *
getRTTIArg()
const {
return CachedRTTIArg; }
393 virtual llvm::opt::DerivedArgList *
404 const llvm::opt::DerivedArgList &Args,
const llvm::Triple &HostTriple,
411 const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
412 llvm::opt::DerivedArgList *DAL,
418 virtual llvm::opt::DerivedArgList *
441 std::string
GetLinkerPath(
bool *LinkerIsLLD =
nullptr)
const;
471 bool isUsingLTO(
const llvm::opt::ArgList &Args,
559 virtual std::string
getCompilerRT(
const llvm::opt::ArgList &Args,
562 bool IsFortran =
false)
const;
566 llvm::opt::ArgStringList &CmdArgs)
const;
571 llvm::opt::ArgStringList &CmdArgs)
const;
575 llvm::opt::ArgStringList &CmdArgs)
const;
580 bool IsFortran =
false)
const;
645 return llvm::codegenoptions::DIF_DWARF;
676 return llvm::DebuggerKind::GDB;
687 const llvm::opt::ArgList &Args)
const {}
690 virtual llvm::ExceptionHandling
706 const llvm::Triple &TargetTriple,
707 StringRef SysRoot)
const {
708 return TargetTriple.str();
749 llvm::opt::ArgStringList &CC1Args)
const;
754 llvm::opt::ArgStringList &CC1Args,
BoundArch BA,
760 llvm::opt::ArgStringList &CC1ASArgs)
const;
801 llvm::opt::ArgStringList &CC1Args)
const;
806 llvm::opt::ArgStringList &CC1Args)
const;
815 llvm::opt::ArgStringList &CmdArgs)
const;
819 llvm::opt::ArgStringList &CmdArgs)
const;
824 llvm::opt::ArgStringList &CmdArgs)
const;
831 const llvm::opt::ArgList &Args, std::string &Path)
const;
838 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
847 llvm::opt::ArgStringList &CmdArgs)
const;
851 llvm::opt::ArgStringList &CC1Args)
const;
855 llvm::opt::ArgStringList &CC1Args)
const;
859 llvm::opt::ArgStringList &CC1Args)
const;
863 llvm::opt::ArgStringList &CC1Args)
const;
867 const llvm::opt::ArgList &Args)
const;
876 const llvm::opt::ArgList &Args,
877 llvm::opt::ArgStringList &CmdArgs)
const {}
897 const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
898 const llvm::fltSemantics *FPType =
nullptr)
const {
899 return llvm::DenormalMode::getIEEE();
906 if (TT.getVendor() == llvm::Triple::UnknownVendor)
907 TT.setVendor(llvm::Triple::NVIDIA);
908 if (TT.getOS() == llvm::Triple::UnknownOS)
909 TT.setOS(llvm::Triple::CUDA);
915 TT.setArch(llvm::Triple::amdgpu, TT.getSubArch());
916 if (TT.getVendor() == llvm::Triple::UnknownVendor)
917 TT.setVendor(llvm::Triple::AMD);
918 if (TT.getOS() == llvm::Triple::UnknownOS)
919 TT.setOS(llvm::Triple::AMDHSA);
925 llvm::Triple TT(OrigTT);
938 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.
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)