clang 17.0.0git
MinGW.h
Go to the documentation of this file.
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 "ROCm.h"
15#include "clang/Driver/Tool.h"
17#include "llvm/Support/ErrorOr.h"
18
19namespace clang {
20namespace driver {
21namespace tools {
22
23/// MinGW -- Directly call GNU Binutils assembler and linker
24namespace MinGW {
25class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
26public:
27 Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
28
29 bool hasIntegratedCPP() const override { return false; }
30
31 void ConstructJob(Compilation &C, const JobAction &JA,
32 const InputInfo &Output, const InputInfoList &Inputs,
33 const llvm::opt::ArgList &TCArgs,
34 const char *LinkingOutput) const override;
35};
36
37class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
38public:
39 Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
40
41 bool hasIntegratedCPP() const override { return false; }
42 bool isLinkJob() const override { return true; }
43
44 void ConstructJob(Compilation &C, const JobAction &JA,
45 const InputInfo &Output, const InputInfoList &Inputs,
46 const llvm::opt::ArgList &TCArgs,
47 const char *LinkingOutput) const override;
48
49private:
50 void AddLibGCC(const llvm::opt::ArgList &Args,
51 llvm::opt::ArgStringList &CmdArgs) const;
52};
53} // end namespace MinGW
54} // end namespace tools
55
56namespace toolchains {
57
58class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
59public:
60 MinGW(const Driver &D, const llvm::Triple &Triple,
61 const llvm::opt::ArgList &Args);
62
63 static void fixTripleArch(const Driver &D, llvm::Triple &Triple,
64 const llvm::opt::ArgList &Args);
65
66 bool HasNativeLLVMSupport() const override;
67
68 bool IsIntegratedAssemblerDefault() const override;
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
100protected:
101 Tool *getTool(Action::ActionClass AC) const override;
102 Tool *buildLinker() const override;
103 Tool *buildAssembler() const override;
104
105private:
106 CudaInstallationDetector CudaInstallation;
107 RocmInstallationDetector RocmInstallation;
108
109 std::string Base;
110 std::string GccLibDir;
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
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:128
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
A class to find a viable CUDA installation.
Definition: Cuda.h:27
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
A class to find a viable ROCM installation TODO: Generalize to handle libclc.
Definition: ROCm.h:47
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
unsigned GetDefaultDwarfVersion() const override
Definition: MinGW.h:98
bool hasIntegratedCPP() const override
Definition: MinGW.h:29
Assembler(const ToolChain &TC)
Definition: MinGW.h:27
bool hasIntegratedCPP() const override
Definition: MinGW.h:41
bool isLinkJob() const override
Definition: MinGW.h:42
Linker(const ToolChain &TC)
Definition: MinGW.h:39
Struct to store and manipulate GCC versions.
Definition: Gnu.h:162