1 //===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_H
14 #include "clang/Basic/VersionTuple.h"
15 #include "clang/Driver/Action.h"
16 #include "clang/Driver/Multilib.h"
17 #include "clang/Driver/ToolChain.h"
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/Optional.h"
20 #include "llvm/Support/Compiler.h"
26 namespace toolchains {
28 /// Generic_GCC - A tool chain using the 'gcc' command to perform
29 /// all subcommands; this relies on gcc translating the majority of
30 /// command line options.
31 class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
33 /// \brief Struct to store and manipulate GCC versions.
35 /// We rely on assumptions about the form and structure of GCC version
36 /// numbers: they consist of at most three '.'-separated components, and each
37 /// component is a non-negative integer except for the last component. For
38 /// the last component we are very flexible in order to tolerate release
39 /// candidates or 'x' wildcards.
41 /// Note that the ordering established among GCCVersions is based on the
42 /// preferred version string to use. For example we prefer versions without
43 /// a hard-coded patch number to those with a hard coded patch number.
45 /// Currently this doesn't provide any logic for textual suffixes to patches
46 /// in the way that (for example) Debian's version format does. If that ever
47 /// becomes necessary, it can be added.
49 /// \brief The unparsed text of the version.
52 /// \brief The parsed major, minor, and patch numbers.
53 int Major, Minor, Patch;
55 /// \brief The text of the parsed major, and major+minor versions.
56 std::string MajorStr, MinorStr;
58 /// \brief Any textual suffix on the patch number.
59 std::string PatchSuffix;
61 static GCCVersion Parse(StringRef VersionText);
62 bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch,
63 StringRef RHSPatchSuffix = StringRef()) const;
64 bool operator<(const GCCVersion &RHS) const {
65 return isOlderThan(RHS.Major, RHS.Minor, RHS.Patch, RHS.PatchSuffix);
67 bool operator>(const GCCVersion &RHS) const { return RHS < *this; }
68 bool operator<=(const GCCVersion &RHS) const { return !(*this > RHS); }
69 bool operator>=(const GCCVersion &RHS) const { return !(*this < RHS); }
72 /// \brief This is a class to find a viable GCC installation for Clang to
75 /// This class tries to find a GCC installation on the system, and report
76 /// information about it. It starts from the host information provided to the
77 /// Driver, and has logic for fuzzing that where appropriate.
78 class GCCInstallationDetector {
80 llvm::Triple GCCTriple;
82 // FIXME: These might be better as path objects.
83 std::string GCCInstallPath;
84 std::string GCCParentLibPath;
86 /// The primary multilib appropriate for the given flags.
87 Multilib SelectedMultilib;
88 /// On Biarch systems, this corresponds to the default multilib when
89 /// targeting the non-default multilib. Otherwise, it is empty.
90 llvm::Optional<Multilib> BiarchSibling;
94 // We retain the list of install paths that were considered and rejected in
95 // order to print out detailed information in verbose mode.
96 std::set<std::string> CandidateGCCInstallPaths;
98 /// The set of multilibs that the detected installation supports.
99 MultilibSet Multilibs;
102 GCCInstallationDetector() : IsValid(false) {}
103 void init(const Driver &D, const llvm::Triple &TargetTriple,
104 const llvm::opt::ArgList &Args);
106 /// \brief Check whether we detected a valid GCC install.
107 bool isValid() const { return IsValid; }
109 /// \brief Get the GCC triple for the detected install.
110 const llvm::Triple &getTriple() const { return GCCTriple; }
112 /// \brief Get the detected GCC installation path.
113 StringRef getInstallPath() const { return GCCInstallPath; }
115 /// \brief Get the detected GCC parent lib path.
116 StringRef getParentLibPath() const { return GCCParentLibPath; }
118 /// \brief Get the detected Multilib
119 const Multilib &getMultilib() const { return SelectedMultilib; }
121 /// \brief Get the whole MultilibSet
122 const MultilibSet &getMultilibs() const { return Multilibs; }
124 /// Get the biarch sibling multilib (if it exists).
125 /// \return true iff such a sibling exists
126 bool getBiarchSibling(Multilib &M) const;
128 /// \brief Get the detected GCC version string.
129 const GCCVersion &getVersion() const { return Version; }
131 /// \brief Print information about the detected GCC installation.
132 void print(raw_ostream &OS) const;
136 CollectLibDirsAndTriples(const llvm::Triple &TargetTriple,
137 const llvm::Triple &BiarchTriple,
138 SmallVectorImpl<StringRef> &LibDirs,
139 SmallVectorImpl<StringRef> &TripleAliases,
140 SmallVectorImpl<StringRef> &BiarchLibDirs,
141 SmallVectorImpl<StringRef> &BiarchTripleAliases);
143 void ScanLibDirForGCCTriple(const llvm::Triple &TargetArch,
144 const llvm::opt::ArgList &Args,
145 const std::string &LibDir,
146 StringRef CandidateTriple,
147 bool NeedsBiarchSuffix = false);
150 GCCInstallationDetector GCCInstallation;
153 Generic_GCC(const Driver &D, const llvm::Triple &Triple,
154 const llvm::opt::ArgList &Args);
155 ~Generic_GCC() override;
157 void printVerboseInfo(raw_ostream &OS) const override;
159 bool IsUnwindTablesDefault() const override;
160 bool isPICDefault() const override;
161 bool isPIEDefault() const override;
162 bool isPICDefaultForced() const override;
163 bool IsIntegratedAssemblerDefault() const override;
166 Tool *getTool(Action::ActionClass AC) const override;
167 Tool *buildAssembler() const override;
168 Tool *buildLinker() const override;
170 /// \name ToolChain Implementation Helper Functions
173 /// \brief Check whether the target triple's architecture is 64-bits.
174 bool isTarget64Bit() const { return getTriple().isArch64Bit(); }
176 /// \brief Check whether the target triple's architecture is 32-bits.
177 bool isTarget32Bit() const { return getTriple().isArch32Bit(); }
182 mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocess;
183 mutable std::unique_ptr<tools::gcc::Compiler> Compile;
186 class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
188 Tool *buildAssembler() const override;
189 Tool *buildLinker() const override;
190 Tool *getTool(Action::ActionClass AC) const override;
193 mutable std::unique_ptr<tools::darwin::Lipo> Lipo;
194 mutable std::unique_ptr<tools::darwin::Dsymutil> Dsymutil;
195 mutable std::unique_ptr<tools::darwin::VerifyDebug> VerifyDebug;
198 MachO(const Driver &D, const llvm::Triple &Triple,
199 const llvm::opt::ArgList &Args);
202 /// @name MachO specific toolchain API
205 /// Get the "MachO" arch name for a particular compiler invocation. For
206 /// example, Apple treats different ARM variations as distinct architectures.
207 StringRef getMachOArchName(const llvm::opt::ArgList &Args) const;
209 /// Add the linker arguments to link the ARC runtime library.
210 virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args,
211 llvm::opt::ArgStringList &CmdArgs) const {}
213 /// Add the linker arguments to link the compiler runtime library.
214 virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
215 llvm::opt::ArgStringList &CmdArgs) const;
217 virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
218 llvm::opt::ArgStringList &CmdArgs) const {
221 virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
222 llvm::opt::ArgStringList &CmdArgs) const {}
224 /// On some iOS platforms, kernel and kernel modules were built statically. Is
225 /// this such a target?
226 virtual bool isKernelStatic() const { return false; }
228 /// Is the target either iOS or an iOS simulator?
229 bool isTargetIOSBased() const { return false; }
231 void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
232 llvm::opt::ArgStringList &CmdArgs,
233 StringRef DarwinLibName, bool AlwaysLink = false,
234 bool IsEmbedded = false, bool AddRPath = false) const;
236 /// Add any profiling runtime libraries that are needed. This is essentially a
237 /// MachO specific version of addProfileRT in Tools.cpp.
238 virtual void addProfileRTLibs(const llvm::opt::ArgList &Args,
239 llvm::opt::ArgStringList &CmdArgs) const {
240 // There aren't any profiling libs for embedded targets currently.
244 /// @name ToolChain Implementation
247 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
248 types::ID InputType) const override;
250 types::ID LookupTypeForExtension(const char *Ext) const override;
252 bool HasNativeLLVMSupport() const override;
254 llvm::opt::DerivedArgList *
255 TranslateArgs(const llvm::opt::DerivedArgList &Args,
256 const char *BoundArch) const override;
258 bool IsBlocksDefault() const override {
259 // Always allow blocks on Apple; users interested in versioning are
260 // expected to use /usr/include/Block.h.
263 bool IsIntegratedAssemblerDefault() const override {
264 // Default integrated assembler to on for Apple's MachO targets.
268 bool IsMathErrnoDefault() const override { return false; }
270 bool IsEncodeExtendedBlockSignatureDefault() const override { return true; }
272 bool IsObjCNonFragileABIDefault() const override {
273 // Non-fragile ABI is default for everything but i386.
274 return getTriple().getArch() != llvm::Triple::x86;
277 bool UseObjCMixedDispatch() const override { return true; }
279 bool IsUnwindTablesDefault() const override;
281 RuntimeLibType GetDefaultRuntimeLibType() const override {
282 return ToolChain::RLT_CompilerRT;
285 bool isPICDefault() const override;
286 bool isPIEDefault() const override;
287 bool isPICDefaultForced() const override;
289 bool SupportsProfiling() const override;
291 bool SupportsObjCGC() const override { return false; }
293 bool UseDwarfDebugFlags() const override;
295 bool UseSjLjExceptions() const override { return false; }
300 /// Darwin - The base Darwin tool chain.
301 class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
303 /// Whether the information on the target has been initialized.
305 // FIXME: This should be eliminated. What we want to do is make this part of
306 // the "default target for arguments" selection process, once we get out of
307 // the argument translation business.
308 mutable bool TargetInitialized;
310 enum DarwinPlatformKind { MacOS, IPhoneOS, IPhoneOSSimulator };
312 mutable DarwinPlatformKind TargetPlatform;
314 /// The OS version we are targeting.
315 mutable VersionTuple TargetVersion;
318 void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
321 Darwin(const Driver &D, const llvm::Triple &Triple,
322 const llvm::opt::ArgList &Args);
325 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
326 types::ID InputType) const override;
328 /// @name Apple Specific Toolchain Implementation
331 void addMinVersionArgs(const llvm::opt::ArgList &Args,
332 llvm::opt::ArgStringList &CmdArgs) const override;
334 void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
335 llvm::opt::ArgStringList &CmdArgs) const override;
337 bool isKernelStatic() const override {
338 return !isTargetIPhoneOS() || isIPhoneOSVersionLT(6, 0);
341 void addProfileRTLibs(const llvm::opt::ArgList &Args,
342 llvm::opt::ArgStringList &CmdArgs) const override;
346 /// @name Darwin specific Toolchain functions
349 // FIXME: Eliminate these ...Target functions and derive separate tool chains
350 // for these targets and put version in constructor.
351 void setTarget(DarwinPlatformKind Platform, unsigned Major, unsigned Minor,
352 unsigned Micro) const {
353 // FIXME: For now, allow reinitialization as long as values don't
354 // change. This will go away when we move away from argument translation.
355 if (TargetInitialized && TargetPlatform == Platform &&
356 TargetVersion == VersionTuple(Major, Minor, Micro))
359 assert(!TargetInitialized && "Target already initialized!");
360 TargetInitialized = true;
361 TargetPlatform = Platform;
362 TargetVersion = VersionTuple(Major, Minor, Micro);
365 bool isTargetIPhoneOS() const {
366 assert(TargetInitialized && "Target not initialized!");
367 return TargetPlatform == IPhoneOS;
370 bool isTargetIOSSimulator() const {
371 assert(TargetInitialized && "Target not initialized!");
372 return TargetPlatform == IPhoneOSSimulator;
375 bool isTargetIOSBased() const {
376 assert(TargetInitialized && "Target not initialized!");
377 return isTargetIPhoneOS() || isTargetIOSSimulator();
380 bool isTargetMacOS() const {
381 assert(TargetInitialized && "Target not initialized!");
382 return TargetPlatform == MacOS;
385 bool isTargetInitialized() const { return TargetInitialized; }
387 VersionTuple getTargetVersion() const {
388 assert(TargetInitialized && "Target not initialized!");
389 return TargetVersion;
392 bool isIPhoneOSVersionLT(unsigned V0, unsigned V1 = 0,
393 unsigned V2 = 0) const {
394 assert(isTargetIOSBased() && "Unexpected call for non iOS target!");
395 return TargetVersion < VersionTuple(V0, V1, V2);
398 bool isMacosxVersionLT(unsigned V0, unsigned V1 = 0, unsigned V2 = 0) const {
399 assert(isTargetMacOS() && "Unexpected call for non OS X target!");
400 return TargetVersion < VersionTuple(V0, V1, V2);
405 /// @name ToolChain Implementation
408 // Darwin tools support multiple architecture (e.g., i386 and x86_64) and
409 // most development is done against SDKs, so compiling for a different
410 // architecture should not get any special treatment.
411 bool isCrossCompiling() const override { return false; }
413 llvm::opt::DerivedArgList *
414 TranslateArgs(const llvm::opt::DerivedArgList &Args,
415 const char *BoundArch) const override;
417 ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const override;
418 bool hasBlocksRuntime() const override;
420 bool UseObjCMixedDispatch() const override {
421 // This is only used with the non-fragile ABI and non-legacy dispatch.
423 // Mixed dispatch is used everywhere except OS X before 10.6.
424 return !(isTargetMacOS() && isMacosxVersionLT(10, 6));
427 unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
428 // Stack protectors default to on for user code on 10.5,
429 // and for everything in 10.6 and beyond
430 if (isTargetIOSBased())
432 else if (isTargetMacOS() && !isMacosxVersionLT(10, 6))
434 else if (isTargetMacOS() && !isMacosxVersionLT(10, 5) && !KernelOrKext)
440 bool SupportsObjCGC() const override;
442 void CheckObjCARC() const override;
444 bool UseSjLjExceptions() const override;
446 SanitizerMask getSupportedSanitizers() const override;
449 /// DarwinClang - The Darwin toolchain used by Clang.
450 class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
452 DarwinClang(const Driver &D, const llvm::Triple &Triple,
453 const llvm::opt::ArgList &Args);
455 /// @name Apple ToolChain Implementation
458 void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
459 llvm::opt::ArgStringList &CmdArgs) const override;
461 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
462 llvm::opt::ArgStringList &CmdArgs) const override;
464 void AddCCKextLibArgs(const llvm::opt::ArgList &Args,
465 llvm::opt::ArgStringList &CmdArgs) const override;
467 void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
469 void AddLinkARCArgs(const llvm::opt::ArgList &Args,
470 llvm::opt::ArgStringList &CmdArgs) const override;
474 void AddLinkSanitizerLibArgs(const llvm::opt::ArgList &Args,
475 llvm::opt::ArgStringList &CmdArgs,
476 StringRef Sanitizer) const;
479 class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
480 virtual void anchor();
483 Generic_ELF(const Driver &D, const llvm::Triple &Triple,
484 const llvm::opt::ArgList &Args)
485 : Generic_GCC(D, Triple, Args) {}
487 void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
488 llvm::opt::ArgStringList &CC1Args) const override;
491 class LLVM_LIBRARY_VISIBILITY CloudABI : public Generic_ELF {
493 CloudABI(const Driver &D, const llvm::Triple &Triple,
494 const llvm::opt::ArgList &Args);
495 bool HasNativeLLVMSupport() const override { return true; }
497 bool IsMathErrnoDefault() const override { return false; }
498 bool IsObjCNonFragileABIDefault() const override { return true; }
501 GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
502 return ToolChain::CST_Libcxx;
504 void AddClangCXXStdlibIncludeArgs(
505 const llvm::opt::ArgList &DriverArgs,
506 llvm::opt::ArgStringList &CC1Args) const override;
507 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
508 llvm::opt::ArgStringList &CmdArgs) const override;
510 bool isPIEDefault() const override { return false; }
513 Tool *buildLinker() const override;
516 class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC {
518 Solaris(const Driver &D, const llvm::Triple &Triple,
519 const llvm::opt::ArgList &Args);
521 bool IsIntegratedAssemblerDefault() const override { return true; }
524 Tool *buildAssembler() const override;
525 Tool *buildLinker() const override;
528 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
530 MinGW(const Driver &D, const llvm::Triple &Triple,
531 const llvm::opt::ArgList &Args);
533 bool IsIntegratedAssemblerDefault() const override;
534 bool IsUnwindTablesDefault() const override;
535 bool isPICDefault() const override;
536 bool isPIEDefault() const override;
537 bool isPICDefaultForced() const override;
538 bool UseSEHExceptions() const;
541 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
542 llvm::opt::ArgStringList &CC1Args) const override;
543 void AddClangCXXStdlibIncludeArgs(
544 const llvm::opt::ArgList &DriverArgs,
545 llvm::opt::ArgStringList &CC1Args) const override;
548 Tool *getTool(Action::ActionClass AC) const override;
549 Tool *buildLinker() const override;
550 Tool *buildAssembler() const override;
554 std::string GccLibDir;
556 mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
557 mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
560 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
562 OpenBSD(const Driver &D, const llvm::Triple &Triple,
563 const llvm::opt::ArgList &Args);
565 bool IsMathErrnoDefault() const override { return false; }
566 bool IsObjCNonFragileABIDefault() const override { return true; }
567 bool isPIEDefault() const override { return true; }
569 unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
574 Tool *buildAssembler() const override;
575 Tool *buildLinker() const override;
578 class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF {
580 Bitrig(const Driver &D, const llvm::Triple &Triple,
581 const llvm::opt::ArgList &Args);
583 bool IsMathErrnoDefault() const override { return false; }
584 bool IsObjCNonFragileABIDefault() const override { return true; }
586 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
587 void AddClangCXXStdlibIncludeArgs(
588 const llvm::opt::ArgList &DriverArgs,
589 llvm::opt::ArgStringList &CC1Args) const override;
590 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
591 llvm::opt::ArgStringList &CmdArgs) const override;
592 unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
597 Tool *buildAssembler() const override;
598 Tool *buildLinker() const override;
601 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
603 FreeBSD(const Driver &D, const llvm::Triple &Triple,
604 const llvm::opt::ArgList &Args);
605 bool HasNativeLLVMSupport() const override;
607 bool IsMathErrnoDefault() const override { return false; }
608 bool IsObjCNonFragileABIDefault() const override { return true; }
610 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
611 void AddClangCXXStdlibIncludeArgs(
612 const llvm::opt::ArgList &DriverArgs,
613 llvm::opt::ArgStringList &CC1Args) const override;
615 bool UseSjLjExceptions() const override;
616 bool isPIEDefault() const override;
617 SanitizerMask getSupportedSanitizers() const override;
620 Tool *buildAssembler() const override;
621 Tool *buildLinker() const override;
624 class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
626 NetBSD(const Driver &D, const llvm::Triple &Triple,
627 const llvm::opt::ArgList &Args);
629 bool IsMathErrnoDefault() const override { return false; }
630 bool IsObjCNonFragileABIDefault() const override { return true; }
632 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
634 void AddClangCXXStdlibIncludeArgs(
635 const llvm::opt::ArgList &DriverArgs,
636 llvm::opt::ArgStringList &CC1Args) const override;
637 bool IsUnwindTablesDefault() const override { return true; }
640 Tool *buildAssembler() const override;
641 Tool *buildLinker() const override;
644 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
646 Minix(const Driver &D, const llvm::Triple &Triple,
647 const llvm::opt::ArgList &Args);
650 Tool *buildAssembler() const override;
651 Tool *buildLinker() const override;
654 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
656 DragonFly(const Driver &D, const llvm::Triple &Triple,
657 const llvm::opt::ArgList &Args);
659 bool IsMathErrnoDefault() const override { return false; }
662 Tool *buildAssembler() const override;
663 Tool *buildLinker() const override;
666 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
668 Linux(const Driver &D, const llvm::Triple &Triple,
669 const llvm::opt::ArgList &Args);
671 bool HasNativeLLVMSupport() const override;
674 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
675 llvm::opt::ArgStringList &CC1Args) const override;
676 void AddClangCXXStdlibIncludeArgs(
677 const llvm::opt::ArgList &DriverArgs,
678 llvm::opt::ArgStringList &CC1Args) const override;
679 bool isPIEDefault() const override;
680 SanitizerMask getSupportedSanitizers() const override;
683 std::vector<std::string> ExtraOpts;
686 Tool *buildAssembler() const override;
687 Tool *buildLinker() const override;
690 static bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix,
692 StringRef GCCMultiarchTriple,
693 StringRef TargetMultiarchTriple,
695 const llvm::opt::ArgList &DriverArgs,
696 llvm::opt::ArgStringList &CC1Args);
698 std::string computeSysRoot() const;
701 class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux {
703 GCCVersion GCCLibAndIncVersion;
704 Tool *buildAssembler() const override;
705 Tool *buildLinker() const override;
708 Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
709 const llvm::opt::ArgList &Args);
710 ~Hexagon_TC() override;
713 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
714 llvm::opt::ArgStringList &CC1Args) const override;
715 void AddClangCXXStdlibIncludeArgs(
716 const llvm::opt::ArgList &DriverArgs,
717 llvm::opt::ArgStringList &CC1Args) const override;
718 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
720 StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
722 static std::string GetGnuDir(const std::string &InstalledDir,
723 const llvm::opt::ArgList &Args);
725 static StringRef GetTargetCPU(const llvm::opt::ArgList &Args);
727 static const char *GetSmallDataThreshold(const llvm::opt::ArgList &Args);
729 static bool UsesG0(const char *smallDataThreshold);
732 class LLVM_LIBRARY_VISIBILITY NaCl_TC : public Generic_ELF {
734 NaCl_TC(const Driver &D, const llvm::Triple &Triple,
735 const llvm::opt::ArgList &Args);
738 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
739 llvm::opt::ArgStringList &CC1Args) const override;
740 void AddClangCXXStdlibIncludeArgs(
741 const llvm::opt::ArgList &DriverArgs,
742 llvm::opt::ArgStringList &CC1Args) const override;
744 CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
746 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
747 llvm::opt::ArgStringList &CmdArgs) const override;
749 bool IsIntegratedAssemblerDefault() const override { return false; }
751 // Get the path to the file containing NaCl's ARM macros. It lives in NaCl_TC
752 // because the AssembleARM tool needs a const char * that it can pass around
753 // and the toolchain outlives all the jobs.
754 const char *GetNaClArmMacrosPath() const { return NaClArmMacrosPath.c_str(); }
756 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
757 types::ID InputType) const override;
761 Tool *buildLinker() const override;
762 Tool *buildAssembler() const override;
765 std::string NaClArmMacrosPath;
768 /// TCEToolChain - A tool chain using the llvm bitcode tools to perform
769 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
770 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
772 TCEToolChain(const Driver &D, const llvm::Triple &Triple,
773 const llvm::opt::ArgList &Args);
774 ~TCEToolChain() override;
776 bool IsMathErrnoDefault() const override;
777 bool isPICDefault() const override;
778 bool isPIEDefault() const override;
779 bool isPICDefaultForced() const override;
782 class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
784 MSVCToolChain(const Driver &D, const llvm::Triple &Triple,
785 const llvm::opt::ArgList &Args);
787 bool IsIntegratedAssemblerDefault() const override;
788 bool IsUnwindTablesDefault() const override;
789 bool isPICDefault() const override;
790 bool isPIEDefault() const override;
791 bool isPICDefaultForced() const override;
794 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
795 llvm::opt::ArgStringList &CC1Args) const override;
796 void AddClangCXXStdlibIncludeArgs(
797 const llvm::opt::ArgList &DriverArgs,
798 llvm::opt::ArgStringList &CC1Args) const override;
800 bool getWindowsSDKDir(std::string &path, int &major, int &minor) const;
801 bool getWindowsSDKLibraryPath(std::string &path) const;
802 bool getVisualStudioInstallDir(std::string &path) const;
803 bool getVisualStudioBinariesFolder(const char *clangProgramPath,
804 std::string &path) const;
806 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
807 types::ID InputType) const override;
808 SanitizerMask getSupportedSanitizers() const override;
811 void AddSystemIncludeWithSubfolder(const llvm::opt::ArgList &DriverArgs,
812 llvm::opt::ArgStringList &CC1Args,
813 const std::string &folder,
814 const char *subfolder) const;
816 Tool *buildLinker() const override;
817 Tool *buildAssembler() const override;
820 class LLVM_LIBRARY_VISIBILITY CrossWindowsToolChain : public Generic_GCC {
822 CrossWindowsToolChain(const Driver &D, const llvm::Triple &T,
823 const llvm::opt::ArgList &Args);
825 bool IsIntegratedAssemblerDefault() const override { return true; }
826 bool IsUnwindTablesDefault() const override;
827 bool isPICDefault() const override;
828 bool isPIEDefault() const override;
829 bool isPICDefaultForced() const override;
831 unsigned int GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
836 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
837 llvm::opt::ArgStringList &CC1Args) const override;
838 void AddClangCXXStdlibIncludeArgs(
839 const llvm::opt::ArgList &DriverArgs,
840 llvm::opt::ArgStringList &CC1Args) const override;
841 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
842 llvm::opt::ArgStringList &CmdArgs) const override;
845 Tool *buildLinker() const override;
846 Tool *buildAssembler() const override;
849 class LLVM_LIBRARY_VISIBILITY XCore : public ToolChain {
851 XCore(const Driver &D, const llvm::Triple &Triple,
852 const llvm::opt::ArgList &Args);
855 Tool *buildAssembler() const override;
856 Tool *buildLinker() const override;
859 bool isPICDefault() const override;
860 bool isPIEDefault() const override;
861 bool isPICDefaultForced() const override;
862 bool SupportsProfiling() const override;
863 bool hasBlocksRuntime() const override;
865 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
866 llvm::opt::ArgStringList &CC1Args) const override;
867 void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
868 llvm::opt::ArgStringList &CC1Args) const override;
869 void AddClangCXXStdlibIncludeArgs(
870 const llvm::opt::ArgList &DriverArgs,
871 llvm::opt::ArgStringList &CC1Args) const override;
872 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
873 llvm::opt::ArgStringList &CmdArgs) const override;
876 /// SHAVEToolChain - A tool chain using the compiler installed by the the
877 // Movidius SDK into MV_TOOLS_DIR (which we assume will be copied to llvm's
878 // installation dir) to perform all subcommands.
879 class LLVM_LIBRARY_VISIBILITY SHAVEToolChain : public Generic_GCC {
881 SHAVEToolChain(const Driver &D, const llvm::Triple &Triple,
882 const llvm::opt::ArgList &Args);
883 ~SHAVEToolChain() override;
885 virtual Tool *SelectTool(const JobAction &JA) const override;
888 Tool *getTool(Action::ActionClass AC) const override;
889 Tool *buildAssembler() const override;
890 Tool *buildLinker() const override;
893 mutable std::unique_ptr<Tool> Compiler;
894 mutable std::unique_ptr<Tool> Assembler;
897 } // end namespace toolchains
898 } // end namespace driver
899 } // end namespace clang