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