| 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/CudaInstallationDetector.h" |
| 15 |
#include "clang/Driver/LazyDetector.h" |
| 16 |
#include "clang/Driver/RocmInstallationDetector.h" |
| 17 |
#include "clang/Driver/Tool.h" |
| 18 |
#include "clang/Driver/ToolChain.h" |
| 19 |
#include "llvm/Support/ErrorOr.h" |
| 20 |
|
| 21 |
namespace clang { |
| 22 |
namespace driver { |
| 23 |
namespace tools { |
| 24 |
|
| 25 |
/// Directly call GNU Binutils assembler and linker |
| 26 |
namespace MinGW { |
| 27 |
class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { |
| 28 |
public: |
| 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 |
|
| 39 |
class LLVM_LIBRARY_VISIBILITY Linker final : public Tool { |
| 40 |
public: |
| 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 |
|
| 51 |
private: |
| 52 |
void AddLibGCC(const llvm::opt::ArgList &Args, |
| 53 |
llvm::opt::ArgStringList &CmdArgs) const; |
| 54 |
}; |
| 55 |
} // end namespace MinGW |
| 56 |
} // end namespace tools |
| 57 |
|
| 58 |
namespace toolchains { |
| 59 |
|
| 60 |
class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain { |
| 61 |
public: |
| 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 |
|
| 70 |
UnwindTableLevel |
| 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 |
|
| 76 |
SanitizerMask getSupportedSanitizers() const override; |
| 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; |
| 88 |
void AddClangCXXStdlibIncludeArgs( |
| 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 |
|
| 101 |
protected: |
| 102 |
Tool *getTool(Action::ActionClass AC) const override; |
| 103 |
Tool *buildLinker() const override; |
| 104 |
Tool *buildAssembler() const override; |
| 105 |
|
| 106 |
private: |
| 107 |
LazyDetector<CudaInstallationDetector> CudaInstallation; |
| 108 |
LazyDetector<RocmInstallationDetector> RocmInstallation; |
| 109 |
|
| 110 |
std::string Base; |
| 111 |
std::string GccLibDir; |
| 112 |
clang::driver::toolchains::Generic_GCC::GCCVersion GccVer; |
| 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 |