clang 24.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 "MSVC.h"
18#include "clang/Driver/Tool.h"
20#include "llvm/Support/ErrorOr.h"
21
22namespace clang {
23namespace driver {
24namespace tools {
25
26/// Directly call GNU Binutils assembler and linker
27namespace MinGW {
28class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
29public:
30 Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
31
32 bool hasIntegratedCPP() const override { return false; }
33
34 void ConstructJob(Compilation &C, const JobAction &JA,
35 const InputInfo &Output, const InputInfoList &Inputs,
36 const llvm::opt::ArgList &TCArgs,
37 const char *LinkingOutput) const override;
38};
39
40class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
41public:
42 Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
43
44 bool hasIntegratedCPP() const override { return false; }
45 bool isLinkJob() const override { return true; }
46
47 void ConstructJob(Compilation &C, const JobAction &JA,
48 const InputInfo &Output, const InputInfoList &Inputs,
49 const llvm::opt::ArgList &TCArgs,
50 const char *LinkingOutput) const override;
51
52private:
53 void AddLibGCC(const llvm::opt::ArgList &Args,
54 llvm::opt::ArgStringList &CmdArgs) const;
55};
56} // end namespace MinGW
57} // end namespace tools
58
59namespace toolchains {
60
61class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
62public:
63 MinGW(const Driver &D, const llvm::Triple &Triple,
64 const llvm::opt::ArgList &Args);
65
66 static void fixTripleArch(const Driver &D, llvm::Triple &Triple,
67 const llvm::opt::ArgList &Args);
68
69 bool HasNativeLLVMSupport() const override;
70
72 getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
73 bool isPICDefault() const override;
74 bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
75 bool isPICDefaultForced() const override;
76
79 Action::OffloadKind DeviceOffloadKind) const override;
80
81 llvm::ExceptionHandling GetExceptionModel(
82 const llvm::opt::ArgList &Args) const override;
83
84 void
85 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
86 llvm::opt::ArgStringList &CC1Args) const override;
87 void
88 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
89 llvm::opt::ArgStringList &CC1Args, BoundArch BA,
90 Action::OffloadKind DeviceOffloadKind) const override;
92 const llvm::opt::ArgList &DriverArgs,
93 llvm::opt::ArgStringList &CC1Args) const override;
94
95 void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
96 llvm::opt::ArgStringList &CC1Args) const override;
97 void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
98 llvm::opt::ArgStringList &CC1Args) const override;
99
100 void printVerboseInfo(raw_ostream &OS) const override;
101
102 unsigned GetDefaultDwarfVersion() const override { return 4; }
103
104protected:
105 Tool *getTool(Action::ActionClass AC) const override;
106 Tool *buildLinker() const override;
107 Tool *buildAssembler() const override;
108
109private:
112
113 std::string Base;
114 std::string GccLibDir;
116 std::string Ver;
117 std::string SubdirName;
118 std::string TripleDirName;
119 mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
120 mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
121 mutable std::unique_ptr<tools::ARM64XObjcopy> Objcopy;
122 void findGccLibDir(const llvm::Triple &LiteralTriple);
123
124 bool NativeLLVMSupport;
125};
126
127} // end namespace toolchains
128} // end namespace driver
129} // end namespace clang
130
131#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MINGW_H
Simple wrapper for toolchain detector with costly initialization.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:46
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:95
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:96
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition ToolChain.cpp:91
Tool - Information on a specific compilation tool.
Definition Tool.h:32
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Tool.cpp:14
llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override
GetExceptionModel - Return the tool chain exception model.
Definition MinGW.cpp:626
void printVerboseInfo(raw_ostream &OS) const override
Dispatch to the specific toolchain for verbose printing.
Definition MinGW.cpp:653
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition MinGW.cpp:648
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition MinGW.cpp:619
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific CUDA includes.
Definition MinGW.cpp:643
unsigned GetDefaultDwarfVersion() const override
Definition MinGW.h:102
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition MinGW.cpp:595
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition MinGW.cpp:614
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition MinGW.cpp:623
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition MinGW.cpp:704
void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition MinGW.cpp:802
SanitizerMask getSupportedSanitizers(BoundArch BA, Action::OffloadKind DeviceOffloadKind) const override
Return sanitizers which are available in this toolchain.
Definition MinGW.cpp:633
UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override
How detailed should the unwind tables be by default.
Definition MinGW.cpp:600
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, BoundArch BA, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition MinGW.cpp:750
MinGW(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition MinGW.cpp:504
static void fixTripleArch(const Driver &D, llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition MinGW.cpp:905
bool hasIntegratedCPP() const override
Definition MinGW.h:32
Assembler(const ToolChain &TC)
Definition MinGW.h:30
bool hasIntegratedCPP() const override
Definition MinGW.h:44
bool isLinkJob() const override
Definition MinGW.h:45
Linker(const ToolChain &TC)
Definition MinGW.h:42
Directly call GNU Binutils assembler and linker.
Definition MinGW.h:27
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:51
The JSON file list parser is used to communicate input to InstallAPI.
Represents a bound architecture for offload / multiple architecture compilation.
Struct to store and manipulate GCC versions.
Definition Gnu.h:163