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