10 #ifndef LLVM_CLANG_DRIVER_TOOLCHAIN_H 11 #define LLVM_CLANG_DRIVER_TOOLCHAIN_H 18 #include "llvm/ADT/ArrayRef.h" 19 #include "llvm/ADT/SmallVector.h" 20 #include "llvm/ADT/StringRef.h" 21 #include "llvm/ADT/Triple.h" 22 #include "llvm/MC/MCTargetOptions.h" 23 #include "llvm/Option/Option.h" 24 #include "llvm/Support/VersionTuple.h" 25 #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;
112 const llvm::opt::ArgList &Args;
115 const llvm::opt::Arg *
const CachedRTTIArg;
125 mutable std::unique_ptr<Tool> Clang;
126 mutable std::unique_ptr<Tool>
Assemble;
127 mutable std::unique_ptr<Tool>
Link;
128 mutable std::unique_ptr<Tool> OffloadBundler;
130 Tool *getClang()
const;
131 Tool *getAssemble()
const;
132 Tool *getLink()
const;
133 Tool *getClangAs()
const;
134 Tool *getOffloadBundler()
const;
136 mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
137 mutable std::unique_ptr<XRayArgs> XRayArguments;
140 mutable llvm::Triple EffectiveTriple;
143 void setEffectiveTriple(llvm::Triple ET)
const {
144 EffectiveTriple = std::move(ET);
151 const llvm::opt::ArgList &Args);
153 void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
155 virtual Tool *buildAssembler()
const;
156 virtual Tool *buildLinker()
const;
161 static void addSystemInclude(
const llvm::opt::ArgList &DriverArgs,
162 llvm::opt::ArgStringList &CC1Args,
164 static void addExternCSystemInclude(
const llvm::opt::ArgList &DriverArgs,
165 llvm::opt::ArgStringList &CC1Args,
168 addExternCSystemIncludeIfExists(
const llvm::opt::ArgList &DriverArgs,
169 llvm::opt::ArgStringList &CC1Args,
171 static void addSystemIncludes(
const llvm::opt::ArgList &DriverArgs,
172 llvm::opt::ArgStringList &CC1Args,
183 const llvm::Triple &
getTriple()
const {
return Triple; }
195 virtual std::string getInputFilename(
const InputInfo &Input)
const;
197 llvm::Triple::ArchType
getArch()
const {
return Triple.getArch(); }
200 StringRef
getOS()
const {
return Triple.getOSName(); }
204 StringRef getDefaultUniversalArchName()
const;
207 return Triple.getTriple();
212 assert(!EffectiveTriple.getTriple().empty() &&
"No effective triple");
213 return EffectiveTriple;
226 const XRayArgs& getXRayArgs()
const;
229 const llvm::opt::Arg *
getRTTIArg()
const {
return CachedRTTIArg; }
248 static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
260 virtual llvm::opt::DerivedArgList *
269 virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
270 const llvm::opt::DerivedArgList &Args,
bool SameTripleAsHost,
281 std::string GetFilePath(
const char *Name)
const;
282 std::string GetProgramPath(
const char *Name)
const;
286 std::string GetLinkerPath()
const;
299 virtual bool isCrossCompiling()
const;
303 virtual bool HasNativeLLVMSupport()
const;
307 virtual types::ID LookupTypeForExtension(StringRef Ext)
const;
317 virtual bool useIntegratedAs()
const;
335 virtual bool useRelaxRelocations()
const;
348 return ToolChain::RLT_Libgcc;
352 return ToolChain::CST_Libstdcxx;
355 virtual std::string getCompilerRTPath()
const;
357 virtual std::string getCompilerRT(
const llvm::opt::ArgList &Args,
359 bool Shared =
false)
const;
361 const char *getCompilerRTArgString(
const llvm::opt::ArgList &Args,
363 bool Shared =
false)
const;
367 std::string getArchSpecificLibPath()
const;
370 StringRef getOSLibName()
const;
373 static bool needsProfileRT(
const llvm::opt::ArgList &Args);
377 virtual bool IsUnwindTablesDefault(
const llvm::opt::ArgList &Args)
const;
380 virtual bool isPICDefault()
const = 0;
383 virtual bool isPIEDefault()
const = 0;
389 virtual bool isPICDefaultForced()
const = 0;
413 return llvm::DebuggerKind::GDB;
422 virtual llvm::ExceptionHandling
423 GetExceptionModel(
const llvm::opt::ArgList &Args)
const;
432 virtual bool isThreadModelSupported(
const StringRef Model)
const;
437 ComputeLLVMTriple(
const llvm::opt::ArgList &Args,
445 virtual std::string ComputeEffectiveClangTriple(
446 const llvm::opt::ArgList &Args,
453 virtual ObjCRuntime getDefaultObjCRuntime(
bool isNonFragile)
const;
467 AddClangSystemIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
468 llvm::opt::ArgStringList &CC1Args)
const;
471 virtual void addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs,
472 llvm::opt::ArgStringList &CC1Args,
476 virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args)
const;
481 GetRuntimeLibType(
const llvm::opt::ArgList &Args)
const;
485 virtual CXXStdlibType GetCXXStdlibType(
const llvm::opt::ArgList &Args)
const;
490 AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
491 llvm::opt::ArgStringList &CC1Args)
const;
495 bool ShouldLinkCXXStdlib(
const llvm::opt::ArgList &Args)
const;
499 virtual void AddCXXStdlibLibArgs(
const llvm::opt::ArgList &Args,
500 llvm::opt::ArgStringList &CmdArgs)
const;
503 void AddFilePathLibArgs(
const llvm::opt::ArgList &Args,
504 llvm::opt::ArgStringList &CmdArgs)
const;
508 virtual void AddCCKextLibArgs(
const llvm::opt::ArgList &Args,
509 llvm::opt::ArgStringList &CmdArgs)
const;
515 virtual bool AddFastMathRuntimeIfAvailable(
516 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
520 virtual void addProfileRTLibs(
const llvm::opt::ArgList &Args,
521 llvm::opt::ArgStringList &CmdArgs)
const;
524 virtual void AddCudaIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
525 llvm::opt::ArgStringList &CC1Args)
const;
528 virtual void AddIAMCUIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
529 llvm::opt::ArgStringList &CC1Args)
const;
532 virtual VersionTuple computeMSVCVersion(
const Driver *D,
533 const llvm::opt::ArgList &Args)
const;
549 TC.setEffectiveTriple(std::move(T));
559 #endif // LLVM_CLANG_DRIVER_TOOLCHAIN_H
std::string ModeSuffix
Driver mode part of the executable name, as g++.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Set a ToolChain's effective triple.
RegisterEffectiveTriple(const ToolChain &TC, llvm::Triple T)
Defines the clang::SanitizerKind enum.
The virtual file system interface.
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...
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()