clang  8.0.0svn
MinGW.cpp
Go to the documentation of this file.
1 //===--- MinGW.cpp - MinGWToolChain Implementation ------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "MinGW.h"
11 #include "InputInfo.h"
12 #include "CommonArgs.h"
13 #include "clang/Config/config.h"
15 #include "clang/Driver/Driver.h"
17 #include "clang/Driver/Options.h"
19 #include "llvm/Option/ArgList.h"
20 #include "llvm/Support/FileSystem.h"
21 #include "llvm/Support/Path.h"
22 #include <system_error>
23 
24 using namespace clang::diag;
25 using namespace clang::driver;
26 using namespace clang;
27 using namespace llvm::opt;
28 
29 /// MinGW Tools
30 void tools::MinGW::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
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(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
54 
55  if (Args.hasArg(options::OPT_gsplit_dwarf))
56  SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output,
57  SplitDebugName(Args, Output));
58 }
59 
60 void tools::MinGW::Linker::AddLibGCC(const ArgList &Args,
61  ArgStringList &CmdArgs) const {
62  if (Args.hasArg(options::OPT_mthreads))
63  CmdArgs.push_back("-lmingwthrd");
64  CmdArgs.push_back("-lmingw32");
65 
66  // Make use of compiler-rt if --rtlib option is used
67  ToolChain::RuntimeLibType RLT = getToolChain().GetRuntimeLibType(Args);
68  if (RLT == ToolChain::RLT_Libgcc) {
69  bool Static = Args.hasArg(options::OPT_static_libgcc) ||
70  Args.hasArg(options::OPT_static);
71  bool Shared = Args.hasArg(options::OPT_shared);
72  bool CXX = getToolChain().getDriver().CCCIsCXX();
73 
74  if (Static || (!CXX && !Shared)) {
75  CmdArgs.push_back("-lgcc");
76  CmdArgs.push_back("-lgcc_eh");
77  } else {
78  CmdArgs.push_back("-lgcc_s");
79  CmdArgs.push_back("-lgcc");
80  }
81  } else {
82  AddRunTimeLibs(getToolChain(), getToolChain().getDriver(), CmdArgs, Args);
83  }
84 
85  CmdArgs.push_back("-lmoldname");
86  CmdArgs.push_back("-lmingwex");
87  for (auto Lib : Args.getAllArgValues(options::OPT_l))
88  if (StringRef(Lib).startswith("msvcr") || StringRef(Lib).startswith("ucrt"))
89  return;
90  CmdArgs.push_back("-lmsvcrt");
91 }
92 
93 void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
94  const InputInfo &Output,
95  const InputInfoList &Inputs,
96  const ArgList &Args,
97  const char *LinkingOutput) const {
98  const ToolChain &TC = getToolChain();
99  const Driver &D = TC.getDriver();
100  const SanitizerArgs &Sanitize = TC.getSanitizerArgs();
101 
102  ArgStringList CmdArgs;
103 
104  // Silence warning for "clang -g foo.o -o foo"
105  Args.ClaimAllArgs(options::OPT_g_Group);
106  // and "clang -emit-llvm foo.o -o foo"
107  Args.ClaimAllArgs(options::OPT_emit_llvm);
108  // and for "clang -w foo.o -o foo". Other warning options are already
109  // handled somewhere else.
110  Args.ClaimAllArgs(options::OPT_w);
111 
112  if (!D.SysRoot.empty())
113  CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
114 
115  if (Args.hasArg(options::OPT_s))
116  CmdArgs.push_back("-s");
117 
118  CmdArgs.push_back("-m");
119  switch (TC.getArch()) {
120  case llvm::Triple::x86:
121  CmdArgs.push_back("i386pe");
122  break;
123  case llvm::Triple::x86_64:
124  CmdArgs.push_back("i386pep");
125  break;
126  case llvm::Triple::arm:
127  case llvm::Triple::thumb:
128  // FIXME: this is incorrect for WinCE
129  CmdArgs.push_back("thumb2pe");
130  break;
131  case llvm::Triple::aarch64:
132  CmdArgs.push_back("arm64pe");
133  break;
134  default:
135  llvm_unreachable("Unsupported target architecture.");
136  }
137 
138  if (Args.hasArg(options::OPT_mwindows)) {
139  CmdArgs.push_back("--subsystem");
140  CmdArgs.push_back("windows");
141  } else if (Args.hasArg(options::OPT_mconsole)) {
142  CmdArgs.push_back("--subsystem");
143  CmdArgs.push_back("console");
144  }
145 
146  if (Args.hasArg(options::OPT_mdll))
147  CmdArgs.push_back("--dll");
148  else if (Args.hasArg(options::OPT_shared))
149  CmdArgs.push_back("--shared");
150  if (Args.hasArg(options::OPT_static))
151  CmdArgs.push_back("-Bstatic");
152  else
153  CmdArgs.push_back("-Bdynamic");
154  if (Args.hasArg(options::OPT_mdll) || Args.hasArg(options::OPT_shared)) {
155  CmdArgs.push_back("-e");
156  if (TC.getArch() == llvm::Triple::x86)
157  CmdArgs.push_back("_DllMainCRTStartup@12");
158  else
159  CmdArgs.push_back("DllMainCRTStartup");
160  CmdArgs.push_back("--enable-auto-image-base");
161  }
162 
163  CmdArgs.push_back("-o");
164  CmdArgs.push_back(Output.getFilename());
165 
166  Args.AddAllArgs(CmdArgs, options::OPT_e);
167  // FIXME: add -N, -n flags
168  Args.AddLastArg(CmdArgs, options::OPT_r);
169  Args.AddLastArg(CmdArgs, options::OPT_s);
170  Args.AddLastArg(CmdArgs, options::OPT_t);
171  Args.AddAllArgs(CmdArgs, options::OPT_u_Group);
172  Args.AddLastArg(CmdArgs, options::OPT_Z_Flag);
173 
174  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
175  if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_mdll)) {
176  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("dllcrt2.o")));
177  } else {
178  if (Args.hasArg(options::OPT_municode))
179  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt2u.o")));
180  else
181  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt2.o")));
182  }
183  if (Args.hasArg(options::OPT_pg))
184  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("gcrt2.o")));
185  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtbegin.o")));
186  }
187 
188  Args.AddAllArgs(CmdArgs, options::OPT_L);
189  TC.AddFilePathLibArgs(Args, CmdArgs);
190  AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
191 
192  // TODO: Add profile stuff here
193 
194  if (TC.ShouldLinkCXXStdlib(Args)) {
195  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
196  !Args.hasArg(options::OPT_static);
197  if (OnlyLibstdcxxStatic)
198  CmdArgs.push_back("-Bstatic");
199  TC.AddCXXStdlibLibArgs(Args, CmdArgs);
200  if (OnlyLibstdcxxStatic)
201  CmdArgs.push_back("-Bdynamic");
202  }
203 
204  bool HasWindowsApp = false;
205  for (auto Lib : Args.getAllArgValues(options::OPT_l)) {
206  if (Lib == "windowsapp") {
207  HasWindowsApp = true;
208  break;
209  }
210  }
211 
212  if (!Args.hasArg(options::OPT_nostdlib)) {
213  if (!Args.hasArg(options::OPT_nodefaultlibs)) {
214  if (Args.hasArg(options::OPT_static))
215  CmdArgs.push_back("--start-group");
216 
217  if (Args.hasArg(options::OPT_fstack_protector) ||
218  Args.hasArg(options::OPT_fstack_protector_strong) ||
219  Args.hasArg(options::OPT_fstack_protector_all)) {
220  CmdArgs.push_back("-lssp_nonshared");
221  CmdArgs.push_back("-lssp");
222  }
223 
224  if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
225  options::OPT_fno_openmp, false)) {
226  switch (TC.getDriver().getOpenMPRuntime(Args)) {
227  case Driver::OMPRT_OMP:
228  CmdArgs.push_back("-lomp");
229  break;
230  case Driver::OMPRT_IOMP5:
231  CmdArgs.push_back("-liomp5md");
232  break;
233  case Driver::OMPRT_GOMP:
234  CmdArgs.push_back("-lgomp");
235  break;
236  case Driver::OMPRT_Unknown:
237  // Already diagnosed.
238  break;
239  }
240  }
241 
242  AddLibGCC(Args, CmdArgs);
243 
244  if (Args.hasArg(options::OPT_pg))
245  CmdArgs.push_back("-lgmon");
246 
247  if (Args.hasArg(options::OPT_pthread))
248  CmdArgs.push_back("-lpthread");
249 
250  if (Sanitize.needsAsanRt()) {
251  // MinGW always links against a shared MSVCRT.
252  CmdArgs.push_back(
253  TC.getCompilerRTArgString(Args, "asan_dynamic", true));
254  CmdArgs.push_back(
255  TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
256  CmdArgs.push_back(Args.MakeArgString("--require-defined"));
257  CmdArgs.push_back(Args.MakeArgString(TC.getArch() == llvm::Triple::x86
258  ? "___asan_seh_interceptor"
259  : "__asan_seh_interceptor"));
260  // Make sure the linker consider all object files from the dynamic
261  // runtime thunk.
262  CmdArgs.push_back(Args.MakeArgString("--whole-archive"));
263  CmdArgs.push_back(Args.MakeArgString(
264  TC.getCompilerRT(Args, "asan_dynamic_runtime_thunk")));
265  CmdArgs.push_back(Args.MakeArgString("--no-whole-archive"));
266  }
267 
268  if (!HasWindowsApp) {
269  // Add system libraries. If linking to libwindowsapp.a, that import
270  // library replaces all these and we shouldn't accidentally try to
271  // link to the normal desktop mode dlls.
272  if (Args.hasArg(options::OPT_mwindows)) {
273  CmdArgs.push_back("-lgdi32");
274  CmdArgs.push_back("-lcomdlg32");
275  }
276  CmdArgs.push_back("-ladvapi32");
277  CmdArgs.push_back("-lshell32");
278  CmdArgs.push_back("-luser32");
279  CmdArgs.push_back("-lkernel32");
280  }
281 
282  if (Args.hasArg(options::OPT_static))
283  CmdArgs.push_back("--end-group");
284  else
285  AddLibGCC(Args, CmdArgs);
286  }
287 
288  if (!Args.hasArg(options::OPT_nostartfiles)) {
289  // Add crtfastmath.o if available and fast math is enabled.
290  TC.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
291 
292  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
293  }
294  }
295  const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
296  C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
297 }
298 
299 // Simplified from Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
300 static bool findGccVersion(StringRef LibDir, std::string &GccLibDir,
301  std::string &Ver) {
302  auto Version = toolchains::Generic_GCC::GCCVersion::Parse("0.0.0");
303  std::error_code EC;
304  for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
305  LI = LI.increment(EC)) {
306  StringRef VersionText = llvm::sys::path::filename(LI->path());
307  auto CandidateVersion =
308  toolchains::Generic_GCC::GCCVersion::Parse(VersionText);
309  if (CandidateVersion.Major == -1)
310  continue;
311  if (CandidateVersion <= Version)
312  continue;
313  Ver = VersionText;
314  GccLibDir = LI->path();
315  }
316  return Ver.size();
317 }
318 
319 void toolchains::MinGW::findGccLibDir() {
321  Archs.emplace_back(getTriple().getArchName());
322  Archs[0] += "-w64-mingw32";
323  Archs.emplace_back("mingw32");
324  if (Arch.empty())
325  Arch = Archs[0].str();
326  // lib: Arch Linux, Ubuntu, Windows
327  // lib64: openSUSE Linux
328  for (StringRef CandidateLib : {"lib", "lib64"}) {
329  for (StringRef CandidateArch : Archs) {
331  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateArch);
332  if (findGccVersion(LibDir, GccLibDir, Ver)) {
333  Arch = CandidateArch;
334  return;
335  }
336  }
337  }
338 }
339 
340 llvm::ErrorOr<std::string> toolchains::MinGW::findGcc() {
342  Gccs.emplace_back(getTriple().getArchName());
343  Gccs[0] += "-w64-mingw32-gcc";
344  Gccs.emplace_back("mingw32-gcc");
345  // Please do not add "gcc" here
346  for (StringRef CandidateGcc : Gccs)
347  if (llvm::ErrorOr<std::string> GPPName = llvm::sys::findProgramByName(CandidateGcc))
348  return GPPName;
349  return make_error_code(std::errc::no_such_file_or_directory);
350 }
351 
352 llvm::ErrorOr<std::string> toolchains::MinGW::findClangRelativeSysroot() {
354  Subdirs.emplace_back(getTriple().str());
355  Subdirs.emplace_back(getTriple().getArchName());
356  Subdirs[1] += "-w64-mingw32";
357  StringRef ClangRoot =
358  llvm::sys::path::parent_path(getDriver().getInstalledDir());
359  StringRef Sep = llvm::sys::path::get_separator();
360  for (StringRef CandidateSubdir : Subdirs) {
361  if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
362  Arch = CandidateSubdir;
363  return (ClangRoot + Sep + CandidateSubdir).str();
364  }
365  }
366  return make_error_code(std::errc::no_such_file_or_directory);
367 }
368 
369 toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple,
370  const ArgList &Args)
371  : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
372  getProgramPaths().push_back(getDriver().getInstalledDir());
373 
374  if (getDriver().SysRoot.size())
375  Base = getDriver().SysRoot;
376  // Look for <clang-bin>/../<triplet>; if found, use <clang-bin>/.. as the
377  // base as it could still be a base for a gcc setup with libgcc.
378  else if (llvm::ErrorOr<std::string> TargetSubdir = findClangRelativeSysroot())
379  Base = llvm::sys::path::parent_path(TargetSubdir.get());
380  else if (llvm::ErrorOr<std::string> GPPName = findGcc())
381  Base = llvm::sys::path::parent_path(
382  llvm::sys::path::parent_path(GPPName.get()));
383  else
384  Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
385 
386  Base += llvm::sys::path::get_separator();
387  findGccLibDir();
388  // GccLibDir must precede Base/lib so that the
389  // correct crtbegin.o ,cetend.o would be found.
390  getFilePaths().push_back(GccLibDir);
391  getFilePaths().push_back(
392  (Base + Arch + llvm::sys::path::get_separator() + "lib").str());
393  getFilePaths().push_back(Base + "lib");
394  // openSUSE
395  getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib");
396 
397  NativeLLVMSupport =
398  Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
399  .equals_lower("lld");
400 }
401 
403 
405  switch (AC) {
407  if (!Preprocessor)
408  Preprocessor.reset(new tools::gcc::Preprocessor(*this));
409  return Preprocessor.get();
411  if (!Compiler)
412  Compiler.reset(new tools::gcc::Compiler(*this));
413  return Compiler.get();
414  default:
415  return ToolChain::getTool(AC);
416  }
417 }
418 
420  return new tools::MinGW::Assembler(*this);
421 }
422 
424  return new tools::MinGW::Linker(*this);
425 }
426 
428  return NativeLLVMSupport;
429 }
430 
431 bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
432  return getArch() == llvm::Triple::x86_64;
433 }
434 
436  return getArch() == llvm::Triple::x86_64;
437 }
438 
439 bool toolchains::MinGW::isPIEDefault() const { return false; }
440 
442  return getArch() == llvm::Triple::x86_64;
443 }
444 
445 llvm::ExceptionHandling
446 toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
447  if (getArch() == llvm::Triple::x86_64)
448  return llvm::ExceptionHandling::WinEH;
449  return llvm::ExceptionHandling::DwarfCFI;
450 }
451 
454  Res |= SanitizerKind::Address;
455  return Res;
456 }
457 
458 void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
459  ArgStringList &CC1Args) const {
460  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
461 }
462 
463 void toolchains::MinGW::printVerboseInfo(raw_ostream &OS) const {
464  CudaInstallation.print(OS);
465 }
466 
467 // Include directories for various hosts:
468 
469 // Windows, mingw.org
470 // c:\mingw\lib\gcc\mingw32\4.8.1\include\c++
471 // c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\mingw32
472 // c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\backward
473 // c:\mingw\include
474 // c:\mingw\mingw32\include
475 
476 // Windows, mingw-w64 mingw-builds
477 // c:\mingw32\i686-w64-mingw32\include
478 // c:\mingw32\i686-w64-mingw32\include\c++
479 // c:\mingw32\i686-w64-mingw32\include\c++\i686-w64-mingw32
480 // c:\mingw32\i686-w64-mingw32\include\c++\backward
481 
482 // Windows, mingw-w64 msys2
483 // c:\msys64\mingw32\include
484 // c:\msys64\mingw32\i686-w64-mingw32\include
485 // c:\msys64\mingw32\include\c++\4.9.2
486 // c:\msys64\mingw32\include\c++\4.9.2\i686-w64-mingw32
487 // c:\msys64\mingw32\include\c++\4.9.2\backward
488 
489 // openSUSE
490 // /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++
491 // /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/x86_64-w64-mingw32
492 // /usr/lib64/gcc/x86_64-w64-mingw32/5.1.0/include/c++/backward
493 // /usr/x86_64-w64-mingw32/sys-root/mingw/include
494 
495 // Arch Linux
496 // /usr/i686-w64-mingw32/include/c++/5.1.0
497 // /usr/i686-w64-mingw32/include/c++/5.1.0/i686-w64-mingw32
498 // /usr/i686-w64-mingw32/include/c++/5.1.0/backward
499 // /usr/i686-w64-mingw32/include
500 
501 // Ubuntu
502 // /usr/include/c++/4.8
503 // /usr/include/c++/4.8/x86_64-w64-mingw32
504 // /usr/include/c++/4.8/backward
505 // /usr/x86_64-w64-mingw32/include
506 
507 void toolchains::MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
508  ArgStringList &CC1Args) const {
509  if (DriverArgs.hasArg(options::OPT_nostdinc))
510  return;
511 
512  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
513  SmallString<1024> P(getDriver().ResourceDir);
514  llvm::sys::path::append(P, "include");
515  addSystemInclude(DriverArgs, CC1Args, P.str());
516  }
517 
518  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
519  return;
520 
521  if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) {
522  // openSUSE
523  addSystemInclude(DriverArgs, CC1Args,
524  Base + Arch + "/sys-root/mingw/include");
525  }
526 
527  addSystemInclude(DriverArgs, CC1Args,
528  Base + Arch + llvm::sys::path::get_separator() + "include");
529  addSystemInclude(DriverArgs, CC1Args, Base + "include");
530 }
531 
533  const ArgList &DriverArgs, ArgStringList &CC1Args) const {
534  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
535  DriverArgs.hasArg(options::OPT_nostdincxx))
536  return;
537 
538  StringRef Slash = llvm::sys::path::get_separator();
539 
540  switch (GetCXXStdlibType(DriverArgs)) {
542  addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" +
543  Slash + "c++" + Slash + "v1");
544  addSystemInclude(DriverArgs, CC1Args,
545  Base + "include" + Slash + "c++" + Slash + "v1");
546  break;
547 
549  llvm::SmallVector<llvm::SmallString<1024>, 4> CppIncludeBases;
550  CppIncludeBases.emplace_back(Base);
551  llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
552  CppIncludeBases.emplace_back(Base);
553  llvm::sys::path::append(CppIncludeBases[1], Arch, "include", "c++", Ver);
554  CppIncludeBases.emplace_back(Base);
555  llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
556  CppIncludeBases.emplace_back(GccLibDir);
557  llvm::sys::path::append(CppIncludeBases[3], "include", "c++");
558  for (auto &CppIncludeBase : CppIncludeBases) {
559  addSystemInclude(DriverArgs, CC1Args, CppIncludeBase);
560  CppIncludeBase += Slash;
561  addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + Arch);
562  addSystemInclude(DriverArgs, CC1Args, CppIncludeBase + "backward");
563  }
564  break;
565  }
566 }
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:507
static bool findGccVersion(StringRef LibDir, std::string &GccLibDir, std::string &Ver)
Definition: MinGW.cpp:300
Tool * getTool(Action::ActionClass AC) const override
Definition: MinGW.cpp:404
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: MinGW.cpp:427
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const
Compute the desired OpenMP runtime from the flags provided.
Definition: Driver.cpp:547
const char * getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, bool Shared=false) const
Definition: ToolChain.cpp:392
const char * SplitDebugName(const llvm::opt::ArgList &Args, const InputInfo &Output)
StringRef P
void AddRunTimeLibs(const ToolChain &TC, const Driver &D, llvm::opt::ArgStringList &CmdArgs, const llvm::opt::ArgList &Args)
std::string GetLinkerPath() const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name...
Definition: ToolChain.cpp:439
void print(raw_ostream &OS) const
Print information about the detected CUDA installation.
Definition: Cuda.cpp:274
const char * getFilename() const
Definition: InputInfo.h:84
bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override
IsUnwindTablesDefault - Does this tool chain use -funwind-tables by default.
Definition: MinGW.cpp:431
path_list & getProgramPaths()
Definition: ToolChain.h:226
Tool * buildLinker() const override
Definition: MinGW.cpp:423
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: MinGW.cpp:439
std::error_code make_error_code(BuildPreambleError Error)
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:23
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:431
path_list & getFilePaths()
Definition: ToolChain.h:223
virtual 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...
Definition: ToolChain.cpp:794
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:58
llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const override
GetExceptionModel - Return the tool chain exception model.
Definition: MinGW.cpp:446
return Out str()
void printVerboseInfo(raw_ostream &OS) const override
Dispatch to the specific toolchain for verbose printing.
Definition: MinGW.cpp:463
Tool * buildAssembler() const override
Definition: MinGW.cpp:419
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: MinGW.cpp:452
void addCommand(std::unique_ptr< Command > C)
Definition: Compilation.h:206
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, bool Shared=false) const
Definition: ToolChain.cpp:365
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:201
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition: Cuda.cpp:231
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: MinGW.cpp:441
void AddFilePathLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
Definition: ToolChain.cpp:778
const Driver & getDriver() const
Definition: ToolChain.h:185
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific CUDA includes.
Definition: MinGW.cpp:458
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.
Definition: ToolChain.cpp:702
void SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T, const JobAction &JA, const llvm::opt::ArgList &Args, const InputInfo &Output, const char *OutFile)
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:664
bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const
Returns if the C++ standard library should be linked in.
Definition: ToolChain.cpp:755
Dataflow Directional Tag Classes.
void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const JobAction &JA)
std::string SysRoot
sysroot, if present
Definition: Driver.h:148
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
const SanitizerArgs & getSanitizerArgs() const
Definition: ToolChain.cpp:116
void claimNoWarnArgs(const llvm::opt::ArgList &Args)
uint64_t SanitizerMask
Definition: Sanitizers.h:26
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:46
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:818
virtual Tool * getTool(Action::ActionClass AC) const
Definition: ToolChain.cpp:289
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:683
bool IsIntegratedAssemblerDefault() const override
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: MinGW.cpp:402
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: MinGW.cpp:435
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:532
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...
Definition: ToolChain.cpp:761
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:125
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:88