1//===--- ToolChains.h - ToolChain Implementations ---------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_ 11#define CLANG_LIB_DRIVER_TOOLCHAINS_H_ 12 13#include "Tools.h" 14#include "clang/Basic/VersionTuple.h" 15#include "clang/Driver/Action.h" 16#include "clang/Driver/ToolChain.h" 17#include "llvm/ADT/DenseMap.h" 18#include "llvm/Support/Compiler.h" 19#include <vector> 20#include <set> 21 22namespace clang { 23namespace driver { 24namespace toolchains { 25 26/// Generic_GCC - A tool chain using the 'gcc' command to perform 27/// all subcommands; this relies on gcc translating the majority of 28/// command line options. 29class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain { 30protected: 31 /// \brief Struct to store and manipulate GCC versions. 32 /// 33 /// We rely on assumptions about the form and structure of GCC version 34 /// numbers: they consist of at most three '.'-separated components, and each 35 /// component is a non-negative integer except for the last component. For 36 /// the last component we are very flexible in order to tolerate release 37 /// candidates or 'x' wildcards. 38 /// 39 /// Note that the ordering established among GCCVersions is based on the 40 /// preferred version string to use. For example we prefer versions without 41 /// a hard-coded patch number to those with a hard coded patch number. 42 /// 43 /// Currently this doesn't provide any logic for textual suffixes to patches 44 /// in the way that (for example) Debian's version format does. If that ever 45 /// becomes necessary, it can be added. 46 struct GCCVersion { 47 /// \brief The unparsed text of the version. 48 std::string Text; 49 50 /// \brief The parsed major, minor, and patch numbers. 51 int Major, Minor, Patch; 52 53 /// \brief The text of the parsed major, and major+minor versions. 54 std::string MajorStr, MinorStr; 55 56 /// \brief Any textual suffix on the patch number. 57 std::string PatchSuffix; 58 59 static GCCVersion Parse(StringRef VersionText); 60 bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch, 61 StringRef RHSPatchSuffix = StringRef()) const; 62 bool operator<(const GCCVersion &RHS) const { 63 return isOlderThan(RHS.Major, RHS.Minor, RHS.Patch, RHS.PatchSuffix); 64 } 65 bool operator>(const GCCVersion &RHS) const { return RHS < *this; } 66 bool operator<=(const GCCVersion &RHS) const { return !(*this > RHS); } 67 bool operator>=(const GCCVersion &RHS) const { return !(*this < RHS); } 68 }; 69 70 71 /// \brief This is a class to find a viable GCC installation for Clang to 72 /// use. 73 /// 74 /// This class tries to find a GCC installation on the system, and report 75 /// information about it. It starts from the host information provided to the 76 /// Driver, and has logic for fuzzing that where appropriate. 77 class GCCInstallationDetector { 78 bool IsValid; 79 const Driver &D; 80 llvm::Triple GCCTriple; 81 82 // FIXME: These might be better as path objects. 83 std::string GCCInstallPath; 84 std::string GCCBiarchSuffix; 85 std::string GCCParentLibPath; 86 std::string GCCMIPSABIDirSuffix; 87 88 GCCVersion Version; 89 90 // We retain the list of install paths that were considered and rejected in 91 // order to print out detailed information in verbose mode. 92 std::set<std::string> CandidateGCCInstallPaths; 93 94 public: 95 GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} 96 void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args); 97 98 /// \brief Check whether we detected a valid GCC install. 99 bool isValid() const { return IsValid; } 100 101 /// \brief Get the GCC triple for the detected install. 102 const llvm::Triple &getTriple() const { return GCCTriple; } 103 104 /// \brief Get the detected GCC installation path. 105 StringRef getInstallPath() const { return GCCInstallPath; } 106 107 /// \brief Get the detected GCC installation path suffix for the bi-arch 108 /// target variant. 109 StringRef getBiarchSuffix() const { return GCCBiarchSuffix; } 110 111 /// \brief Get the detected GCC parent lib path. 112 StringRef getParentLibPath() const { return GCCParentLibPath; } 113 114 /// \brief Get the detected GCC MIPS ABI directory suffix. 115 /// 116 /// This is used as a suffix both to the install directory of GCC and as 117 /// a suffix to its parent lib path in order to select a MIPS ABI-specific 118 /// subdirectory. 119 /// 120 /// This will always be empty for any non-MIPS target. 121 /// 122 // FIXME: This probably shouldn't exist at all, and should be factored 123 // into the multiarch and/or biarch support. Please don't add more uses of 124 // this interface, it is meant as a legacy crutch for the MIPS driver 125 // logic. 126 StringRef getMIPSABIDirSuffix() const { return GCCMIPSABIDirSuffix; } 127 128 /// \brief Get the detected GCC version string. 129 const GCCVersion &getVersion() const { return Version; } 130 131 /// \brief Print information about the detected GCC installation. 132 void print(raw_ostream &OS) const; 133 134 private: 135 static void 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); 142 143 void ScanLibDirForGCCTriple(llvm::Triple::ArchType TargetArch, 144 const llvm::opt::ArgList &Args, 145 const std::string &LibDir, 146 StringRef CandidateTriple, 147 bool NeedsBiarchSuffix = false); 148 149 void findMIPSABIDirSuffix(std::string &Suffix, 150 llvm::Triple::ArchType TargetArch, StringRef Path, 151 const llvm::opt::ArgList &Args); 152 }; 153 154 GCCInstallationDetector GCCInstallation; 155 156public: 157 Generic_GCC(const Driver &D, const llvm::Triple &Triple, 158 const llvm::opt::ArgList &Args); 159 ~Generic_GCC(); 160 161 virtual void printVerboseInfo(raw_ostream &OS) const; 162 163 virtual bool IsUnwindTablesDefault() const; 164 virtual bool isPICDefault() const; 165 virtual bool isPIEDefault() const; 166 virtual bool isPICDefaultForced() const; 167 virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 168 llvm::opt::ArgStringList &CC1Args) const; 169 170protected: 171 virtual Tool *getTool(Action::ActionClass AC) const; 172 virtual Tool *buildAssembler() const; 173 virtual Tool *buildLinker() const; 174 175 /// \name ToolChain Implementation Helper Functions 176 /// @{ 177 178 /// \brief Check whether the target triple's architecture is 64-bits. 179 bool isTarget64Bit() const { return getTriple().isArch64Bit(); } 180 181 /// \brief Check whether the target triple's architecture is 32-bits. 182 bool isTarget32Bit() const { return getTriple().isArch32Bit(); } 183 184 /// @} 185 186private: 187 mutable OwningPtr<tools::gcc::Preprocess> Preprocess; 188 mutable OwningPtr<tools::gcc::Precompile> Precompile; 189 mutable OwningPtr<tools::gcc::Compile> Compile; 190}; 191 192 /// Darwin - The base Darwin tool chain. 193class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain { 194public: 195 /// The host version. 196 unsigned DarwinVersion[3]; 197 198protected: 199 virtual Tool *buildAssembler() const; 200 virtual Tool *buildLinker() const; 201 virtual Tool *getTool(Action::ActionClass AC) const; 202 203private: 204 mutable OwningPtr<tools::darwin::Lipo> Lipo; 205 mutable OwningPtr<tools::darwin::Dsymutil> Dsymutil; 206 mutable OwningPtr<tools::darwin::VerifyDebug> VerifyDebug; 207 208 /// Whether the information on the target has been initialized. 209 // 210 // FIXME: This should be eliminated. What we want to do is make this part of 211 // the "default target for arguments" selection process, once we get out of 212 // the argument translation business. 213 mutable bool TargetInitialized; 214 215 /// Whether we are targeting iPhoneOS target. 216 mutable bool TargetIsIPhoneOS; 217 218 /// Whether we are targeting the iPhoneOS simulator target. 219 mutable bool TargetIsIPhoneOSSimulator; 220 221 /// The OS version we are targeting. 222 mutable VersionTuple TargetVersion; 223 224private: 225 /// The default macosx-version-min of this tool chain; empty until 226 /// initialized. 227 std::string MacosxVersionMin; 228 229 /// The default ios-version-min of this tool chain; empty until 230 /// initialized. 231 std::string iOSVersionMin; 232 233private: 234 void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const; 235 236public: 237 Darwin(const Driver &D, const llvm::Triple &Triple, 238 const llvm::opt::ArgList &Args); 239 ~Darwin(); 240 241 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, 242 types::ID InputType) const; 243 244 /// @name Darwin Specific Toolchain API 245 /// { 246 247 // FIXME: Eliminate these ...Target functions and derive separate tool chains 248 // for these targets and put version in constructor. 249 void setTarget(bool IsIPhoneOS, unsigned Major, unsigned Minor, 250 unsigned Micro, bool IsIOSSim) const { 251 assert((!IsIOSSim || IsIPhoneOS) && "Unexpected deployment target!"); 252 253 // FIXME: For now, allow reinitialization as long as values don't 254 // change. This will go away when we move away from argument translation. 255 if (TargetInitialized && TargetIsIPhoneOS == IsIPhoneOS && 256 TargetIsIPhoneOSSimulator == IsIOSSim && 257 TargetVersion == VersionTuple(Major, Minor, Micro)) 258 return; 259 260 assert(!TargetInitialized && "Target already initialized!"); 261 TargetInitialized = true; 262 TargetIsIPhoneOS = IsIPhoneOS; 263 TargetIsIPhoneOSSimulator = IsIOSSim; 264 TargetVersion = VersionTuple(Major, Minor, Micro); 265 } 266 267 bool isTargetIPhoneOS() const { 268 assert(TargetInitialized && "Target not initialized!"); 269 return TargetIsIPhoneOS; 270 } 271 272 bool isTargetIOSSimulator() const { 273 assert(TargetInitialized && "Target not initialized!"); 274 return TargetIsIPhoneOSSimulator; 275 } 276 277 bool isTargetMacOS() const { 278 return !isTargetIOSSimulator() && !isTargetIPhoneOS(); 279 } 280 281 bool isTargetInitialized() const { return TargetInitialized; } 282 283 VersionTuple getTargetVersion() const { 284 assert(TargetInitialized && "Target not initialized!"); 285 return TargetVersion; 286 } 287 288 /// getDarwinArchName - Get the "Darwin" arch name for a particular compiler 289 /// invocation. For example, Darwin treats different ARM variations as 290 /// distinct architectures. 291 StringRef getDarwinArchName(const llvm::opt::ArgList &Args) const; 292 293 bool isIPhoneOSVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { 294 assert(isTargetIPhoneOS() && "Unexpected call for OS X target!"); 295 return TargetVersion < VersionTuple(V0, V1, V2); 296 } 297 298 bool isMacosxVersionLT(unsigned V0, unsigned V1=0, unsigned V2=0) const { 299 assert(!isTargetIPhoneOS() && "Unexpected call for iPhoneOS target!"); 300 return TargetVersion < VersionTuple(V0, V1, V2); 301 } 302 303 /// AddLinkARCArgs - Add the linker arguments to link the ARC runtime library. 304 virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args, 305 llvm::opt::ArgStringList &CmdArgs) const = 0; 306 307 /// AddLinkRuntimeLibArgs - Add the linker arguments to link the compiler 308 /// runtime library. 309 virtual void 310 AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args, 311 llvm::opt::ArgStringList &CmdArgs) const = 0; 312 313 /// } 314 /// @name ToolChain Implementation 315 /// { 316 317 virtual types::ID LookupTypeForExtension(const char *Ext) const; 318 319 virtual bool HasNativeLLVMSupport() const; 320 321 virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const; 322 virtual bool hasBlocksRuntime() const; 323 324 virtual llvm::opt::DerivedArgList * 325 TranslateArgs(const llvm::opt::DerivedArgList &Args, 326 const char *BoundArch) const; 327 328 virtual bool IsBlocksDefault() const { 329 // Always allow blocks on Darwin; users interested in versioning are 330 // expected to use /usr/include/Blocks.h. 331 return true; 332 } 333 virtual bool IsIntegratedAssemblerDefault() const { 334 // Default integrated assembler to on for Darwin. 335 return true; 336 } 337 338 virtual bool IsMathErrnoDefault() const { 339 return false; 340 } 341 342 virtual bool IsEncodeExtendedBlockSignatureDefault() const { 343 return true; 344 } 345 346 virtual bool IsObjCNonFragileABIDefault() const { 347 // Non-fragile ABI is default for everything but i386. 348 return getTriple().getArch() != llvm::Triple::x86; 349 } 350 351 virtual bool UseObjCMixedDispatch() const { 352 // This is only used with the non-fragile ABI and non-legacy dispatch. 353 354 // Mixed dispatch is used everywhere except OS X before 10.6. 355 return !(!isTargetIPhoneOS() && isMacosxVersionLT(10, 6)); 356 } 357 virtual bool IsUnwindTablesDefault() const; 358 virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { 359 // Stack protectors default to on for user code on 10.5, 360 // and for everything in 10.6 and beyond 361 return isTargetIPhoneOS() || 362 (!isMacosxVersionLT(10, 6) || 363 (!isMacosxVersionLT(10, 5) && !KernelOrKext)); 364 } 365 virtual RuntimeLibType GetDefaultRuntimeLibType() const { 366 return ToolChain::RLT_CompilerRT; 367 } 368 virtual bool isPICDefault() const; 369 virtual bool isPIEDefault() const; 370 virtual bool isPICDefaultForced() const; 371 372 virtual bool SupportsProfiling() const; 373 374 virtual bool SupportsObjCGC() const; 375 376 virtual void CheckObjCARC() const; 377 378 virtual bool UseDwarfDebugFlags() const; 379 380 virtual bool UseSjLjExceptions() const; 381 382 /// } 383}; 384 385/// DarwinClang - The Darwin toolchain used by Clang. 386class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin { 387public: 388 DarwinClang(const Driver &D, const llvm::Triple &Triple, 389 const llvm::opt::ArgList &Args); 390 391 /// @name Darwin ToolChain Implementation 392 /// { 393 394 virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args, 395 llvm::opt::ArgStringList &CmdArgs) const; 396 void AddLinkRuntimeLib(const llvm::opt::ArgList &Args, 397 llvm::opt::ArgStringList &CmdArgs, 398 const char *DarwinStaticLib, 399 bool AlwaysLink = false) const; 400 401 virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, 402 llvm::opt::ArgStringList &CmdArgs) const; 403 404 virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args, 405 llvm::opt::ArgStringList &CmdArgs) const; 406 407 virtual void AddLinkARCArgs(const llvm::opt::ArgList &Args, 408 llvm::opt::ArgStringList &CmdArgs) const; 409 /// } 410}; 411 412/// Darwin_Generic_GCC - Generic Darwin tool chain using gcc. 413class LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC { 414public: 415 Darwin_Generic_GCC(const Driver &D, const llvm::Triple &Triple, 416 const llvm::opt::ArgList &Args) 417 : Generic_GCC(D, Triple, Args) {} 418 419 std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, 420 types::ID InputType) const; 421 422 virtual bool isPICDefault() const { return false; } 423}; 424 425class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC { 426 virtual void anchor(); 427public: 428 Generic_ELF(const Driver &D, const llvm::Triple &Triple, 429 const llvm::opt::ArgList &Args) 430 : Generic_GCC(D, Triple, Args) {} 431 432 virtual bool IsIntegratedAssemblerDefault() const { 433 // Default integrated assembler to on for x86. 434 return (getTriple().getArch() == llvm::Triple::aarch64 || 435 getTriple().getArch() == llvm::Triple::x86 || 436 getTriple().getArch() == llvm::Triple::x86_64); 437 } 438}; 439 440class LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC { 441public: 442 AuroraUX(const Driver &D, const llvm::Triple &Triple, 443 const llvm::opt::ArgList &Args); 444 445protected: 446 virtual Tool *buildAssembler() const; 447 virtual Tool *buildLinker() const; 448}; 449 450class LLVM_LIBRARY_VISIBILITY Solaris : public Generic_GCC { 451public: 452 Solaris(const Driver &D, const llvm::Triple &Triple, 453 const llvm::opt::ArgList &Args); 454 455 virtual bool IsIntegratedAssemblerDefault() const { return true; } 456protected: 457 virtual Tool *buildAssembler() const; 458 virtual Tool *buildLinker() const; 459 460}; 461 462 463class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF { 464public: 465 OpenBSD(const Driver &D, const llvm::Triple &Triple, 466 const llvm::opt::ArgList &Args); 467 468 virtual bool IsMathErrnoDefault() const { return false; } 469 virtual bool IsObjCNonFragileABIDefault() const { return true; } 470 virtual bool isPIEDefault() const { return true; } 471 472 virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { 473 return 1; 474 } 475 476protected: 477 virtual Tool *buildAssembler() const; 478 virtual Tool *buildLinker() const; 479}; 480 481class LLVM_LIBRARY_VISIBILITY Bitrig : public Generic_ELF { 482public: 483 Bitrig(const Driver &D, const llvm::Triple &Triple, 484 const llvm::opt::ArgList &Args); 485 486 virtual bool IsMathErrnoDefault() const { return false; } 487 virtual bool IsObjCNonFragileABIDefault() const { return true; } 488 virtual bool IsObjCLegacyDispatchDefault() const { return false; } 489 490 virtual void 491 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 492 llvm::opt::ArgStringList &CC1Args) const; 493 virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, 494 llvm::opt::ArgStringList &CmdArgs) const; 495 virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const { 496 return 1; 497 } 498 499protected: 500 virtual Tool *buildAssembler() const; 501 virtual Tool *buildLinker() const; 502}; 503 504class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF { 505public: 506 FreeBSD(const Driver &D, const llvm::Triple &Triple, 507 const llvm::opt::ArgList &Args); 508 virtual bool HasNativeLLVMSupport() const; 509 510 virtual bool IsMathErrnoDefault() const { return false; } 511 virtual bool IsObjCNonFragileABIDefault() const { return true; } 512 513 virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; 514 virtual void 515 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 516 llvm::opt::ArgStringList &CC1Args) const; 517 virtual bool IsIntegratedAssemblerDefault() const { 518 if (getTriple().getArch() == llvm::Triple::ppc || 519 getTriple().getArch() == llvm::Triple::ppc64) 520 return true; 521 return Generic_ELF::IsIntegratedAssemblerDefault(); 522 } 523 524 virtual bool UseSjLjExceptions() const; 525protected: 526 virtual Tool *buildAssembler() const; 527 virtual Tool *buildLinker() const; 528}; 529 530class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF { 531public: 532 NetBSD(const Driver &D, const llvm::Triple &Triple, 533 const llvm::opt::ArgList &Args); 534 535 virtual bool IsMathErrnoDefault() const { return false; } 536 virtual bool IsObjCNonFragileABIDefault() const { return true; } 537 538 virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; 539 540 virtual void 541 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 542 llvm::opt::ArgStringList &CC1Args) const; 543 virtual bool IsUnwindTablesDefault() const { 544 return true; 545 } 546 virtual bool IsIntegratedAssemblerDefault() const { 547 if (getTriple().getArch() == llvm::Triple::ppc) 548 return true; 549 return Generic_ELF::IsIntegratedAssemblerDefault(); 550 } 551 552protected: 553 virtual Tool *buildAssembler() const; 554 virtual Tool *buildLinker() const; 555}; 556 557class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF { 558public: 559 Minix(const Driver &D, const llvm::Triple &Triple, 560 const llvm::opt::ArgList &Args); 561 562protected: 563 virtual Tool *buildAssembler() const; 564 virtual Tool *buildLinker() const; 565}; 566 567class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF { 568public: 569 DragonFly(const Driver &D, const llvm::Triple &Triple, 570 const llvm::opt::ArgList &Args); 571 572 virtual bool IsMathErrnoDefault() const { return false; } 573 574protected: 575 virtual Tool *buildAssembler() const; 576 virtual Tool *buildLinker() const; 577}; 578 579class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF { 580public: 581 Linux(const Driver &D, const llvm::Triple &Triple, 582 const llvm::opt::ArgList &Args); 583 584 virtual bool HasNativeLLVMSupport() const; 585 586 virtual void 587 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 588 llvm::opt::ArgStringList &CC1Args) const; 589 virtual void 590 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 591 llvm::opt::ArgStringList &CC1Args) const; 592 virtual bool isPIEDefault() const; 593 594 std::string Linker; 595 std::vector<std::string> ExtraOpts; 596 597protected: 598 virtual Tool *buildAssembler() const; 599 virtual Tool *buildLinker() const; 600 601private: 602 static bool addLibStdCXXIncludePaths(Twine Base, Twine Suffix, 603 Twine TargetArchDir, 604 Twine BiarchSuffix, 605 Twine MIPSABIDirSuffix, 606 const llvm::opt::ArgList &DriverArgs, 607 llvm::opt::ArgStringList &CC1Args); 608 static bool addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir, 609 const llvm::opt::ArgList &DriverArgs, 610 llvm::opt::ArgStringList &CC1Args); 611 612 std::string computeSysRoot() const; 613}; 614 615class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux { 616protected: 617 GCCVersion GCCLibAndIncVersion; 618 virtual Tool *buildAssembler() const; 619 virtual Tool *buildLinker() const; 620 621public: 622 Hexagon_TC(const Driver &D, const llvm::Triple &Triple, 623 const llvm::opt::ArgList &Args); 624 ~Hexagon_TC(); 625 626 virtual void 627 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 628 llvm::opt::ArgStringList &CC1Args) const; 629 virtual void 630 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 631 llvm::opt::ArgStringList &CC1Args) const; 632 virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const; 633 634 StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; } 635 636 static std::string GetGnuDir(const std::string &InstalledDir); 637 638 static StringRef GetTargetCPU(const llvm::opt::ArgList &Args); 639}; 640 641/// TCEToolChain - A tool chain using the llvm bitcode tools to perform 642/// all subcommands. See http://tce.cs.tut.fi for our peculiar target. 643class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain { 644public: 645 TCEToolChain(const Driver &D, const llvm::Triple &Triple, 646 const llvm::opt::ArgList &Args); 647 ~TCEToolChain(); 648 649 bool IsMathErrnoDefault() const; 650 bool isPICDefault() const; 651 bool isPIEDefault() const; 652 bool isPICDefaultForced() const; 653}; 654 655class LLVM_LIBRARY_VISIBILITY Windows : public ToolChain { 656public: 657 Windows(const Driver &D, const llvm::Triple &Triple, 658 const llvm::opt::ArgList &Args); 659 660 virtual bool IsIntegratedAssemblerDefault() const; 661 virtual bool IsUnwindTablesDefault() const; 662 virtual bool isPICDefault() const; 663 virtual bool isPIEDefault() const; 664 virtual bool isPICDefaultForced() const; 665 666 virtual void 667 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 668 llvm::opt::ArgStringList &CC1Args) const; 669 virtual void 670 AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 671 llvm::opt::ArgStringList &CC1Args) const; 672 673protected: 674 virtual Tool *buildLinker() const; 675 virtual Tool *buildAssembler() const; 676}; 677 678 679class LLVM_LIBRARY_VISIBILITY XCore : public ToolChain { 680public: 681 XCore(const Driver &D, const llvm::Triple &Triple, 682 const llvm::opt::ArgList &Args); 683protected: 684 virtual Tool *buildAssembler() const; 685 virtual Tool *buildLinker() const; 686public: 687 virtual bool isPICDefault() const; 688 virtual bool isPIEDefault() const; 689 virtual bool isPICDefaultForced() const; 690 virtual bool SupportsProfiling() const; 691 virtual bool hasBlocksRuntime() const; 692 virtual void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 693 llvm::opt::ArgStringList &CC1Args) const; 694 virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, 695 llvm::opt::ArgStringList &CC1Args) const; 696 virtual void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, 697 llvm::opt::ArgStringList &CC1Args) const; 698 virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, 699 llvm::opt::ArgStringList &CmdArgs) const; 700}; 701 702} // end namespace toolchains 703} // end namespace driver 704} // end namespace clang 705 706#endif 707