MinGW.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //===--- MinGW.h - MinGW ToolChain Implementations --------------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H
  9. #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H
  10. #include "Cuda.h"
  11. #include "Gnu.h"
  12. #include "ROCm.h"
  13. #include "clang/Driver/Tool.h"
  14. #include "clang/Driver/ToolChain.h"
  15. #include "llvm/Support/ErrorOr.h"
  16. namespace clang {
  17. namespace driver {
  18. namespace tools {
  19. /// MinGW -- Directly call GNU Binutils assembler and linker
  20. namespace MinGW {
  21. class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
  22. public:
  23. Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
  24. bool hasIntegratedCPP() const override { return false; }
  25. void ConstructJob(Compilation &C, const JobAction &JA,
  26. const InputInfo &Output, const InputInfoList &Inputs,
  27. const llvm::opt::ArgList &TCArgs,
  28. const char *LinkingOutput) const override;
  29. };
  30. class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
  31. public:
  32. Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
  33. bool hasIntegratedCPP() const override { return false; }
  34. bool isLinkJob() const override { return true; }
  35. void ConstructJob(Compilation &C, const JobAction &JA,
  36. const InputInfo &Output, const InputInfoList &Inputs,
  37. const llvm::opt::ArgList &TCArgs,
  38. const char *LinkingOutput) const override;
  39. private:
  40. void AddLibGCC(const llvm::opt::ArgList &Args,
  41. llvm::opt::ArgStringList &CmdArgs) const;
  42. };
  43. } // end namespace MinGW
  44. } // end namespace tools
  45. namespace toolchains {
  46. class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
  47. public:
  48. MinGW(const Driver &D, const llvm::Triple &Triple,
  49. const llvm::opt::ArgList &Args);
  50. static void fixTripleArch(const Driver &D, llvm::Triple &Triple,
  51. const llvm::opt::ArgList &Args);
  52. bool HasNativeLLVMSupport() const override;
  53. bool IsIntegratedAssemblerDefault() const override;
  54. bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
  55. bool isPICDefault() const override;
  56. bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
  57. bool isPICDefaultForced() const override;
  58. SanitizerMask getSupportedSanitizers() const override;
  59. llvm::ExceptionHandling GetExceptionModel(
  60. const llvm::opt::ArgList &Args) const override;
  61. void
  62. AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  63. llvm::opt::ArgStringList &CC1Args) const override;
  64. void AddClangCXXStdlibIncludeArgs(
  65. const llvm::opt::ArgList &DriverArgs,
  66. llvm::opt::ArgStringList &CC1Args) const override;
  67. void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  68. llvm::opt::ArgStringList &CC1Args) const override;
  69. void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
  70. llvm::opt::ArgStringList &CC1Args) const override;
  71. void printVerboseInfo(raw_ostream &OS) const override;
  72. unsigned GetDefaultDwarfVersion() const override { return 4; }
  73. protected:
  74. Tool *getTool(Action::ActionClass AC) const override;
  75. Tool *buildLinker() const override;
  76. Tool *buildAssembler() const override;
  77. private:
  78. CudaInstallationDetector CudaInstallation;
  79. RocmInstallationDetector RocmInstallation;
  80. std::string Base;
  81. std::string GccLibDir;
  82. std::string Ver;
  83. std::string SubdirName;
  84. mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
  85. mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
  86. void findGccLibDir();
  87. bool NativeLLVMSupport;
  88. };
  89. } // end namespace toolchains
  90. } // end namespace driver
  91. } // end namespace clang
  92. #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H