clang 24.0.0git
MinGW.cpp
Go to the documentation of this file.
1//===--- MinGW.cpp - MinGWToolChain Implementation ------------------------===//
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#include "MinGW.h"
10#include "clang/Config/config.h"
13#include "clang/Driver/Driver.h"
17#include "llvm/Config/llvm-config.h" // for LLVM_HOST_TRIPLE
18#include "llvm/Option/ArgList.h"
19#include "llvm/Support/FileSystem.h"
20#include "llvm/Support/Path.h"
21#include "llvm/Support/VirtualFileSystem.h"
22#include <system_error>
23
24using namespace clang::diag;
25using namespace clang::driver;
26using namespace clang;
27using namespace llvm::opt;
28
29/// MinGW Tools
31 const InputInfo &Output,
32 const InputInfoList &Inputs,
33 const ArgList &Args,
34 const char *LinkingOutput) const {
35 claimNoWarnArgs(Args);
36 ArgStringList CmdArgs;
37
38 if (getToolChain().getArch() == llvm::Triple::x86) {
39 CmdArgs.push_back("--32");
40 } else if (getToolChain().getArch() == llvm::Triple::x86_64) {
41 CmdArgs.push_back("--64");
42 }
43
44 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
45
46 CmdArgs.push_back("-o");
47 CmdArgs.push_back(Output.getFilename());
48
49 for (const auto &II : Inputs)
50 CmdArgs.push_back(II.getFilename());
51
52 const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
53 C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
54 Exec, CmdArgs, Inputs, Output));
55
56 if (Args.hasArg(options::OPT_gsplit_dwarf))
57 SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
58 SplitDebugName(JA, Args, Inputs[0], Output));
59}
60
61void tools::MinGW::Linker::AddLibGCC(const ArgList &Args,
62 ArgStringList &CmdArgs) const {
63 bool NoLibc = Args.hasArg(options::OPT_nolibc);
64 if (Args.hasArg(options::OPT_mthreads))
65 CmdArgs.push_back("-lmingwthrd");
66 if (!NoLibc)
67 CmdArgs.push_back("-lmingw32");
68
69 // Make use of compiler-rt if --rtlib option is used
70 ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
71 if (RLT == ToolChain::RLT_Libgcc) {
72 bool Static = Args.hasArg(options::OPT_static_libgcc) ||
73 Args.hasArg(options::OPT_static);
74 bool Shared = Args.hasArg(options::OPT_shared);
75 bool CXX = getToolChain().getDriver().CCCIsCXX();
76
77 if (Static || (!CXX && !Shared)) {
78 CmdArgs.push_back("-lgcc");
79 CmdArgs.push_back("-lgcc_eh");
80 } else {
81 CmdArgs.push_back("-lgcc_s");
82 CmdArgs.push_back("-lgcc");
83 }
84 } else {
85 AddRunTimeLibs(getToolChain(), getToolChain().getDriver(), CmdArgs, Args);
86 }
87
88 if (!NoLibc) {
89 CmdArgs.push_back("-lmingwex");
90 for (auto Lib : Args.getAllArgValues(options::OPT_l)) {
91 if (StringRef(Lib).starts_with("msvcr") ||
92 StringRef(Lib).starts_with("ucrt") ||
93 StringRef(Lib).starts_with("crtdll")) {
94 std::string CRTLib = (llvm::Twine("-l") + Lib).str();
95 // Respect the user's chosen crt variant, but still provide it
96 // again as the last linker argument, because some of the libraries
97 // we added above may depend on it.
98 CmdArgs.push_back(Args.MakeArgStringRef(CRTLib));
99 return;
100 }
101 }
102 CmdArgs.push_back("-lmsvcrt");
103 }
104}
105
107 const InputInfo &Output,
108 const InputInfoList &Inputs,
109 const ArgList &Args,
110 const char *LinkingOutput) const {
111 const ToolChain &TC = getToolChain();
112 const Driver &D = TC.getDriver();
113 const SanitizerArgs &Sanitize = TC.getSanitizerArgs(Args);
114
115 ArgStringList CmdArgs;
116
117 // Silence warning for "clang -g foo.o -o foo"
118 Args.ClaimAllArgs(options::OPT_g_Group);
119 // and "clang -emit-llvm foo.o -o foo"
120 Args.ClaimAllArgs(options::OPT_emit_llvm);
121 // and for "clang -w foo.o -o foo". Other warning options are already
122 // handled somewhere else.
123 Args.ClaimAllArgs(options::OPT_w);
124
125 if (!D.SysRoot.empty())
126 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
127
128 if (Args.hasArg(options::OPT_s))
129 CmdArgs.push_back("-s");
130
131 CmdArgs.push_back("-m");
132 switch (TC.getArch()) {
133 case llvm::Triple::x86:
134 CmdArgs.push_back("i386pe");
135 break;
136 case llvm::Triple::x86_64:
137 CmdArgs.push_back("i386pep");
138 break;
139 case llvm::Triple::arm:
140 case llvm::Triple::thumb:
141 // FIXME: this is incorrect for WinCE
142 CmdArgs.push_back("thumb2pe");
143 break;
144 case llvm::Triple::aarch64:
145 if (Args.hasArg(options::OPT_marm64x))
146 CmdArgs.push_back("arm64xpe");
147 else if (TC.getEffectiveTriple().isWindowsArm64EC())
148 CmdArgs.push_back("arm64ecpe");
149 else
150 CmdArgs.push_back("arm64pe");
151 break;
152 case llvm::Triple::mipsel:
153 CmdArgs.push_back("mipspe");
154 break;
155 default:
156 D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str();
157 }
158
159 Arg *SubsysArg =
160 Args.getLastArg(options::OPT_mwindows, options::OPT_mconsole);
161 if (SubsysArg && SubsysArg->getOption().matches(options::OPT_mwindows)) {
162 CmdArgs.push_back("--subsystem");
163 CmdArgs.push_back("windows");
164 } else if (SubsysArg &&
165 SubsysArg->getOption().matches(options::OPT_mconsole)) {
166 CmdArgs.push_back("--subsystem");
167 CmdArgs.push_back("console");
168 }
169
170 if (Args.hasArg(options::OPT_mdll))
171 CmdArgs.push_back("--dll");
172 else if (Args.hasArg(options::OPT_shared))
173 CmdArgs.push_back("--shared");
174 if (Args.hasArg(options::OPT_static))
175 CmdArgs.push_back("-Bstatic");
176 else
177 CmdArgs.push_back("-Bdynamic");
178 if (Args.hasArg(options::OPT_mdll) || Args.hasArg(options::OPT_shared)) {
179 CmdArgs.push_back("-e");
180 if (TC.getArch() == llvm::Triple::x86)
181 CmdArgs.push_back("_DllMainCRTStartup@12");
182 else
183 CmdArgs.push_back("DllMainCRTStartup");
184 CmdArgs.push_back("--enable-auto-image-base");
185 }
186
187 if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
188 CmdArgs.push_back("--no-demangle");
189
190 if (!Args.hasFlag(options::OPT_fauto_import, options::OPT_fno_auto_import,
191 true))
192 CmdArgs.push_back("--disable-auto-import");
193
194 if (Arg *A = Args.getLastArg(options::OPT_mguard_EQ)) {
195 StringRef GuardArgs = A->getValue();
196 if (GuardArgs == "none")
197 CmdArgs.push_back("--no-guard-cf");
198 else if (GuardArgs == "cf" || GuardArgs == "cf-nochecks")
199 CmdArgs.push_back("--guard-cf");
200 else
201 D.Diag(diag::err_drv_unsupported_option_argument)
202 << A->getSpelling() << GuardArgs;
203 }
204
205 if (Args.hasArg(options::OPT_fms_hotpatch))
206 CmdArgs.push_back("--functionpadmin");
207
208 CmdArgs.push_back("-o");
209 const char *OutputFile = Output.getFilename();
210 // GCC implicitly adds an .exe extension if it is given an output file name
211 // that lacks an extension.
212 // GCC used to do this only when the compiler itself runs on windows, but
213 // since GCC 8 it does the same when cross compiling as well.
214 if (!llvm::sys::path::has_extension(OutputFile)) {
215 CmdArgs.push_back(Args.MakeArgString(Twine(OutputFile) + ".exe"));
216 OutputFile = CmdArgs.back();
217 } else
218 CmdArgs.push_back(OutputFile);
219
220 // FIXME: add -N, -n flags
221 Args.AddLastArg(CmdArgs, options::OPT_r);
222 Args.AddLastArg(CmdArgs, options::OPT_s);
223 Args.AddLastArg(CmdArgs, options::OPT_t);
224 Args.AddAllArgs(CmdArgs, options::OPT_u_Group);
225
226 // Add asan_dynamic as the first import lib before other libs. This allows
227 // asan to be initialized as early as possible to increase its instrumentation
228 // coverage to include other user DLLs which has not been built with asan.
229 if (Sanitize.needsAsanRt() && !Args.hasArg(options::OPT_nostdlib) &&
230 !Args.hasArg(options::OPT_nodefaultlibs)) {
231 // MinGW always links against a shared MSVCRT.
232 CmdArgs.push_back(
233 TC.getCompilerRTArgString(Args, "asan_dynamic", ToolChain::FT_Shared));
234 }
235
236 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
237 if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_mdll)) {
238 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("dllcrt2.o")));
239 } else {
240 if (Args.hasArg(options::OPT_municode))
241 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt2u.o")));
242 else
243 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt2.o")));
244 }
245 if (Args.hasArg(options::OPT_pg))
246 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("gcrt2.o")));
247 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtbegin.o")));
248 }
249
250 Args.AddAllArgs(CmdArgs, options::OPT_L);
251 TC.AddFilePathLibArgs(Args, CmdArgs);
252
253 // Add the compiler-rt library directories if they exist to help
254 // the linker find the various sanitizer, builtin, and profiling runtimes.
255 for (const auto &LibPath : TC.getLibraryPaths()) {
256 if (TC.getVFS().exists(LibPath))
257 CmdArgs.push_back(Args.MakeArgString("-L" + LibPath));
258 }
259 auto CRTPath = TC.getCompilerRTPath();
260 if (TC.getVFS().exists(CRTPath))
261 CmdArgs.push_back(Args.MakeArgString("-L" + CRTPath));
262
263 AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
264
265 if (auto LTO = TC.getLTOMode(Args); LTO != LTOK_None)
266 addLTOOptions(TC, Args, CmdArgs, Output, Inputs, LTO == LTOK_Thin);
267
268 if (C.getDriver().IsFlangMode() &&
269 !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
270 TC.addFortranRuntimeLibraryPath(Args, CmdArgs);
271 TC.addFortranRuntimeLibs(Args, CmdArgs);
272 }
273
274 // TODO: Add profile stuff here
275
276 if (TC.ShouldLinkCXXStdlib(Args)) {
277 bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
278 !Args.hasArg(options::OPT_static);
279 if (OnlyLibstdcxxStatic)
280 CmdArgs.push_back("-Bstatic");
281 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
282 if (OnlyLibstdcxxStatic)
283 CmdArgs.push_back("-Bdynamic");
284 }
285
286 bool HasWindowsApp = false;
287 for (auto Lib : Args.getAllArgValues(options::OPT_l)) {
288 if (Lib == "windowsapp") {
289 HasWindowsApp = true;
290 break;
291 }
292 }
293
294 bool NoLibc = Args.hasArg(options::OPT_nolibc);
295 if (!Args.hasArg(options::OPT_nostdlib)) {
296 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
297 if (Args.hasArg(options::OPT_static))
298 CmdArgs.push_back("--start-group");
299
300 if (Args.hasArg(options::OPT_fstack_protector) ||
301 Args.hasArg(options::OPT_fstack_protector_strong) ||
302 Args.hasArg(options::OPT_fstack_protector_all)) {
303 CmdArgs.push_back("-lssp_nonshared");
304 CmdArgs.push_back("-lssp");
305 }
306
307 if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
308 options::OPT_fno_openmp, false)) {
309 switch (TC.getDriver().getOpenMPRuntime(Args)) {
311 CmdArgs.push_back("-lomp");
312 break;
314 CmdArgs.push_back("-liomp5md");
315 break;
317 CmdArgs.push_back("-lgomp");
318 break;
320 // Already diagnosed.
321 break;
322 }
323 }
324
325 AddLibGCC(Args, CmdArgs);
326
327 if (Args.hasArg(options::OPT_pg))
328 CmdArgs.push_back("-lgmon");
329
330 if (Args.hasArg(options::OPT_pthread))
331 CmdArgs.push_back("-lpthread");
332
333 if (Sanitize.needsAsanRt()) {
334 // MinGW always links against a shared MSVCRT.
335 CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dynamic",
337 CmdArgs.push_back(
338 TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
339 CmdArgs.push_back("--require-defined");
340 CmdArgs.push_back(TC.getArch() == llvm::Triple::x86
341 ? "___asan_seh_interceptor"
342 : "__asan_seh_interceptor");
343 // Make sure the linker consider all object files from the dynamic
344 // runtime thunk.
345 CmdArgs.push_back("--whole-archive");
346 CmdArgs.push_back(
347 TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
348 CmdArgs.push_back("--no-whole-archive");
349 }
350
351 TC.addProfileRTLibs(Args, CmdArgs);
352
353 if (!HasWindowsApp && !NoLibc) {
354 // Add system libraries. If linking to libwindowsapp.a, that import
355 // library replaces all these and we shouldn't accidentally try to
356 // link to the normal desktop mode dlls.
357 if (Args.hasArg(options::OPT_mwindows)) {
358 CmdArgs.push_back("-lgdi32");
359 CmdArgs.push_back("-lcomdlg32");
360 }
361 CmdArgs.push_back("-ladvapi32");
362 CmdArgs.push_back("-lshell32");
363 CmdArgs.push_back("-luser32");
364 CmdArgs.push_back("-lkernel32");
365 }
366
367 if (Args.hasArg(options::OPT_static)) {
368 CmdArgs.push_back("--end-group");
369 } else {
370 AddLibGCC(Args, CmdArgs);
371 if (!HasWindowsApp && !NoLibc)
372 CmdArgs.push_back("-lkernel32");
373 }
374 }
375
376 if (!Args.hasArg(options::OPT_nostartfiles)) {
377 // Add crtfastmath.o if available and fast math is enabled.
378 TC.addFastMathRuntimeIfAvailable(Args, CmdArgs);
379
380 if (!Args.hasArg(options::OPT_mdll, options::OPT_shared)) {
381 if (auto O = TC.GetFilePathIfExists("default-manifest.o"))
382 CmdArgs.push_back(Args.MakeArgString(std::move(*O)));
383 }
384
385 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
386 }
387 }
388 const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
389 C.addCommand(std::make_unique<Command>(JA, *this,
391 Exec, CmdArgs, Inputs, Output));
392}
393
394static bool isCrossCompiling(const llvm::Triple &T, bool RequireArchMatch) {
395 llvm::Triple HostTriple(llvm::Triple::normalize(LLVM_HOST_TRIPLE));
396 if (HostTriple.getOS() != llvm::Triple::Win32)
397 return true;
398 if (RequireArchMatch && HostTriple.getArch() != T.getArch())
399 return true;
400 return false;
401}
402
403// Simplified from Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
404static bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
405 std::string &Ver,
408 std::error_code EC;
409 for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
410 LI = LI.increment(EC)) {
411 StringRef VersionText = llvm::sys::path::filename(LI->path());
412 auto CandidateVersion =
414 if (CandidateVersion.Major == -1)
415 continue;
416 if (CandidateVersion <= Version)
417 continue;
418 Version = CandidateVersion;
419 Ver = std::string(VersionText);
420 GccLibDir = LI->path();
421 }
422 return Ver.size();
423}
424
425static llvm::Triple getLiteralTriple(const Driver &D, const llvm::Triple &T) {
426 llvm::Triple LiteralTriple(D.getTargetTriple());
427 // The arch portion of the triple may be overridden by -m32/-m64.
428 LiteralTriple.setArchName(T.getArchName());
429 return LiteralTriple;
430}
431
432void toolchains::MinGW::findGccLibDir(const llvm::Triple &LiteralTriple) {
433 llvm::SmallVector<llvm::SmallString<32>, 5> SubdirNames;
434 SubdirNames.emplace_back(LiteralTriple.str());
435 SubdirNames.emplace_back(getTriple().str());
436 SubdirNames.emplace_back(getTriple().getArchName());
437 SubdirNames.back() += "-w64-mingw32";
438 SubdirNames.emplace_back(getTriple().getArchName());
439 SubdirNames.back() += "-w64-mingw32ucrt";
440 SubdirNames.emplace_back("mingw32");
441 if (SubdirName.empty()) {
442 SubdirName = getTriple().getArchName();
443 SubdirName += "-w64-mingw32";
444 }
445 // lib: Arch Linux, Ubuntu, Windows
446 // lib64: openSUSE Linux
447 for (StringRef CandidateLib : {"lib", "lib64"}) {
448 for (StringRef CandidateSysroot : SubdirNames) {
449 llvm::SmallString<1024> LibDir(Base);
450 llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
451 if (findGccVersion(LibDir, GccLibDir, Ver, GccVer)) {
452 SubdirName = std::string(CandidateSysroot);
453 return;
454 }
455 }
456 }
457}
458
459static llvm::ErrorOr<std::string> findGcc(const llvm::Triple &LiteralTriple,
460 const llvm::Triple &T) {
462 Gccs.emplace_back(LiteralTriple.str());
463 Gccs.back() += "-gcc";
464 Gccs.emplace_back(T.str());
465 Gccs.back() += "-gcc";
466 Gccs.emplace_back(T.getArchName());
467 Gccs.back() += "-w64-mingw32-gcc";
468 Gccs.emplace_back(T.getArchName());
469 Gccs.back() += "-w64-mingw32ucrt-gcc";
470 Gccs.emplace_back("mingw32-gcc");
471 // Please do not add "gcc" here
472 for (StringRef CandidateGcc : Gccs)
473 if (llvm::ErrorOr<std::string> GPPName = llvm::sys::findProgramByName(CandidateGcc))
474 return GPPName;
475 return make_error_code(std::errc::no_such_file_or_directory);
476}
477
478static llvm::ErrorOr<std::string>
479findClangRelativeSysroot(const Driver &D, const llvm::Triple &LiteralTriple,
480 const llvm::Triple &T, std::string &SubdirName) {
482 Subdirs.emplace_back(LiteralTriple.str());
483 // On ARM64EC targets, also try native aarch64 sysroot, which may contain
484 // support for both targets.
485 if (LiteralTriple.isWindowsArm64EC()) {
486 llvm::Triple NativeTriple(LiteralTriple);
487 NativeTriple.setArchName("aarch64");
488 Subdirs.emplace_back(NativeTriple.str());
489 }
490 Subdirs.emplace_back(T.str());
491 Subdirs.emplace_back(T.getArchName());
492 Subdirs.back() += "-w64-mingw32";
493 Subdirs.emplace_back(T.getArchName());
494 Subdirs.back() += "-w64-mingw32ucrt";
495 if (T.isWindowsArm64EC()) {
496 llvm::Triple NativeTriple(T);
497 NativeTriple.setArchName("aarch64");
498 Subdirs.emplace_back(NativeTriple.str());
499
500 Subdirs.emplace_back("aarch64-w64-mingw32");
501 Subdirs.emplace_back("aarch64-w64-mingw32ucrt");
502 }
503 StringRef ClangRoot = llvm::sys::path::parent_path(D.Dir);
504 StringRef Sep = llvm::sys::path::get_separator();
505 for (StringRef CandidateSubdir : Subdirs) {
506 if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
507 SubdirName = std::string(CandidateSubdir);
508 return (ClangRoot + Sep + CandidateSubdir).str();
509 }
510 }
511 return make_error_code(std::errc::no_such_file_or_directory);
512}
513
514static bool looksLikeMinGWSysroot(const std::string &Directory) {
515 StringRef Sep = llvm::sys::path::get_separator();
516 if (!llvm::sys::fs::exists(Directory + Sep + "include" + Sep + "_mingw.h"))
517 return false;
518 if (!llvm::sys::fs::exists(Directory + Sep + "lib" + Sep + "libkernel32.a"))
519 return false;
520 return true;
521}
522
523toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
524 const ArgList &Args)
525 : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args),
526 RocmInstallation(D, Triple, Args) {
527 getProgramPaths().push_back(getDriver().Dir);
528
529 std::string InstallBase =
530 std::string(llvm::sys::path::parent_path(getDriver().Dir));
531 // The sequence for detecting a sysroot here should be kept in sync with
532 // the testTriple function below.
533 llvm::Triple LiteralTriple = getLiteralTriple(D, getTriple());
534 if (getDriver().SysRoot.size())
535 Base = getDriver().SysRoot;
536 // Look for <clang-bin>/../<triplet>; if found, use <clang-bin>/.. as the
537 // base as it could still be a base for a gcc setup with libgcc.
538 else if (llvm::ErrorOr<std::string> TargetSubdir = findClangRelativeSysroot(
539 getDriver(), LiteralTriple, getTriple(), SubdirName))
540 Base = std::string(llvm::sys::path::parent_path(TargetSubdir.get()));
541 // If the install base of Clang seems to have mingw sysroot files directly
542 // in the toplevel include and lib directories, use this as base instead of
543 // looking for a triple prefixed GCC in the path.
544 else if (looksLikeMinGWSysroot(InstallBase))
545 Base = InstallBase;
546 else if (llvm::ErrorOr<std::string> GPPName =
547 findGcc(LiteralTriple, getTriple()))
548 Base = std::string(llvm::sys::path::parent_path(
549 llvm::sys::path::parent_path(GPPName.get())));
550 else
551 Base = InstallBase;
552
553 Base += llvm::sys::path::get_separator();
554 findGccLibDir(LiteralTriple);
555 TripleDirName = SubdirName;
556 // GccLibDir must precede Base/lib so that the
557 // correct crtbegin.o ,cetend.o would be found.
558 getFilePaths().push_back(GccLibDir);
559
560 // openSUSE/Fedora
561 std::string CandidateSubdir = SubdirName + "/sys-root/mingw";
562 if (getDriver().getVFS().exists(Base + CandidateSubdir))
563 SubdirName = CandidateSubdir;
564
565 getFilePaths().push_back(
566 (Base + SubdirName + llvm::sys::path::get_separator() + "lib").str());
567
568 // Gentoo
569 getFilePaths().push_back(
570 (Base + SubdirName + llvm::sys::path::get_separator() + "mingw/lib").str());
571
572 // Only include <base>/lib if we're not cross compiling (not even for
573 // windows->windows to a different arch), or if the sysroot has been set
574 // (where we presume the user has pointed it at an arch specific
575 // subdirectory).
576 if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/true) ||
577 getDriver().SysRoot.size())
578 getFilePaths().push_back(Base + "lib");
579
580 loadMultilibsFromYAML(Args, D);
581
582 NativeLLVMSupport =
583 Args.getLastArgValue(options::OPT_fuse_ld_EQ, D.getPreferredLinker())
584 .equals_insensitive("lld");
585}
586
588 switch (AC) {
590 if (!Preprocessor)
591 Preprocessor.reset(new tools::gcc::Preprocessor(*this));
592 return Preprocessor.get();
594 if (!Compiler)
595 Compiler.reset(new tools::gcc::Compiler(*this));
596 return Compiler.get();
598 if (!Objcopy)
599 Objcopy.reset(new tools::ARM64XObjcopy(*this));
600 return Objcopy.get();
601 default:
602 return ToolChain::getTool(AC);
603 }
604}
605
609
611 return new tools::MinGW::Linker(*this);
612}
613
615 return NativeLLVMSupport;
616}
617
620 Arg *ExceptionArg = Args.getLastArg(options::OPT_fsjlj_exceptions,
621 options::OPT_fseh_exceptions,
622 options::OPT_fdwarf_exceptions);
623 if (ExceptionArg &&
624 ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
626
627 if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::arm ||
628 getArch() == llvm::Triple::thumb || getArch() == llvm::Triple::aarch64)
631}
632
634 return getArch() == llvm::Triple::x86_64 ||
635 getArch() == llvm::Triple::aarch64;
636}
637
638bool toolchains::MinGW::isPIEDefault(const llvm::opt::ArgList &Args) const {
639 return false;
640}
641
642bool toolchains::MinGW::isPICDefaultForced() const { return true; }
643
644llvm::ExceptionHandling
645toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
646 if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::aarch64 ||
647 getArch() == llvm::Triple::arm || getArch() == llvm::Triple::thumb)
648 return llvm::ExceptionHandling::WinEH;
649 return llvm::ExceptionHandling::DwarfCFI;
650}
651
653 BoundArch BA, Action::OffloadKind DeviceOffloadKind) const {
654 SanitizerMask Res = ToolChain::getSupportedSanitizers(BA, DeviceOffloadKind);
655 Res |= SanitizerKind::Address;
656 Res |= SanitizerKind::PointerCompare;
657 Res |= SanitizerKind::PointerSubtract;
658 Res |= SanitizerKind::Vptr;
659 return Res;
660}
661
662void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
663 ArgStringList &CC1Args) const {
664 CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
665}
666
667void toolchains::MinGW::AddHIPIncludeArgs(const ArgList &DriverArgs,
668 ArgStringList &CC1Args) const {
669 RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
670}
671
672void toolchains::MinGW::printVerboseInfo(raw_ostream &OS) const {
673 CudaInstallation->print(OS);
674 RocmInstallation->print(OS);
675}
676
677// Include directories for various hosts:
678
679// Windows, mingw.org
680// c:\mingw\lib\gcc\mingw32\4.8.1\include\c++
681// c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\mingw32
682// c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\backward
683// c:\mingw\include
684// c:\mingw\mingw32\include
685
686// Windows, mingw-w64 mingw-builds
687// c:\mingw32\i686-w64-mingw32\include
688// c:\mingw32\i686-w64-mingw32\include\c++
689// c:\mingw32\i686-w64-mingw32\include\c++\i686-w64-mingw32
690// c:\mingw32\i686-w64-mingw32\include\c++\backward
691
692// Windows, mingw-w64 msys2
693// c:\msys64\mingw32\include
694// c:\msys64\mingw32\i686-w64-mingw32\include
695// c:\msys64\mingw32\include\c++\4.9.2
696// c:\msys64\mingw32\include\c++\4.9.2\i686-w64-mingw32
697// c:\msys64\mingw32\include\c++\4.9.2\backward
698
699// openSUSE
700// /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++
701// /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32
702// /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward
703// /usr/x86_64-w64-mingw32/sys-root/mingw/include
704
705// Arch Linux
706// /usr/i686-w64-mingw32/include/c++/5.1.0
707// /usr/i686-w64-mingw32/include/c++/5.1.0/i686-w64-mingw32
708// /usr/i686-w64-mingw32/include/c++/5.1.0/backward
709// /usr/i686-w64-mingw32/include
710
711// Ubuntu
712// /usr/include/c++/4.8
713// /usr/include/c++/4.8/x86_64-w64-mingw32
714// /usr/include/c++/4.8/backward
715// /usr/x86_64-w64-mingw32/include
716
717// Fedora
718// /usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/x86_64-w64-mingw32ucrt
719// /usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include/c++/backward
720// /usr/x86_64-w64-mingw32ucrt/sys-root/mingw/include
721// /usr/lib/gcc/x86_64-w64-mingw32ucrt/12.2.1/include-fixed
722
723void toolchains::MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
724 ArgStringList &CC1Args) const {
725 if (DriverArgs.hasArg(options::OPT_nostdinc))
726 return;
727
728 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
729 SmallString<1024> P(getDriver().ResourceDir);
730 llvm::sys::path::append(P, "include");
731 addSystemInclude(DriverArgs, CC1Args, P.str());
732 }
733
734 if (DriverArgs.hasArg(options::OPT_nostdlibinc))
735 return;
736
737 // Add multilib variant include paths in priority order.
738 for (const Multilib &M : getOrderedMultilibs()) {
739 if (M.isDefault())
740 continue;
741 if (std::optional<std::string> StdlibIncDir = getStdlibIncludePath()) {
742 SmallString<128> Dir(*StdlibIncDir);
743 llvm::sys::path::append(Dir, M.includeSuffix());
744 if (getDriver().getVFS().exists(Dir))
745 addSystemInclude(DriverArgs, CC1Args, Dir);
746 }
747 }
748
749 if (std::optional<std::string> Path = getStdlibIncludePath())
750 addSystemInclude(DriverArgs, CC1Args, *Path);
751
752 addSystemInclude(DriverArgs, CC1Args,
753 Base + SubdirName + llvm::sys::path::get_separator() +
754 "include");
755
756 // Gentoo
757 addSystemInclude(DriverArgs, CC1Args,
758 Base + SubdirName + llvm::sys::path::get_separator() + "usr/include");
759
760 // Only include <base>/include if we're not cross compiling (but do allow it
761 // if we're on Windows and building for Windows on another architecture),
762 // or if the sysroot has been set (where we presume the user has pointed it
763 // at an arch specific subdirectory).
764 if (!::isCrossCompiling(getTriple(), /*RequireArchMatch=*/false) ||
765 getDriver().SysRoot.size())
766 addSystemInclude(DriverArgs, CC1Args, Base + "include");
767}
768
770 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
771 BoundArch BA, Action::OffloadKind DeviceOffloadKind) const {
772 if (Arg *A = DriverArgs.getLastArg(options::OPT_mguard_EQ)) {
773 StringRef GuardArgs = A->getValue();
774 if (GuardArgs == "none") {
775 // Do nothing.
776 } else if (GuardArgs == "cf") {
777 // Emit CFG instrumentation and the table of address-taken functions.
778 CC1Args.push_back("-cfguard");
779 } else if (GuardArgs == "cf-nochecks") {
780 // Emit only the table of address-taken functions.
781 CC1Args.push_back("-cfguard-no-checks");
782 } else {
783 getDriver().Diag(diag::err_drv_unsupported_option_argument)
784 << A->getSpelling() << GuardArgs;
785 }
786 }
787
788 // Default to not enabling sized deallocation, but let user provided options
789 // override it.
790 //
791 // If using sized deallocation, user code that invokes delete will end up
792 // calling delete(void*,size_t). If the user wanted to override the
793 // operator delete(void*), there may be a fallback operator
794 // delete(void*,size_t) which calls the regular operator delete(void*).
795 //
796 // However, if the C++ standard library is linked in the form of a DLL,
797 // and the fallback operator delete(void*,size_t) is within this DLL (which is
798 // the case for libc++ at least) it will only redirect towards the library's
799 // default operator delete(void*), not towards the user's provided operator
800 // delete(void*).
801 //
802 // This issue can be avoided, if the fallback operators are linked statically
803 // into the callers, even if the C++ standard library is linked as a DLL.
804 //
805 // This is meant as a temporary workaround until libc++ implements this
806 // technique, which is tracked in
807 // https://github.com/llvm/llvm-project/issues/96899.
808 if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation,
809 options::OPT_fno_sized_deallocation))
810 CC1Args.push_back("-fno-sized-deallocation");
811
812 CC1Args.push_back("-fno-use-init-array");
813
814 for (auto Opt : {options::OPT_mthreads, options::OPT_mwindows,
815 options::OPT_mconsole, options::OPT_mdll}) {
816 if (Arg *A = DriverArgs.getLastArgNoClaim(Opt))
817 A->ignoreTargetSpecific();
818 }
819}
820
822 const ArgList &DriverArgs, ArgStringList &CC1Args) const {
823 if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
824 options::OPT_nostdincxx))
825 return;
826
827 StringRef Slash = llvm::sys::path::get_separator();
828
829 switch (GetCXXStdlibType(DriverArgs)) {
831 std::string TargetDir = (Base + "include" + Slash + getTripleString() +
832 Slash + "c++" + Slash + "v1")
833 .str();
834 if (getDriver().getVFS().exists(TargetDir))
835 addSystemInclude(DriverArgs, CC1Args, TargetDir);
836 addSystemInclude(DriverArgs, CC1Args,
837 Base + SubdirName + Slash + "include" + Slash + "c++" +
838 Slash + "v1");
839 addSystemInclude(DriverArgs, CC1Args,
840 Base + "include" + Slash + "c++" + Slash + "v1");
841 break;
842 }
843
846 CppIncludeBases.emplace_back(Base);
847 llvm::sys::path::append(CppIncludeBases[0], SubdirName, "include", "c++");
848 CppIncludeBases.emplace_back(Base);
849 llvm::sys::path::append(CppIncludeBases[1], SubdirName, "include", "c++",
850 Ver);
851 CppIncludeBases.emplace_back(Base);
852 llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
853 CppIncludeBases.emplace_back(GccLibDir);
854 llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
855 CppIncludeBases.emplace_back(GccLibDir);
856 llvm::sys::path::append(CppIncludeBases[4], "include",
857 "g++-v" + GccVer.Text);
858 CppIncludeBases.emplace_back(GccLibDir);
859 llvm::sys::path::append(CppIncludeBases[5], "include",
860 "g++-v" + GccVer.MajorStr + "." + GccVer.MinorStr);
861 CppIncludeBases.emplace_back(GccLibDir);
862 llvm::sys::path::append(CppIncludeBases[6], "include",
863 "g++-v" + GccVer.MajorStr);
864 for (auto &CppIncludeBase : CppIncludeBases) {
865 addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
866 CppIncludeBase += Slash;
867 addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + TripleDirName);
868 addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + "backward");
869 }
870 break;
871 }
872}
873
874static bool testTriple(const Driver &D, const llvm::Triple &Triple,
875 const ArgList &Args) {
876 // If an explicit sysroot is set, that will be used and we shouldn't try to
877 // detect anything else.
878 std::string SubdirName;
879 if (D.SysRoot.size())
880 return true;
881 llvm::Triple LiteralTriple = getLiteralTriple(D, Triple);
882 std::string InstallBase = std::string(llvm::sys::path::parent_path(D.Dir));
883 if (llvm::ErrorOr<std::string> TargetSubdir =
884 findClangRelativeSysroot(D, LiteralTriple, Triple, SubdirName))
885 return true;
886 // If the install base itself looks like a mingw sysroot, we'll use that
887 // - don't use any potentially unrelated gcc to influence what triple to use.
888 if (looksLikeMinGWSysroot(InstallBase))
889 return false;
890 if (llvm::ErrorOr<std::string> GPPName = findGcc(LiteralTriple, Triple))
891 return true;
892 // If we neither found a colocated sysroot or a matching gcc executable,
893 // conclude that we can't know if this is the correct spelling of the triple.
894 return false;
895}
896
897static llvm::Triple adjustTriple(const Driver &D, const llvm::Triple &Triple,
898 const ArgList &Args) {
899 // First test if the original triple can find a sysroot with the triple
900 // name.
901 if (testTriple(D, Triple, Args))
902 return Triple;
904 // If not, test a couple other possible arch names that might be what was
905 // intended.
906 if (Triple.getArch() == llvm::Triple::x86) {
907 Archs.emplace_back("i386");
908 Archs.emplace_back("i586");
909 Archs.emplace_back("i686");
910 } else if (Triple.getArch() == llvm::Triple::arm ||
911 Triple.getArch() == llvm::Triple::thumb) {
912 Archs.emplace_back("armv7");
913 }
914 for (auto A : Archs) {
915 llvm::Triple TestTriple(Triple);
916 TestTriple.setArchName(A);
917 if (testTriple(D, TestTriple, Args))
918 return TestTriple;
919 }
920 // If none was found, just proceed with the original value.
921 return Triple;
922}
923
924void toolchains::MinGW::fixTripleArch(const Driver &D, llvm::Triple &Triple,
925 const ArgList &Args) {
926 if (Triple.getArch() == llvm::Triple::x86 ||
927 Triple.getArch() == llvm::Triple::arm ||
928 Triple.getArch() == llvm::Triple::thumb)
929 Triple = adjustTriple(D, Triple, Args);
930}
static llvm::Triple getLiteralTriple(const Driver &D, const llvm::Triple &T)
Definition MinGW.cpp:425
static bool looksLikeMinGWSysroot(const std::string &Directory)
Definition MinGW.cpp:514
static bool findGccVersion(StringRef LibDir, std::string &GccLibDir, std::string &Ver, toolchains::Generic_GCC::GCCVersion &Version)
Definition MinGW.cpp:404
static bool testTriple(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
Definition MinGW.cpp:874
static llvm::Triple adjustTriple(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
Definition MinGW.cpp:897
static llvm::ErrorOr< std::string > findGcc(const llvm::Triple &LiteralTriple, const llvm::Triple &T)
Definition MinGW.cpp:459
static llvm::ErrorOr< std::string > findClangRelativeSysroot(const Driver &D, const llvm::Triple &LiteralTriple, const llvm::Triple &T, std::string &SubdirName)
Definition MinGW.cpp:479
static bool isCrossCompiling(const llvm::Triple &T, bool RequireArchMatch)
Definition MinGW.cpp:394
static StringRef getTriple(const Command &Job)
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:47
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition Driver.h:93
std::string SysRoot
sysroot, if present
Definition Driver.h:193
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const
Compute the desired OpenMP runtime from the flags provided.
Definition Driver.cpp:920
DiagnosticBuilder Diag(unsigned DiagID) const
Definition Driver.h:157
std::string Dir
The path the driver executable was in, as invoked from the command line.
Definition Driver.h:168
@ OMPRT_IOMP5
The legacy name for the LLVM OpenMP runtime from when it was the Intel OpenMP runtime.
Definition Driver.h:153
@ OMPRT_OMP
The LLVM OpenMP runtime.
Definition Driver.h:143
@ OMPRT_Unknown
An unknown OpenMP runtime.
Definition Driver.h:139
@ OMPRT_GOMP
The GNU OpenMP runtime.
Definition Driver.h:148
std::string getTargetTriple() const
Definition Driver.h:427
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag.
Definition Multilib.h:35
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:92
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory to CC1 arguments.
bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const
Returns if the C++ standard library should be linked in.
virtual void addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Adds the path for the Fortran runtime libraries to CmdArgs.
std::string GetFilePath(const char *Name) const
virtual void addFortranRuntimeLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Adds Fortran runtime libraries to CmdArgs.
path_list & getFilePaths()
Definition ToolChain.h:319
virtual SanitizerMask getSupportedSanitizers(BoundArch BA, Action::OffloadKind DeviceOffloadKind) const
Return sanitizers which are available in this toolchain.
llvm::Triple::ArchType getArch() const
Definition ToolChain.h:295
const Driver & getDriver() const
Definition ToolChain.h:279
llvm::vfs::FileSystem & getVFS() const
bool loadMultilibsFromYAML(const llvm::opt::ArgList &Args, const Driver &D, StringRef Fallback={})
Discover and load a multilib.yaml configuration.
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition ToolChain.cpp:93
bool addFastMathRuntimeIfAvailable(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFastMathRuntimeIfAvailable - If a runtime library exists that sets global flags for unsafe floatin...
path_list & getProgramPaths()
Definition ToolChain.h:322
virtual LTOKind getLTOMode(const llvm::opt::ArgList &Args, Action::OffloadKind Kind=Action::OFK_None) const
Resolve the requested LTO mode for this toolchain.
const llvm::Triple & getEffectiveTriple() const
Get the toolchain's effective clang triple.
Definition ToolChain.h:307
virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddCXXStdlibLibArgs - Add the system specific linker arguments to use for the given C++ standard libr...
const llvm::Triple & getTriple() const
Definition ToolChain.h:281
virtual void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass a suitable profile runtime ...
OrderedMultilibs getOrderedMultilibs() const
Get selected multilibs in priority order with default fallback.
StringRef getTripleString() const
Definition ToolChain.h:304
virtual std::string getCompilerRTPath() const
std::string GetLinkerPath(bool *LinkerIsLLD=nullptr) const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name.
std::optional< std::string > getStdlibIncludePath() const
virtual void AddFilePathLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs, BoundArch BA={}, Action::OffloadKind DeviceOffloadKind=Action::OFK_None) const
path_list & getLibraryPaths()
Definition ToolChain.h:316
virtual Tool * getTool(Action::ActionClass AC) const
const char * getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static, bool IsFortran=false) const
std::optional< std::string > GetFilePathIfExists(const char *Name) const
virtual bool isCrossCompiling() const
Returns true if the toolchain is targeting a non-native architecture.
Tool - Information on a specific compilation tool.
Definition Tool.h:31
const ToolChain & getToolChain() const
Definition Tool.h:51
Tool * getTool(Action::ActionClass AC) const override
Definition MinGW.cpp:587
llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override
GetExceptionModel - Return the tool chain exception model.
Definition MinGW.cpp:645
Tool * buildAssembler() const override
Definition MinGW.cpp:606
void printVerboseInfo(raw_ostream &OS) const override
Dispatch to the specific toolchain for verbose printing.
Definition MinGW.cpp:672
Tool * buildLinker() const override
Definition MinGW.cpp:610
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition MinGW.cpp:667
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition MinGW.cpp:638
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific CUDA includes.
Definition MinGW.cpp:662
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition MinGW.cpp:614
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition MinGW.cpp:633
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition MinGW.cpp:642
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:723
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:821
SanitizerMask getSupportedSanitizers(BoundArch BA, Action::OffloadKind DeviceOffloadKind) const override
Return sanitizers which are available in this toolchain.
Definition MinGW.cpp:652
UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override
How detailed should the unwind tables be by default.
Definition MinGW.cpp:619
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:769
MinGW(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition MinGW.cpp:523
static void fixTripleArch(const Driver &D, llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition MinGW.cpp:924
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
MinGW Tools.
Definition MinGW.cpp:30
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
Definition MinGW.cpp:106
const char * SplitDebugName(const JobAction &JA, const llvm::opt::ArgList &Args, const InputInfo &Input, const InputInfo &Output)
void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, const InputInfoList &Inputs, bool IsThinLTO)
void AddRunTimeLibs(const ToolChain &TC, const Driver &D, llvm::opt::ArgStringList &CmdArgs, const llvm::opt::ArgList &Args)
void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T, const JobAction &JA, const llvm::opt::ArgList &Args, const InputInfo &Output, const char *OutFile)
void claimNoWarnArgs(const llvm::opt::ArgList &Args)
void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const JobAction &JA)
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:49
Top level wrappers for InstallAPI frontend operations.
std::error_code make_error_code(BuildPreambleError Error)
const FunctionProtoType * T
Represents a bound architecture for offload / multiple architecture compilation.
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
Definition Job.h:79
static constexpr ResponseFileSupport AtFileUTF8()
Definition Job.h:86
Struct to store and manipulate GCC versions.
Definition Gnu.h:163
static GCCVersion Parse(StringRef VersionText)
Parse a GCCVersion object out of a string of text.
Definition Gnu.cpp:2010