9 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H 10 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H 19 #include "llvm/ADT/ArrayRef.h" 20 #include "llvm/ADT/SmallVector.h" 21 #include "llvm/ADT/StringRef.h" 22 #include "llvm/ADT/Triple.h" 23 #include "llvm/MC/MCTargetOptions.h" 24 #include "llvm/Option/Option.h" 25 #include "llvm/Support/VersionTuple.h" 26 #include "llvm/Target/TargetOptions.h" 69 const char *DriverMode =
nullptr;
72 bool TargetIsValid =
false;
76 : ModeSuffix(Suffix), DriverMode(Mode) {}
79 : TargetPrefix(Target), ModeSuffix(Suffix), DriverMode(Mode),
80 TargetIsValid(IsRegistered) {}
83 return TargetPrefix.empty() && ModeSuffix.empty() && DriverMode ==
nullptr;
120 const llvm::opt::ArgList &Args;
123 const llvm::opt::Arg *
const CachedRTTIArg;
136 mutable std::unique_ptr<Tool> Clang;
137 mutable std::unique_ptr<Tool>
Assemble;
138 mutable std::unique_ptr<Tool>
Link;
139 mutable std::unique_ptr<Tool> OffloadBundler;
141 Tool *getClang()
const;
142 Tool *getAssemble()
const;
143 Tool *getLink()
const;
144 Tool *getClangAs()
const;
145 Tool *getOffloadBundler()
const;
147 mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
148 mutable std::unique_ptr<XRayArgs> XRayArguments;
151 mutable llvm::Triple EffectiveTriple;
154 void setEffectiveTriple(llvm::Triple ET)
const {
155 EffectiveTriple = std::move(ET);
163 const llvm::opt::ArgList &Args);
165 void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
167 virtual Tool *buildAssembler()
const;
168 virtual Tool *buildLinker()
const;
173 static void addSystemInclude(
const llvm::opt::ArgList &DriverArgs,
174 llvm::opt::ArgStringList &CC1Args,
176 static void addExternCSystemInclude(
const llvm::opt::ArgList &DriverArgs,
177 llvm::opt::ArgStringList &CC1Args,
180 addExternCSystemIncludeIfExists(
const llvm::opt::ArgList &DriverArgs,
181 llvm::opt::ArgStringList &CC1Args,
183 static void addSystemIncludes(
const llvm::opt::ArgList &DriverArgs,
184 llvm::opt::ArgStringList &CC1Args,
194 llvm::vfs::FileSystem &getVFS()
const;
195 const llvm::Triple &
getTriple()
const {
return Triple; }
207 virtual std::string getInputFilename(
const InputInfo &Input)
const;
209 llvm::Triple::ArchType
getArch()
const {
return Triple.getArch(); }
212 StringRef
getOS()
const {
return Triple.getOSName(); }
216 StringRef getDefaultUniversalArchName()
const;
219 return Triple.getTriple();
224 assert(!EffectiveTriple.getTriple().empty() &&
"No effective triple");
225 return EffectiveTriple;
243 const XRayArgs& getXRayArgs()
const;
246 const llvm::opt::Arg *
getRTTIArg()
const {
return CachedRTTIArg; }
265 static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
277 virtual llvm::opt::DerivedArgList *
286 virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
287 const llvm::opt::DerivedArgList &Args,
bool SameTripleAsHost,
298 std::string GetFilePath(
const char *Name)
const;
299 std::string GetProgramPath(
const char *Name)
const;
303 std::string GetLinkerPath()
const;
316 virtual bool isCrossCompiling()
const;
320 virtual bool HasNativeLLVMSupport()
const;
324 virtual types::ID LookupTypeForExtension(StringRef Ext)
const;
334 virtual bool useIntegratedAs()
const;
352 virtual bool useRelaxRelocations()
const;
371 return ToolChain::RLT_Libgcc;
375 return ToolChain::CST_Libstdcxx;
379 return ToolChain::UNW_None;
382 virtual std::string getCompilerRTPath()
const;
384 virtual std::string getCompilerRT(
const llvm::opt::ArgList &Args,
389 getCompilerRTArgString(
const llvm::opt::ArgList &Args, StringRef Component,
400 std::string getArchSpecificLibPath()
const;
403 StringRef getOSLibName()
const;
406 static bool needsProfileRT(
const llvm::opt::ArgList &Args);
409 static bool needsGCovInstrumentation(
const llvm::opt::ArgList &Args);
413 virtual bool IsUnwindTablesDefault(
const llvm::opt::ArgList &Args)
const;
416 virtual bool isPICDefault()
const = 0;
419 virtual bool isPIEDefault()
const = 0;
422 virtual bool isNoExecStackDefault()
const;
428 virtual bool isPICDefaultForced()
const = 0;
457 return llvm::DebuggerKind::GDB;
467 const llvm::opt::ArgList &Args)
const {}
470 virtual llvm::ExceptionHandling
471 GetExceptionModel(
const llvm::opt::ArgList &Args)
const;
480 virtual bool isThreadModelSupported(
const StringRef Model)
const;
485 ComputeLLVMTriple(
const llvm::opt::ArgList &Args,
493 virtual std::string ComputeEffectiveClangTriple(
494 const llvm::opt::ArgList &Args,
501 virtual ObjCRuntime getDefaultObjCRuntime(
bool isNonFragile)
const;
515 AddClangSystemIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
516 llvm::opt::ArgStringList &CC1Args)
const;
519 virtual void addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs,
520 llvm::opt::ArgStringList &CC1Args,
524 virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args)
const;
529 GetRuntimeLibType(
const llvm::opt::ArgList &Args)
const;
533 virtual CXXStdlibType GetCXXStdlibType(
const llvm::opt::ArgList &Args)
const;
537 virtual UnwindLibType GetUnwindLibType(
const llvm::opt::ArgList &Args)
const;
542 AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
543 llvm::opt::ArgStringList &CC1Args)
const;
547 bool ShouldLinkCXXStdlib(
const llvm::opt::ArgList &Args)
const;
551 virtual void AddCXXStdlibLibArgs(
const llvm::opt::ArgList &Args,
552 llvm::opt::ArgStringList &CmdArgs)
const;
555 void AddFilePathLibArgs(
const llvm::opt::ArgList &Args,
556 llvm::opt::ArgStringList &CmdArgs)
const;
560 virtual void AddCCKextLibArgs(
const llvm::opt::ArgList &Args,
561 llvm::opt::ArgStringList &CmdArgs)
const;
567 virtual bool AddFastMathRuntimeIfAvailable(
568 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
572 virtual void addProfileRTLibs(
const llvm::opt::ArgList &Args,
573 llvm::opt::ArgStringList &CmdArgs)
const;
576 virtual void AddCudaIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
577 llvm::opt::ArgStringList &CC1Args)
const;
580 virtual void AddIAMCUIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
581 llvm::opt::ArgStringList &CC1Args)
const;
584 virtual VersionTuple computeMSVCVersion(
const Driver *D,
585 const llvm::opt::ArgList &Args)
const;
603 TC.setEffectiveTriple(std::move(T));
613 #endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H
std::string ModeSuffix
Driver mode part of the executable name, as g++.
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
Set a ToolChain's effective triple.
The base class of the type hierarchy.
RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)
Defines the clang::SanitizerKind enum.
std::string TargetPrefix
Target part of the executable name, as i686-linux-android.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Defines the clang::LangOptions interface.
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag...
ParsedClangName(std::string Suffix, const char *Mode)
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Dataflow Directional Tag Classes.
The basic abstraction for the target Objective-C runtime.
ParsedClangName(std::string Target, std::string Suffix, const char *Mode, bool IsRegistered)
~RegisterEffectiveTriple()