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 9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H 10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H 11 12 #include "Cuda.h" 13 #include "Gnu.h" 14 #include "clang/Driver/Tool.h" 15 #include "clang/Driver/ToolChain.h" 16 17 namespace clang { 18 namespace driver { 19 namespace tools { 20 21 /// MinGW -- Directly call GNU Binutils assembler and linker 22 namespace MinGW { 23 class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { 24 public: 25 Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {} 26 27 bool hasIntegratedCPP() const override { return false; } 28 29 void ConstructJob(Compilation &C, const JobAction &JA, 30 const InputInfo &Output, const InputInfoList &Inputs, 31 const llvm::opt::ArgList &TCArgs, 32 const char *LinkingOutput) const override; 33 }; 34 35 class LLVM_LIBRARY_VISIBILITY Linker : public Tool { 36 public: 37 Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {} 38 39 bool hasIntegratedCPP() const override { return false; } 40 bool isLinkJob() const override { return true; } 41 42 void ConstructJob(Compilation &C, const JobAction &JA, 43 const InputInfo &Output, const InputInfoList &Inputs, 44 const llvm::opt::ArgList &TCArgs, 45 const char *LinkingOutput) const override; 46 47 private: 48 void AddLibGCC(const llvm::opt::ArgList &Args, 49 llvm::opt::ArgStringList &CmdArgs) const; 50 }; 51 } // end namespace MinGW 52 } // end namespace tools 53 54 namespace toolchains { 55 56 class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain { 57 public: 58 MinGW(const Driver &D, const llvm::Triple &Triple, 59 const llvm::opt::ArgList &Args); 60 61 bool HasNativeLLVMSupport() const override; 62 63 bool IsIntegratedAssemblerDefault() const override; 64 bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; 65 bool isPICDefault() const override; 66 bool isPIEDefault() const override; 67 bool isPICDefaultForced() const override; 68 69 SanitizerMask getSupportedSanitizers() const override; 70 71 llvm::ExceptionHandling GetExceptionModel( 72 const llvm::opt::ArgList &Args) const override; 73 74 void 75 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, 76 llvm::opt::ArgStringList &CC1Args) const override; 77 void AddClangCXXStdlibIncludeArgs( 78 const llvm::opt::ArgList &DriverArgs, 79 llvm::opt::ArgStringList &CC1Args) const override; 80 81 void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, 82 llvm::opt::ArgStringList &CC1Args) const override; 83 84 void printVerboseInfo(raw_ostream &OS) const override; 85 86 protected: 87 Tool *getTool(Action::ActionClass AC) const override; 88 Tool *buildLinker() const override; 89 Tool *buildAssembler() const override; 90 91 private: 92 CudaInstallationDetector CudaInstallation; 93 94 std::string Base; 95 std::string GccLibDir; 96 std::string Ver; 97 std::string Arch; 98 mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor; 99 mutable std::unique_ptr<tools::gcc::Compiler> Compiler; 100 void findGccLibDir(); 101 llvm::ErrorOr<std::string> findGcc(); 102 llvm::ErrorOr<std::string> findClangRelativeSysroot(); 103 104 bool NativeLLVMSupport; 105 }; 106 107 } // end namespace toolchains 108 } // end namespace driver 109 } // end namespace clang 110 111 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H 112