clang 22.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"
17#include "clang/Driver/Tool.h"
19#include "llvm/Support/ErrorOr.h"
20
21namespace clang {
22namespace driver {
23namespace tools {
24
25/// Directly call GNU Binutils assembler and linker
26namespace MinGW {
27class LLVM_LIBRARY_VISIBILITY Assembler : public Tool {
28public:
29 Assembler(const ToolChain &TC) : Tool("MinGW::Assemble", "assembler", TC) {}
30
31 bool hasIntegratedCPP() const override { return false; }
32
33 void ConstructJob(Compilation &C, const JobAction &JA,
34 const InputInfo &Output, const InputInfoList &Inputs,
35 const llvm::opt::ArgList &TCArgs,
36 const char *LinkingOutput) const override;
37};
38
39class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
40public:
41 Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {}
42
43 bool hasIntegratedCPP() const override { return false; }
44 bool isLinkJob() const override { return true; }
45
46 void ConstructJob(Compilation &C, const JobAction &JA,
47 const InputInfo &Output, const InputInfoList &Inputs,
48 const llvm::opt::ArgList &TCArgs,
49 const char *LinkingOutput) const override;
50
51private:
52 void AddLibGCC(const llvm::opt::ArgList &Args,
53 llvm::opt::ArgStringList &CmdArgs) const;
54};
55} // end namespace MinGW
56} // end namespace tools
57
58namespace toolchains {
59
60class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
61public:
62 MinGW(const Driver &D, const llvm::Triple &Triple,
63 const llvm::opt::ArgList &Args);
64
65 static void fixTripleArch(const Driver &D, llvm::Triple &Triple,
66 const llvm::opt::ArgList &Args);
67
68 bool HasNativeLLVMSupport() const override;
69
71 getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override;
72 bool isPICDefault() const override;
73 bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
74 bool isPICDefaultForced() const override;
75
77
78 llvm::ExceptionHandling GetExceptionModel(
79 const llvm::opt::ArgList &Args) const override;
80
81 void
82 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
83 llvm::opt::ArgStringList &CC1Args) const override;
84 void
85 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
86 llvm::opt::ArgStringList &CC1Args,
87 Action::OffloadKind DeviceOffloadKind) const override;
89 const llvm::opt::ArgList &DriverArgs,
90 llvm::opt::ArgStringList &CC1Args) const override;
91
92 void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
93 llvm::opt::ArgStringList &CC1Args) const override;
94 void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs,
95 llvm::opt::ArgStringList &CC1Args) const override;
96
97 void printVerboseInfo(raw_ostream &OS) const override;
98
99 unsigned GetDefaultDwarfVersion() const override { return 4; }
100
101protected:
102 Tool *getTool(Action::ActionClass AC) const override;
103 Tool *buildLinker() const override;
104 Tool *buildAssembler() const override;
105
106private:
109
110 std::string Base;
111 std::string GccLibDir;
113 std::string Ver;
114 std::string SubdirName;
115 std::string TripleDirName;
116 mutable std::unique_ptr<tools::gcc::Preprocessor> Preprocessor;
117 mutable std::unique_ptr<tools::gcc::Compiler> Compiler;
118 void findGccLibDir(const llvm::Triple &LiteralTriple);
119
120 bool NativeLLVMSupport;
121};
122
123} // end namespace toolchains
124} // end namespace driver
125} // end namespace clang
126
127#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:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:99
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:92
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition ToolChain.cpp:89
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:616
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition MinGW.cpp:724
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition MinGW.cpp:623
void printVerboseInfo(raw_ostream &OS) const override
Dispatch to the specific toolchain for verbose printing.
Definition MinGW.cpp:642
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition MinGW.cpp:637
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition MinGW.cpp:609
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific CUDA includes.
Definition MinGW.cpp:632
unsigned GetDefaultDwarfVersion() const override
Definition MinGW.h:99
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition MinGW.cpp:585
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition MinGW.cpp:604
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition MinGW.cpp:613
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:693
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:776
UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override
How detailed should the unwind tables be by default.
Definition MinGW.cpp:590
MinGW(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition MinGW.cpp:500
static void fixTripleArch(const Driver &D, llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition MinGW.cpp:879
bool hasIntegratedCPP() const override
Definition MinGW.h:31
Assembler(const ToolChain &TC)
Definition MinGW.h:29
bool hasIntegratedCPP() const override
Definition MinGW.h:43
bool isLinkJob() const override
Definition MinGW.h:44
Linker(const ToolChain &TC)
Definition MinGW.h:41
Directly call GNU Binutils assembler and linker.
Definition MinGW.h:26
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:50
The JSON file list parser is used to communicate input to InstallAPI.
Struct to store and manipulate GCC versions.
Definition Gnu.h:163