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> Flang;
138 mutable std::unique_ptr<Tool>
Assemble;
139 mutable std::unique_ptr<Tool>
Link;
140 mutable std::unique_ptr<Tool>
IfsMerge;
141 mutable std::unique_ptr<Tool> OffloadBundler;
142 mutable std::unique_ptr<Tool> OffloadWrapper;
144 Tool *getClang()
const;
145 Tool *getFlang()
const;
146 Tool *getAssemble()
const;
147 Tool *getLink()
const;
148 Tool *getIfsMerge()
const;
149 Tool *getClangAs()
const;
150 Tool *getOffloadBundler()
const;
151 Tool *getOffloadWrapper()
const;
153 mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
154 mutable std::unique_ptr<XRayArgs> XRayArguments;
157 mutable llvm::Triple EffectiveTriple;
160 void setEffectiveTriple(llvm::Triple ET)
const {
161 EffectiveTriple = std::move(ET);
169 const llvm::opt::ArgList &Args);
171 void setTripleEnvironment(llvm::Triple::EnvironmentType Env);
173 virtual Tool *buildAssembler()
const;
174 virtual Tool *buildLinker()
const;
179 static void addSystemInclude(
const llvm::opt::ArgList &DriverArgs,
180 llvm::opt::ArgStringList &CC1Args,
182 static void addExternCSystemInclude(
const llvm::opt::ArgList &DriverArgs,
183 llvm::opt::ArgStringList &CC1Args,
186 addExternCSystemIncludeIfExists(
const llvm::opt::ArgList &DriverArgs,
187 llvm::opt::ArgStringList &CC1Args,
189 static void addSystemIncludes(
const llvm::opt::ArgList &DriverArgs,
190 llvm::opt::ArgStringList &CC1Args,
200 llvm::vfs::FileSystem &getVFS()
const;
201 const llvm::Triple &
getTriple()
const {
return Triple; }
213 virtual std::string getInputFilename(
const InputInfo &Input)
const;
215 llvm::Triple::ArchType
getArch()
const {
return Triple.getArch(); }
218 StringRef
getOS()
const {
return Triple.getOSName(); }
222 StringRef getDefaultUniversalArchName()
const;
225 return Triple.getTriple();
230 assert(!EffectiveTriple.getTriple().empty() &&
"No effective triple");
231 return EffectiveTriple;
249 const XRayArgs& getXRayArgs()
const;
252 const llvm::opt::Arg *
getRTTIArg()
const {
return CachedRTTIArg; }
271 static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName);
283 virtual llvm::opt::DerivedArgList *
292 virtual llvm::opt::DerivedArgList *TranslateOpenMPTargetArgs(
293 const llvm::opt::DerivedArgList &Args,
bool SameTripleAsHost,
304 std::string GetFilePath(
const char *Name)
const;
305 std::string GetProgramPath(
const char *Name)
const;
309 std::string GetLinkerPath()
const;
322 virtual bool isCrossCompiling()
const;
326 virtual bool HasNativeLLVMSupport()
const;
330 virtual types::ID LookupTypeForExtension(StringRef Ext)
const;
340 virtual bool useIntegratedAs()
const;
358 virtual bool useRelaxRelocations()
const;
377 return ToolChain::RLT_Libgcc;
381 return ToolChain::CST_Libstdcxx;
385 return ToolChain::UNW_None;
388 virtual std::string getCompilerRTPath()
const;
390 virtual std::string getCompilerRT(
const llvm::opt::ArgList &Args,
395 getCompilerRTArgString(
const llvm::opt::ArgList &Args, StringRef Component,
406 std::string getArchSpecificLibPath()
const;
409 StringRef getOSLibName()
const;
412 static bool needsProfileRT(
const llvm::opt::ArgList &Args);
415 static bool needsGCovInstrumentation(
const llvm::opt::ArgList &Args);
419 virtual bool IsUnwindTablesDefault(
const llvm::opt::ArgList &Args)
const;
422 virtual bool isPICDefault()
const = 0;
425 virtual bool isPIEDefault()
const = 0;
428 virtual bool isNoExecStackDefault()
const;
434 virtual bool isPICDefaultForced()
const = 0;
463 return llvm::DebuggerKind::GDB;
473 const llvm::opt::ArgList &Args)
const {}
476 virtual llvm::ExceptionHandling
477 GetExceptionModel(
const llvm::opt::ArgList &Args)
const;
486 virtual bool isThreadModelSupported(
const StringRef Model)
const;
491 ComputeLLVMTriple(
const llvm::opt::ArgList &Args,
499 virtual std::string ComputeEffectiveClangTriple(
500 const llvm::opt::ArgList &Args,
507 virtual ObjCRuntime getDefaultObjCRuntime(
bool isNonFragile)
const;
521 AddClangSystemIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
522 llvm::opt::ArgStringList &CC1Args)
const;
525 virtual void addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs,
526 llvm::opt::ArgStringList &CC1Args,
530 virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args)
const;
535 GetRuntimeLibType(
const llvm::opt::ArgList &Args)
const;
539 virtual CXXStdlibType GetCXXStdlibType(
const llvm::opt::ArgList &Args)
const;
543 virtual UnwindLibType GetUnwindLibType(
const llvm::opt::ArgList &Args)
const;
548 AddClangCXXStdlibIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
549 llvm::opt::ArgStringList &CC1Args)
const;
553 void AddClangCXXStdlibIsystemArgs(
const llvm::opt::ArgList &DriverArgs,
554 llvm::opt::ArgStringList &CC1Args)
const;
558 bool ShouldLinkCXXStdlib(
const llvm::opt::ArgList &Args)
const;
562 virtual void AddCXXStdlibLibArgs(
const llvm::opt::ArgList &Args,
563 llvm::opt::ArgStringList &CmdArgs)
const;
566 void AddFilePathLibArgs(
const llvm::opt::ArgList &Args,
567 llvm::opt::ArgStringList &CmdArgs)
const;
571 virtual void AddCCKextLibArgs(
const llvm::opt::ArgList &Args,
572 llvm::opt::ArgStringList &CmdArgs)
const;
578 virtual bool AddFastMathRuntimeIfAvailable(
579 const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
const;
583 virtual void addProfileRTLibs(
const llvm::opt::ArgList &Args,
584 llvm::opt::ArgStringList &CmdArgs)
const;
587 virtual void AddCudaIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
588 llvm::opt::ArgStringList &CC1Args)
const;
591 virtual void AddIAMCUIncludeArgs(
const llvm::opt::ArgList &DriverArgs,
592 llvm::opt::ArgStringList &CC1Args)
const;
595 virtual VersionTuple computeMSVCVersion(
const Driver *D,
596 const llvm::opt::ArgList &Args)
const;
618 TC.setEffectiveTriple(std::move(T));
628 #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()