13 #include "llvm/Option/ArgList.h"
14 #include "llvm/Support/FileSystem.h"
15 #include "llvm/Support/Path.h"
17 using namespace clang::diag;
18 using namespace clang::driver;
19 using namespace clang::driver::toolchains;
20 using namespace clang;
21 using namespace llvm::opt;
25 bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
29 for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
30 LI = LI.increment(EC)) {
31 StringRef VersionText = llvm::sys::path::filename(LI->path());
33 Generic_GCC::GCCVersion::Parse(VersionText);
34 if (CandidateVersion.Major == -1)
36 if (CandidateVersion <= Version)
39 GccLibDir = LI->path();
45 void MinGW::findGccLibDir() {
47 Archs.emplace_back(getTriple().getArchName());
48 Archs[0] +=
"-w64-mingw32";
49 Archs.emplace_back(
"mingw32");
50 Arch = Archs[0].str();
53 for (StringRef CandidateLib : {
"lib",
"lib64"}) {
54 for (StringRef CandidateArch : Archs) {
56 llvm::sys::path::append(LibDir, CandidateLib,
"gcc", CandidateArch);
57 if (findGccVersion(LibDir, GccLibDir, Ver)) {
65 MinGW::MinGW(
const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args)
74 else if (llvm::ErrorOr<std::string> GPPName =
75 llvm::sys::findProgramByName(
"gcc"))
76 Base = llvm::sys::path::parent_path(
77 llvm::sys::path::parent_path(GPPName.get()));
79 Base = llvm::sys::path::parent_path(
getDriver().getInstalledDir());
87 Base += llvm::sys::path::get_separator();
93 (
Base + Arch + llvm::sys::path::get_separator() +
"lib").str());
110 return Compiler.get();
123 return getArch() == llvm::Triple::x86_64;
131 return getArch() == llvm::Triple::x86_64;
135 return getArch() == llvm::Triple::x86_64;
191 ArgStringList &CC1Args)
const {
192 if (DriverArgs.hasArg(options::OPT_nostdinc))
195 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
197 llvm::sys::path::append(P,
"include");
201 if (DriverArgs.hasArg(options::OPT_nostdlibinc))
206 llvm::sys::path::append(IncludeDir,
"include");
208 IncludeDir +=
"-fixed";
211 Base + Arch +
"/sys-root/mingw/include");
215 Base + Arch + llvm::sys::path::get_separator() +
"include");
220 ArgStringList &CC1Args)
const {
221 if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
222 DriverArgs.hasArg(options::OPT_nostdincxx))
228 Base +
"include" + llvm::sys::path::get_separator() +
229 "c++" + llvm::sys::path::get_separator() +
"v1");
234 CppIncludeBases.emplace_back(
Base);
235 llvm::sys::path::append(CppIncludeBases[0], Arch,
"include",
"c++");
236 CppIncludeBases.emplace_back(
Base);
237 llvm::sys::path::append(CppIncludeBases[1], Arch,
"include",
"c++", Ver);
238 CppIncludeBases.emplace_back(
Base);
239 llvm::sys::path::append(CppIncludeBases[2],
"include",
"c++", Ver);
240 CppIncludeBases.emplace_back(GccLibDir);
241 llvm::sys::path::append(CppIncludeBases[3],
"include",
"c++");
242 for (
auto &CppIncludeBase : CppIncludeBases) {
244 CppIncludeBase += llvm::sys::path::get_separator();
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
std::string SysRoot
sysroot, if present
Engages in a tight little dance with the lexer to efficiently preprocess tokens.