clang  15.0.0git
WebAssembly.cpp
Go to the documentation of this file.
1 //===--- WebAssembly.cpp - WebAssembly ToolChain Implementation -*- 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 #include "WebAssembly.h"
10 #include "CommonArgs.h"
11 #include "Gnu.h"
12 #include "clang/Basic/Version.h"
13 #include "clang/Config/config.h"
15 #include "clang/Driver/Driver.h"
17 #include "clang/Driver/Options.h"
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 
23 using namespace clang::driver;
24 using namespace clang::driver::tools;
25 using namespace clang::driver::toolchains;
26 using namespace clang;
27 using namespace llvm::opt;
28 
29 /// Following the conventions in https://wiki.debian.org/Multiarch/Tuples,
30 /// we remove the vendor field to form the multiarch triple.
31 std::string WebAssembly::getMultiarchTriple(const Driver &D,
32  const llvm::Triple &TargetTriple,
33  StringRef SysRoot) const {
34  return (TargetTriple.getArchName() + "-" +
35  TargetTriple.getOSAndEnvironmentName()).str();
36 }
37 
38 std::string wasm::Linker::getLinkerPath(const ArgList &Args) const {
39  const ToolChain &ToolChain = getToolChain();
40  if (const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
41  StringRef UseLinker = A->getValue();
42  if (!UseLinker.empty()) {
43  if (llvm::sys::path::is_absolute(UseLinker) &&
44  llvm::sys::fs::can_execute(UseLinker))
45  return std::string(UseLinker);
46 
47  // Accept 'lld', and 'ld' as aliases for the default linker
48  if (UseLinker != "lld" && UseLinker != "ld")
49  ToolChain.getDriver().Diag(diag::err_drv_invalid_linker_name)
50  << A->getAsString(Args);
51  }
52  }
53 
55 }
56 
58  const InputInfo &Output,
59  const InputInfoList &Inputs,
60  const ArgList &Args,
61  const char *LinkingOutput) const {
62 
63  const ToolChain &ToolChain = getToolChain();
64  const char *Linker = Args.MakeArgString(getLinkerPath(Args));
65  ArgStringList CmdArgs;
66 
67  CmdArgs.push_back("-m");
68  if (ToolChain.getTriple().isArch64Bit())
69  CmdArgs.push_back("wasm64");
70  else
71  CmdArgs.push_back("wasm32");
72 
73  if (Args.hasArg(options::OPT_s))
74  CmdArgs.push_back("--strip-all");
75 
76  Args.AddAllArgs(CmdArgs, options::OPT_L);
77  Args.AddAllArgs(CmdArgs, options::OPT_u);
78  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
79 
80  const char *Crt1 = "crt1.o";
81  const char *Entry = nullptr;
82 
83  // If crt1-command.o exists, it supports new-style commands, so use it.
84  // Otherwise, use the old crt1.o. This is a temporary transition measure.
85  // Once WASI libc no longer needs to support LLVM versions which lack
86  // support for new-style command, it can make crt1.o the same as
87  // crt1-command.o. And once LLVM no longer needs to support WASI libc
88  // versions before that, it can switch to using crt1-command.o.
89  if (ToolChain.GetFilePath("crt1-command.o") != "crt1-command.o")
90  Crt1 = "crt1-command.o";
91 
92  if (const Arg *A = Args.getLastArg(options::OPT_mexec_model_EQ)) {
93  StringRef CM = A->getValue();
94  if (CM == "command") {
95  // Use default values.
96  } else if (CM == "reactor") {
97  Crt1 = "crt1-reactor.o";
98  Entry = "_initialize";
99  } else {
100  ToolChain.getDriver().Diag(diag::err_drv_invalid_argument_to_option)
101  << CM << A->getOption().getName();
102  }
103  }
104  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
105  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
106  if (Entry) {
107  CmdArgs.push_back(Args.MakeArgString("--entry"));
108  CmdArgs.push_back(Args.MakeArgString(Entry));
109  }
110 
111  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
112 
113  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
114  if (ToolChain.ShouldLinkCXXStdlib(Args))
115  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
116 
117  if (Args.hasArg(options::OPT_pthread)) {
118  CmdArgs.push_back("-lpthread");
119  CmdArgs.push_back("--shared-memory");
120  }
121 
122  CmdArgs.push_back("-lc");
123  AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
124  }
125 
126  CmdArgs.push_back("-o");
127  CmdArgs.push_back(Output.getFilename());
128 
129  C.addCommand(std::make_unique<Command>(JA, *this,
131  Linker, CmdArgs, Inputs, Output));
132 
133  // When optimizing, if wasm-opt is available, run it.
134  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
135  auto WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
136  if (WasmOptPath != "wasm-opt") {
137  StringRef OOpt = "s";
138  if (A->getOption().matches(options::OPT_O4) ||
139  A->getOption().matches(options::OPT_Ofast))
140  OOpt = "4";
141  else if (A->getOption().matches(options::OPT_O0))
142  OOpt = "0";
143  else if (A->getOption().matches(options::OPT_O))
144  OOpt = A->getValue();
145 
146  if (OOpt != "0") {
147  const char *WasmOpt = Args.MakeArgString(WasmOptPath);
148  ArgStringList CmdArgs;
149  CmdArgs.push_back(Output.getFilename());
150  CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
151  CmdArgs.push_back("-o");
152  CmdArgs.push_back(Output.getFilename());
153  C.addCommand(std::make_unique<Command>(
154  JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, CmdArgs,
155  Inputs, Output));
156  }
157  }
158  }
159 }
160 
161 /// Given a base library directory, append path components to form the
162 /// LTO directory.
164  // The version allows the path to be keyed to the specific version of
165  // LLVM in used, as the bitcode format is not stable.
166  return Dir + "/llvm-lto/" LLVM_VERSION_STRING;
167 }
168 
169 WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
170  const llvm::opt::ArgList &Args)
171  : ToolChain(D, Triple, Args) {
172 
173  assert(Triple.isArch32Bit() != Triple.isArch64Bit());
174 
175  getProgramPaths().push_back(getDriver().getInstalledDir());
176 
177  auto SysRoot = getDriver().SysRoot;
178  if (getTriple().getOS() == llvm::Triple::UnknownOS) {
179  // Theoretically an "unknown" OS should mean no standard libraries, however
180  // it could also mean that a custom set of libraries is in use, so just add
181  // /lib to the search path. Disable multiarch in this case, to discourage
182  // paths containing "unknown" from acquiring meanings.
183  getFilePaths().push_back(SysRoot + "/lib");
184  } else {
185  const std::string MultiarchTriple =
186  getMultiarchTriple(getDriver(), Triple, SysRoot);
187  if (D.isUsingLTO()) {
188  // For LTO, enable use of lto-enabled sysroot libraries too, if available.
189  // Note that the directory is keyed to the LLVM revision, as LLVM's
190  // bitcode format is not stable.
191  auto Dir = AppendLTOLibDir(SysRoot + "/lib/" + MultiarchTriple);
192  getFilePaths().push_back(Dir);
193  }
194  getFilePaths().push_back(SysRoot + "/lib/" + MultiarchTriple);
195  }
196 }
197 
198 bool WebAssembly::IsMathErrnoDefault() const { return false; }
199 
200 bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
201 
202 bool WebAssembly::UseObjCMixedDispatch() const { return true; }
203 
204 bool WebAssembly::isPICDefault() const { return false; }
205 
206 bool WebAssembly::isPIEDefault(const llvm::opt::ArgList &Args) const {
207  return false;
208 }
209 
210 bool WebAssembly::isPICDefaultForced() const { return false; }
211 
212 bool WebAssembly::IsIntegratedAssemblerDefault() const { return true; }
213 
214 bool WebAssembly::hasBlocksRuntime() const { return false; }
215 
216 // TODO: Support profiling.
217 bool WebAssembly::SupportsProfiling() const { return false; }
218 
219 bool WebAssembly::HasNativeLLVMSupport() const { return true; }
220 
221 void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
222  ArgStringList &CC1Args,
223  Action::OffloadKind) const {
224  if (!DriverArgs.hasFlag(clang::driver::options::OPT_fuse_init_array,
225  options::OPT_fno_use_init_array, true))
226  CC1Args.push_back("-fno-use-init-array");
227 
228  // '-pthread' implies atomics, bulk-memory, mutable-globals, and sign-ext
229  if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
230  false)) {
231  if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
232  false))
233  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
234  << "-pthread"
235  << "-mno-atomics";
236  if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
237  options::OPT_mbulk_memory, false))
238  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
239  << "-pthread"
240  << "-mno-bulk-memory";
241  if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
242  options::OPT_mmutable_globals, false))
243  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
244  << "-pthread"
245  << "-mno-mutable-globals";
246  if (DriverArgs.hasFlag(options::OPT_mno_sign_ext, options::OPT_msign_ext,
247  false))
248  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
249  << "-pthread"
250  << "-mno-sign-ext";
251  CC1Args.push_back("-target-feature");
252  CC1Args.push_back("+atomics");
253  CC1Args.push_back("-target-feature");
254  CC1Args.push_back("+bulk-memory");
255  CC1Args.push_back("-target-feature");
256  CC1Args.push_back("+mutable-globals");
257  CC1Args.push_back("-target-feature");
258  CC1Args.push_back("+sign-ext");
259  }
260 
261  if (!DriverArgs.hasFlag(options::OPT_mmutable_globals,
262  options::OPT_mno_mutable_globals, false)) {
263  // -fPIC implies +mutable-globals because the PIC ABI used by the linker
264  // depends on importing and exporting mutable globals.
265  llvm::Reloc::Model RelocationModel;
266  unsigned PICLevel;
267  bool IsPIE;
268  std::tie(RelocationModel, PICLevel, IsPIE) =
269  ParsePICArgs(*this, DriverArgs);
270  if (RelocationModel == llvm::Reloc::PIC_) {
271  if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
272  options::OPT_mmutable_globals, false)) {
273  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
274  << "-fPIC"
275  << "-mno-mutable-globals";
276  }
277  CC1Args.push_back("-target-feature");
278  CC1Args.push_back("+mutable-globals");
279  }
280  }
281 
282  if (DriverArgs.getLastArg(options::OPT_fwasm_exceptions)) {
283  // '-fwasm-exceptions' is not compatible with '-mno-exception-handling'
284  if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,
285  options::OPT_mexception_handing, false))
286  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
287  << "-fwasm-exceptions"
288  << "-mno-exception-handling";
289  // '-fwasm-exceptions' is not compatible with
290  // '-mllvm -enable-emscripten-cxx-exceptions'
291  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
292  if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions")
293  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
294  << "-fwasm-exceptions"
295  << "-mllvm -enable-emscripten-cxx-exceptions";
296  }
297  // '-fwasm-exceptions' implies exception-handling feature
298  CC1Args.push_back("-target-feature");
299  CC1Args.push_back("+exception-handling");
300  // Backend needs -wasm-enable-eh to enable Wasm EH
301  CC1Args.push_back("-mllvm");
302  CC1Args.push_back("-wasm-enable-eh");
303  }
304 
305  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
306  StringRef Opt = A->getValue(0);
307  if (Opt.startswith("-emscripten-cxx-exceptions-allowed")) {
308  // '-mllvm -emscripten-cxx-exceptions-allowed' should be used with
309  // '-mllvm -enable-emscripten-cxx-exceptions'
310  bool EmEHArgExists = false;
311  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
312  if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions") {
313  EmEHArgExists = true;
314  break;
315  }
316  }
317  if (!EmEHArgExists)
318  getDriver().Diag(diag::err_drv_argument_only_allowed_with)
319  << "-mllvm -emscripten-cxx-exceptions-allowed"
320  << "-mllvm -enable-emscripten-cxx-exceptions";
321 
322  // Prevent functions specified in -emscripten-cxx-exceptions-allowed list
323  // from being inlined before reaching the wasm backend.
324  StringRef FuncNamesStr = Opt.split('=').second;
325  SmallVector<StringRef, 4> FuncNames;
326  FuncNamesStr.split(FuncNames, ',');
327  for (auto Name : FuncNames) {
328  CC1Args.push_back("-mllvm");
329  CC1Args.push_back(DriverArgs.MakeArgString("--force-attribute=" + Name +
330  ":noinline"));
331  }
332  }
333 
334  if (Opt.startswith("-wasm-enable-sjlj")) {
335  // '-mllvm -wasm-enable-sjlj' is not compatible with
336  // '-mno-exception-handling'
337  if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,
338  options::OPT_mexception_handing, false))
339  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
340  << "-mllvm -wasm-enable-sjlj"
341  << "-mno-exception-handling";
342  // '-mllvm -wasm-enable-sjlj' is not compatible with
343  // '-mllvm -enable-emscripten-cxx-exceptions'
344  // because we don't allow Emscripten EH + Wasm SjLj
345  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
346  if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions")
347  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
348  << "-mllvm -wasm-enable-sjlj"
349  << "-mllvm -enable-emscripten-cxx-exceptions";
350  }
351  // '-mllvm -wasm-enable-sjlj' is not compatible with
352  // '-mllvm -enable-emscripten-sjlj'
353  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
354  if (StringRef(A->getValue(0)) == "-enable-emscripten-sjlj")
355  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
356  << "-mllvm -wasm-enable-sjlj"
357  << "-mllvm -enable-emscripten-sjlj";
358  }
359  // '-mllvm -wasm-enable-sjlj' implies exception-handling feature
360  CC1Args.push_back("-target-feature");
361  CC1Args.push_back("+exception-handling");
362  // Backend needs '-exception-model=wasm' to use Wasm EH instructions
363  CC1Args.push_back("-exception-model=wasm");
364  }
365  }
366 }
367 
368 ToolChain::RuntimeLibType WebAssembly::GetDefaultRuntimeLibType() const {
370 }
371 
373 WebAssembly::GetCXXStdlibType(const ArgList &Args) const {
374  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
375  StringRef Value = A->getValue();
376  if (Value == "libc++")
377  return ToolChain::CST_Libcxx;
378  else if (Value == "libstdc++")
380  else
381  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
382  << A->getAsString(Args);
383  }
384  return ToolChain::CST_Libcxx;
385 }
386 
387 void WebAssembly::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
388  ArgStringList &CC1Args) const {
389  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
390  return;
391 
392  const Driver &D = getDriver();
393 
394  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
396  llvm::sys::path::append(P, "include");
397  addSystemInclude(DriverArgs, CC1Args, P);
398  }
399 
400  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
401  return;
402 
403  // Check for configure-time C include directories.
404  StringRef CIncludeDirs(C_INCLUDE_DIRS);
405  if (CIncludeDirs != "") {
407  CIncludeDirs.split(dirs, ":");
408  for (StringRef dir : dirs) {
409  StringRef Prefix =
410  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
411  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
412  }
413  return;
414  }
415 
416  if (getTriple().getOS() != llvm::Triple::UnknownOS) {
417  const std::string MultiarchTriple =
418  getMultiarchTriple(D, getTriple(), D.SysRoot);
419  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include/" + MultiarchTriple);
420  }
421  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/include");
422 }
423 
424 void WebAssembly::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
425  ArgStringList &CC1Args) const {
426 
427  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
428  DriverArgs.hasArg(options::OPT_nostdincxx))
429  return;
430 
431  switch (GetCXXStdlibType(DriverArgs)) {
433  addLibCxxIncludePaths(DriverArgs, CC1Args);
434  break;
436  addLibStdCXXIncludePaths(DriverArgs, CC1Args);
437  break;
438  }
439 }
440 
441 void WebAssembly::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
442  llvm::opt::ArgStringList &CmdArgs) const {
443 
444  switch (GetCXXStdlibType(Args)) {
446  CmdArgs.push_back("-lc++");
447  CmdArgs.push_back("-lc++abi");
448  break;
450  CmdArgs.push_back("-lstdc++");
451  break;
452  }
453 }
454 
455 SanitizerMask WebAssembly::getSupportedSanitizers() const {
457  if (getTriple().isOSEmscripten()) {
458  Res |= SanitizerKind::Vptr | SanitizerKind::Leak | SanitizerKind::Address;
459  }
460  return Res;
461 }
462 
463 Tool *WebAssembly::buildLinker() const {
464  return new tools::wasm::Linker(*this);
465 }
466 
467 void WebAssembly::addLibCxxIncludePaths(
468  const llvm::opt::ArgList &DriverArgs,
469  llvm::opt::ArgStringList &CC1Args) const {
470  const Driver &D = getDriver();
471  std::string SysRoot = computeSysRoot();
472  std::string LibPath = SysRoot + "/include";
473  const std::string MultiarchTriple =
474  getMultiarchTriple(D, getTriple(), SysRoot);
475  bool IsKnownOs = (getTriple().getOS() != llvm::Triple::UnknownOS);
476 
477  std::string Version = detectLibcxxVersion(LibPath);
478  if (Version.empty())
479  return;
480 
481  // First add the per-target include path if the OS is known.
482  if (IsKnownOs) {
483  std::string TargetDir = LibPath + "/" + MultiarchTriple + "/c++/" + Version;
484  addSystemInclude(DriverArgs, CC1Args, TargetDir);
485  }
486 
487  // Second add the generic one.
488  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
489 }
490 
491 void WebAssembly::addLibStdCXXIncludePaths(
492  const llvm::opt::ArgList &DriverArgs,
493  llvm::opt::ArgStringList &CC1Args) const {
494  // We cannot use GCCInstallationDetector here as the sysroot usually does
495  // not contain a full GCC installation.
496  // Instead, we search the given sysroot for /usr/include/xx, similar
497  // to how we do it for libc++.
498  const Driver &D = getDriver();
499  std::string SysRoot = computeSysRoot();
500  std::string LibPath = SysRoot + "/include";
501  const std::string MultiarchTriple =
502  getMultiarchTriple(D, getTriple(), SysRoot);
503  bool IsKnownOs = (getTriple().getOS() != llvm::Triple::UnknownOS);
504 
505  // This is similar to detectLibcxxVersion()
506  std::string Version;
507  {
508  std::error_code EC;
509  Generic_GCC::GCCVersion MaxVersion =
511  SmallString<128> Path(LibPath);
512  llvm::sys::path::append(Path, "c++");
513  for (llvm::vfs::directory_iterator LI = getVFS().dir_begin(Path, EC), LE;
514  !EC && LI != LE; LI = LI.increment(EC)) {
515  StringRef VersionText = llvm::sys::path::filename(LI->path());
516  if (VersionText[0] != 'v') {
517  auto Version = Generic_GCC::GCCVersion::Parse(VersionText);
518  if (Version > MaxVersion)
519  MaxVersion = Version;
520  }
521  }
522  if (MaxVersion.Major > 0)
523  Version = MaxVersion.Text;
524  }
525 
526  if (Version.empty())
527  return;
528 
529  // First add the per-target include path if the OS is known.
530  if (IsKnownOs) {
531  std::string TargetDir = LibPath + "/c++/" + Version + "/" + MultiarchTriple;
532  addSystemInclude(DriverArgs, CC1Args, TargetDir);
533  }
534 
535  // Second add the generic one.
536  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version);
537  // Third the backward one.
538  addSystemInclude(DriverArgs, CC1Args, LibPath + "/c++/" + Version + "/backward");
539 }
clang::driver::toolchains
Definition: AIX.h:55
clang::driver::tools::wasm::Linker
Definition: WebAssembly.h:21
clang::driver::ToolChain::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: ToolChain.cpp:99
Driver.h
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::tools::ParsePICArgs
std::tuple< llvm::Reloc::Model, unsigned, bool > ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args)
clang::driver::ToolChain::getDefaultLinker
virtual const char * getDefaultLinker() const
GetDefaultLinker - Get the default linker to use.
Definition: ToolChain.h:433
llvm::SmallVector
Definition: LLVM.h:38
WebAssembly.h
clang::driver::ToolChain::GetProgramPath
std::string GetProgramPath(const char *Name) const
Definition: ToolChain.cpp:581
clang::driver::tools
Definition: AIX.h:17
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:225
clang::driver::ToolChain::detectLibcxxVersion
virtual std::string detectLibcxxVersion(StringRef IncludePath) const
Definition: ToolChain.cpp:917
clang::driver::ToolChain::GetFilePath
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:577
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::ToolChain::RuntimeLibType
RuntimeLibType
Definition: ToolChain.h:100
clang::driver::tools::AddLinkerInputs
void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const JobAction &JA)
clang::driver::toolchains::Generic_GCC::GCCVersion
Struct to store and manipulate GCC versions.
Definition: Gnu.h:161
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:132
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
Options.h
clang::driver::toolchains::Generic_GCC::GCCVersion::Text
std::string Text
The unparsed text of the version.
Definition: Gnu.h:163
clang::interp::LE
bool LE(InterpState &S, CodePtr OpPC)
Definition: Interp.h:239
clang::driver::ToolChain::getOS
StringRef getOS() const
Definition: ToolChain.h:244
Version.h
llvm::opt
Definition: DiagnosticOptions.h:19
DriverDiagnostic.h
clang::driver::ResponseFileSupport::AtFileCurCP
static constexpr ResponseFileSupport AtFileCurCP()
Definition: Job.h:92
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
llvm::SmallString< 128 >
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:227
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:171
clang::driver::ToolChain::CST_Libcxx
@ CST_Libcxx
Definition: ToolChain.h:96
clang::driver::toolchains::Generic_GCC::GCCVersion::Parse
static GCCVersion Parse(StringRef VersionText)
Parse a GCCVersion object out of a string of text.
Definition: Gnu.cpp:1901
clang::driver::ToolChain::CST_Libstdcxx
@ CST_Libstdcxx
Definition: ToolChain.h:97
clang::driver::Driver::ResourceDir
std::string ResourceDir
The path to the compiler resource directory.
Definition: Driver.h:155
clang::driver::ToolChain::AddFilePathLibArgs
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:988
clang::driver::ToolChain::ShouldLinkCXXStdlib
bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const
Returns if the C++ standard library should be linked in.
Definition: ToolChain.cpp:965
clang::driver::tools::wasm::Linker::ConstructJob
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: WebAssembly.cpp:57
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::driver::ToolChain::getSupportedSanitizers
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1031
clang::driver::Driver::isUsingLTO
bool isUsingLTO(bool IsOffload=false) const
Returns true if we are performing any kind of LTO.
Definition: Driver.h:619
clang::driver::ToolChain::AddCXXStdlibLibArgs
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:971
Compilation.h
Gnu.h
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::ToolChain::RLT_CompilerRT
@ RLT_CompilerRT
Definition: ToolChain.h:101
Value
Value
Definition: UninitializedValues.cpp:102
clang::driver::ToolChain::computeSysRoot
virtual std::string computeSysRoot() const
Return the sysroot, possibly searching for a default sysroot using target-specific logic.
Definition: ToolChain.cpp:767
clang::driver::tools::AddRunTimeLibs
void AddRunTimeLibs(const ToolChain &TC, const Driver &D, llvm::opt::ArgStringList &CmdArgs, const llvm::opt::ArgList &Args)
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::toolchains::Generic_GCC::GCCVersion::Major
int Major
The parsed major, minor, and patch numbers.
Definition: Gnu.h:166
clang::driver::InputInfo::getFilename
const char * getFilename() const
Definition: InputInfo.h:83
CommonArgs.h
clang
Definition: CalledOnceCheck.h:17
AppendLTOLibDir
static std::string AppendLTOLibDir(const std::string &Dir)
Given a base library directory, append path components to form the LTO directory.
Definition: WebAssembly.cpp:163
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:71
clang::driver::ToolChain::addExternCSystemInclude
static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory with extern "C" semantics to CC1 arguments.
Definition: ToolChain.cpp:893
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:88
clang::driver
Definition: Action.h:31
clang::driver::ToolChain::addSystemInclude
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:878
clang::driver::tools::wasm::Linker::getLinkerPath
std::string getLinkerPath(const llvm::opt::ArgList &Args) const
Definition: WebAssembly.cpp:38
clang::driver::JobAction
Definition: Action.h:395
clang::SanitizerMask
Definition: Sanitizers.h:30