clang  16.0.0git
Fuchsia.cpp
Go to the documentation of this file.
1 //===--- Fuchsia.cpp - Fuchsia ToolChain Implementations --------*- 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 "Fuchsia.h"
10 #include "CommonArgs.h"
11 #include "clang/Config/config.h"
13 #include "clang/Driver/Driver.h"
15 #include "clang/Driver/Options.h"
17 #include "llvm/Option/ArgList.h"
18 #include "llvm/ProfileData/InstrProf.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::toolchains;
25 using namespace clang::driver::tools;
26 using namespace clang;
27 using namespace llvm::opt;
28 
30 
31 void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
32  const InputInfo &Output,
33  const InputInfoList &Inputs,
34  const ArgList &Args,
35  const char *LinkingOutput) const {
37  static_cast<const toolchains::Fuchsia &>(getToolChain());
38  const Driver &D = ToolChain.getDriver();
39 
40  const llvm::Triple &Triple = ToolChain.getEffectiveTriple();
41 
42  ArgStringList CmdArgs;
43 
44  // Silence warning for "clang -g foo.o -o foo"
45  Args.ClaimAllArgs(options::OPT_g_Group);
46  // and "clang -emit-llvm foo.o -o foo"
47  Args.ClaimAllArgs(options::OPT_emit_llvm);
48  // and for "clang -w foo.o -o foo". Other warning options are already
49  // handled somewhere else.
50  Args.ClaimAllArgs(options::OPT_w);
51 
52  CmdArgs.push_back("-z");
53  CmdArgs.push_back("max-page-size=4096");
54 
55  CmdArgs.push_back("-z");
56  CmdArgs.push_back("now");
57 
58  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
59  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
60  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
61  CmdArgs.push_back("-z");
62  CmdArgs.push_back("rodynamic");
63  CmdArgs.push_back("-z");
64  CmdArgs.push_back("separate-loadable-segments");
65  CmdArgs.push_back("-z");
66  CmdArgs.push_back("rel");
67  CmdArgs.push_back("--pack-dyn-relocs=relr");
68  }
69 
70  if (!D.SysRoot.empty())
71  CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
72 
73  if (!Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_r))
74  CmdArgs.push_back("-pie");
75 
76  if (Args.hasArg(options::OPT_rdynamic))
77  CmdArgs.push_back("-export-dynamic");
78 
79  if (Args.hasArg(options::OPT_s))
80  CmdArgs.push_back("-s");
81 
82  if (Args.hasArg(options::OPT_r)) {
83  CmdArgs.push_back("-r");
84  } else {
85  CmdArgs.push_back("--build-id");
86  CmdArgs.push_back("--hash-style=gnu");
87  }
88 
89  if (ToolChain.getArch() == llvm::Triple::aarch64) {
90  CmdArgs.push_back("--execute-only");
91 
92  std::string CPU = getCPUName(D, Args, Triple);
93  if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
94  CmdArgs.push_back("--fix-cortex-a53-843419");
95  }
96 
97  CmdArgs.push_back("--eh-frame-hdr");
98 
99  if (Args.hasArg(options::OPT_static))
100  CmdArgs.push_back("-Bstatic");
101  else if (Args.hasArg(options::OPT_shared))
102  CmdArgs.push_back("-shared");
103 
104  const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
105 
106  if (!Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_r)) {
107  std::string Dyld = D.DyldPrefix;
108  if (SanArgs.needsAsanRt() && SanArgs.needsSharedRt())
109  Dyld += "asan/";
110  if (SanArgs.needsHwasanRt() && SanArgs.needsSharedRt())
111  Dyld += "hwasan/";
112  if (SanArgs.needsTsanRt() && SanArgs.needsSharedRt())
113  Dyld += "tsan/";
114  Dyld += "ld.so.1";
115  CmdArgs.push_back("-dynamic-linker");
116  CmdArgs.push_back(Args.MakeArgString(Dyld));
117  }
118 
119  if (ToolChain.getArch() == llvm::Triple::riscv64)
120  CmdArgs.push_back("-X");
121 
122  CmdArgs.push_back("-o");
123  CmdArgs.push_back(Output.getFilename());
124 
125  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
126  options::OPT_r)) {
127  if (!Args.hasArg(options::OPT_shared)) {
128  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
129  }
130  }
131 
132  Args.AddAllArgs(CmdArgs, options::OPT_L);
133  Args.AddAllArgs(CmdArgs, options::OPT_u);
134 
135  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
136 
137  if (D.isUsingLTO()) {
138  assert(!Inputs.empty() && "Must have at least one input.");
139  addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
140  D.getLTOMode() == LTOK_Thin);
141  }
142 
144  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
145 
146  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
147  options::OPT_r)) {
148  if (Args.hasArg(options::OPT_static))
149  CmdArgs.push_back("-Bdynamic");
150 
151  if (D.CCCIsCXX()) {
152  if (ToolChain.ShouldLinkCXXStdlib(Args)) {
153  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
154  !Args.hasArg(options::OPT_static);
155  CmdArgs.push_back("--push-state");
156  CmdArgs.push_back("--as-needed");
157  if (OnlyLibstdcxxStatic)
158  CmdArgs.push_back("-Bstatic");
159  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
160  if (OnlyLibstdcxxStatic)
161  CmdArgs.push_back("-Bdynamic");
162  CmdArgs.push_back("-lm");
163  CmdArgs.push_back("--pop-state");
164  }
165  }
166 
167  // Note that Fuchsia never needs to link in sanitizer runtime deps. Any
168  // sanitizer runtimes with system dependencies use the `.deplibs` feature
169  // instead.
170  addSanitizerRuntimes(ToolChain, Args, CmdArgs);
171 
172  addXRayRuntime(ToolChain, Args, CmdArgs);
173 
174  ToolChain.addProfileRTLibs(Args, CmdArgs);
175 
176  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
177 
178  if (Args.hasArg(options::OPT_pthread) ||
179  Args.hasArg(options::OPT_pthreads))
180  CmdArgs.push_back("-lpthread");
181 
182  if (Args.hasArg(options::OPT_fsplit_stack))
183  CmdArgs.push_back("--wrap=pthread_create");
184 
185  if (!Args.hasArg(options::OPT_nolibc))
186  CmdArgs.push_back("-lc");
187  }
188 
189  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
190  Exec, CmdArgs, Inputs, Output));
191 }
192 
193 /// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly.
194 
195 Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
196  const ArgList &Args)
197  : ToolChain(D, Triple, Args) {
198  getProgramPaths().push_back(getDriver().getInstalledDir());
199  if (getDriver().getInstalledDir() != D.Dir)
200  getProgramPaths().push_back(D.Dir);
201 
202  if (!D.SysRoot.empty()) {
204  llvm::sys::path::append(P, "lib");
205  getFilePaths().push_back(std::string(P.str()));
206  }
207 
208  auto FilePaths = [&](const Multilib &M) -> std::vector<std::string> {
209  std::vector<std::string> FP;
210  for (const std::string &Path : getStdlibPaths()) {
211  SmallString<128> P(Path);
212  llvm::sys::path::append(P, M.gccSuffix());
213  FP.push_back(std::string(P.str()));
214  }
215  return FP;
216  };
217 
219  // Use the noexcept variant with -fno-exceptions to avoid the extra overhead.
220  Multilibs.push_back(Multilib("noexcept", {}, {}, 1)
221  .flag("-fexceptions")
222  .flag("+fno-exceptions"));
223  // ASan has higher priority because we always want the instrumentated version.
224  Multilibs.push_back(Multilib("asan", {}, {}, 2)
225  .flag("+fsanitize=address"));
226  // Use the asan+noexcept variant with ASan and -fno-exceptions.
227  Multilibs.push_back(Multilib("asan+noexcept", {}, {}, 3)
228  .flag("+fsanitize=address")
229  .flag("-fexceptions")
230  .flag("+fno-exceptions"));
231  // HWASan has higher priority because we always want the instrumentated
232  // version.
234  Multilib("hwasan", {}, {}, 4).flag("+fsanitize=hwaddress"));
235  // Use the hwasan+noexcept variant with HWASan and -fno-exceptions.
236  Multilibs.push_back(Multilib("hwasan+noexcept", {}, {}, 5)
237  .flag("+fsanitize=hwaddress")
238  .flag("-fexceptions")
239  .flag("+fno-exceptions"));
240  // Use the relative vtables ABI.
241  // TODO: Remove these multilibs once relative vtables are enabled by default
242  // for Fuchsia.
243  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 6)
244  .flag("+fexperimental-relative-c++-abi-vtables"));
245  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 7)
246  .flag("+fexperimental-relative-c++-abi-vtables")
247  .flag("-fexceptions")
248  .flag("+fno-exceptions"));
249  Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 8)
250  .flag("+fexperimental-relative-c++-abi-vtables")
251  .flag("+fsanitize=address"));
252  Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 9)
253  .flag("+fexperimental-relative-c++-abi-vtables")
254  .flag("+fsanitize=address")
255  .flag("-fexceptions")
256  .flag("+fno-exceptions"));
257  Multilibs.push_back(Multilib("relative-vtables+hwasan", {}, {}, 10)
258  .flag("+fexperimental-relative-c++-abi-vtables")
259  .flag("+fsanitize=hwaddress"));
260  Multilibs.push_back(Multilib("relative-vtables+hwasan+noexcept", {}, {}, 11)
261  .flag("+fexperimental-relative-c++-abi-vtables")
262  .flag("+fsanitize=hwaddress")
263  .flag("-fexceptions")
264  .flag("+fno-exceptions"));
265  // Use Itanium C++ ABI for the compat multilib.
266  Multilibs.push_back(Multilib("compat", {}, {}, 12).flag("+fc++-abi=itanium"));
267 
268  Multilibs.FilterOut([&](const Multilib &M) {
269  std::vector<std::string> RD = FilePaths(M);
270  return llvm::all_of(RD, [&](std::string P) { return !getVFS().exists(P); });
271  });
272 
273  Multilib::flags_list Flags;
275  Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true),
276  "fexceptions", Flags);
277  addMultilibFlag(getSanitizerArgs(Args).needsAsanRt(), "fsanitize=address",
278  Flags);
279  addMultilibFlag(getSanitizerArgs(Args).needsHwasanRt(), "fsanitize=hwaddress",
280  Flags);
281 
283  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
284  options::OPT_fno_experimental_relative_cxx_abi_vtables,
285  /*default=*/false),
286  "fexperimental-relative-c++-abi-vtables", Flags);
287  addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
288  "fc++-abi=itanium", Flags);
289 
290  Multilibs.setFilePathsCallback(FilePaths);
291 
292  if (Multilibs.select(Flags, SelectedMultilib))
294  if (const auto &PathsCallback = Multilibs.filePathsCallback())
295  for (const auto &Path : PathsCallback(SelectedMultilib))
296  // Prepend the multilib path to ensure it takes the precedence.
297  getFilePaths().insert(getFilePaths().begin(), Path);
298 }
299 
301  types::ID InputType) const {
302  llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
303  return Triple.str();
304 }
305 
307  return new tools::fuchsia::Linker(*this);
308 }
309 
311  const ArgList &Args) const {
312  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
313  StringRef Value = A->getValue();
314  if (Value != "compiler-rt")
315  getDriver().Diag(clang::diag::err_drv_invalid_rtlib_name)
316  << A->getAsString(Args);
317  }
318 
320 }
321 
323 Fuchsia::GetCXXStdlibType(const ArgList &Args) const {
324  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
325  StringRef Value = A->getValue();
326  if (Value != "libc++")
327  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
328  << A->getAsString(Args);
329  }
330 
331  return ToolChain::CST_Libcxx;
332 }
333 
334 void Fuchsia::addClangTargetOptions(const ArgList &DriverArgs,
335  ArgStringList &CC1Args,
336  Action::OffloadKind) const {
337  if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
338  options::OPT_fno_use_init_array, true))
339  CC1Args.push_back("-fno-use-init-array");
340 }
341 
342 void Fuchsia::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
343  ArgStringList &CC1Args) const {
344  const Driver &D = getDriver();
345 
346  if (DriverArgs.hasArg(options::OPT_nostdinc))
347  return;
348 
349  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
351  llvm::sys::path::append(P, "include");
352  addSystemInclude(DriverArgs, CC1Args, P);
353  }
354 
355  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
356  return;
357 
358  // Check for configure-time C include directories.
359  StringRef CIncludeDirs(C_INCLUDE_DIRS);
360  if (CIncludeDirs != "") {
362  CIncludeDirs.split(dirs, ":");
363  for (StringRef dir : dirs) {
364  StringRef Prefix =
365  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
366  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
367  }
368  return;
369  }
370 
371  if (!D.SysRoot.empty()) {
373  llvm::sys::path::append(P, "include");
374  addExternCSystemInclude(DriverArgs, CC1Args, P.str());
375  }
376 }
377 
378 void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
379  ArgStringList &CC1Args) const {
380  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
381  options::OPT_nostdincxx))
382  return;
383 
384  const Driver &D = getDriver();
386 
387  auto AddCXXIncludePath = [&](StringRef Path) {
388  std::string Version = detectLibcxxVersion(Path);
389  if (Version.empty())
390  return;
391 
392  // First add the per-target include path.
393  SmallString<128> TargetDir(Path);
394  llvm::sys::path::append(TargetDir, Target, "c++", Version);
395  if (getVFS().exists(TargetDir))
396  addSystemInclude(DriverArgs, CC1Args, TargetDir);
397 
398  // Second add the generic one.
399  SmallString<128> Dir(Path);
400  llvm::sys::path::append(Dir, "c++", Version);
401  addSystemInclude(DriverArgs, CC1Args, Dir);
402  };
403 
404  switch (GetCXXStdlibType(DriverArgs)) {
405  case ToolChain::CST_Libcxx: {
407  llvm::sys::path::append(P, "..", "include");
408  AddCXXIncludePath(P);
409  break;
410  }
411 
412  default:
413  llvm_unreachable("invalid stdlib name");
414  }
415 }
416 
417 void Fuchsia::AddCXXStdlibLibArgs(const ArgList &Args,
418  ArgStringList &CmdArgs) const {
419  switch (GetCXXStdlibType(Args)) {
421  CmdArgs.push_back("-lc++");
422  if (Args.hasArg(options::OPT_fexperimental_library))
423  CmdArgs.push_back("-lc++experimental");
424  break;
425 
427  llvm_unreachable("invalid stdlib name");
428  }
429 }
430 
433  Res |= SanitizerKind::Address;
434  Res |= SanitizerKind::HWAddress;
435  Res |= SanitizerKind::PointerCompare;
436  Res |= SanitizerKind::PointerSubtract;
437  Res |= SanitizerKind::Fuzzer;
438  Res |= SanitizerKind::FuzzerNoLink;
439  Res |= SanitizerKind::Leak;
440  Res |= SanitizerKind::SafeStack;
441  Res |= SanitizerKind::Scudo;
442  Res |= SanitizerKind::Thread;
443  return Res;
444 }
445 
447  SanitizerMask Res;
448  switch (getTriple().getArch()) {
449  case llvm::Triple::aarch64:
450  Res |= SanitizerKind::ShadowCallStack;
451  break;
452  case llvm::Triple::x86_64:
453  Res |= SanitizerKind::SafeStack;
454  break;
455  default:
456  // TODO: Enable SafeStack on RISC-V once tested.
457  break;
458  }
459  return Res;
460 }
clang::driver::toolchains
Definition: AIX.h:55
clang::driver::Multilib::flags_list
std::vector< std::string > flags_list
Definition: Multilib.h:30
clang::driver::ToolChain::getEffectiveTriple
const llvm::Triple & getEffectiveTriple() const
Get the toolchain's effective clang triple.
Definition: ToolChain.h:262
clang::driver::Multilib::isDefault
bool isDefault() const
Check whether the default is selected.
Definition: Multilib.h:106
clang::driver::ToolChain::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: ToolChain.cpp:99
clang::driver::toolchains::Fuchsia::Fuchsia
Fuchsia(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly.
Definition: Fuchsia.cpp:195
clang::driver::ToolChain::getProgramPaths
path_list & getProgramPaths()
Definition: ToolChain.h:277
Driver.h
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::Driver::Dir
std::string Dir
The path the driver executable was in, as invoked from the command line.
Definition: Driver.h:153
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::toolchains::Fuchsia::GetCXXStdlibType
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: Fuchsia.cpp:323
clang::MultiVersionKind::Target
@ Target
clang::driver::tools
Definition: AIX.h:17
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:232
clang::driver::ToolChain::detectLibcxxVersion
virtual std::string detectLibcxxVersion(StringRef IncludePath) const
Definition: ToolChain.cpp:966
clang::driver::SanitizerArgs::needsTsanRt
bool needsTsanRt() const
Definition: SanitizerArgs.h:85
clang::driver::ToolChain::getTripleString
std::string getTripleString() const
Definition: ToolChain.h:257
clang::driver::toolchains::Fuchsia::getDefaultSanitizers
SanitizerMask getDefaultSanitizers() const override
Return sanitizers which are enabled by default.
Definition: Fuchsia.cpp:446
clang::driver::tools::getCPUName
std::string getCPUName(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &T, bool FromAs=false)
clang::driver::SanitizerArgs::needsHwasanRt
bool needsHwasanRt() const
Definition: SanitizerArgs.h:79
clang::driver::toolchains::Fuchsia::AddClangCXXStdlibIncludeArgs
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: Fuchsia.cpp:378
clang::driver::ToolChain::GetFilePath
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:610
clang::driver::MultilibSet::FilterOut
MultilibSet & FilterOut(FilterCallback F)
Filter out some subset of the Multilibs using a user defined callback.
Definition: Multilib.cpp:212
clang::driver::ToolChain::getSanitizerArgs
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const
Definition: ToolChain.cpp:146
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::MultilibSet::setFilePathsCallback
MultilibSet & setFilePathsCallback(IncludeDirsFunc F)
Definition: Multilib.h:181
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::ToolChain::getFilePaths
path_list & getFilePaths()
Definition: ToolChain.h:274
clang::driver::Driver::getLTOMode
LTOKind getLTOMode(bool IsOffload=false) const
Get the specific kind of LTO being performed.
Definition: Driver.h:668
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:142
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
Options.h
clang::driver::toolchains::Fuchsia::buildLinker
Tool * buildLinker() const override
Definition: Fuchsia.cpp:306
clang::driver::LTOK_Thin
@ LTOK_Thin
Definition: Driver.h:59
llvm::opt
Definition: DiagnosticOptions.h:19
DriverDiagnostic.h
clang::driver::MultilibSet::push_back
void push_back(const Multilib &M)
Add a completed Multilib to the set.
Definition: Multilib.cpp:232
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
llvm::SmallString< 128 >
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:234
clang::driver::ToolChain::SelectedMultilib
Multilib SelectedMultilib
Definition: ToolChain.h:190
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:181
clang::driver::SanitizerArgs::needsAsanRt
bool needsAsanRt() const
Definition: SanitizerArgs.h:78
clang::driver::toolchains::Fuchsia::AddCXXStdlibLibArgs
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
AddCXXStdlibLibArgs - Add the system specific linker arguments to use for the given C++ standard libr...
Definition: Fuchsia.cpp:417
clang::driver::ToolChain::getStdlibPaths
path_list getStdlibPaths() const
Definition: ToolChain.cpp:565
clang::driver::Multilib
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag.
Definition: Multilib.h:28
clang::driver::ToolChain::CST_Libcxx
@ CST_Libcxx
Definition: ToolChain.h:96
clang::driver::Driver::CCCIsCXX
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
Definition: Driver.h:211
clang::driver::tools::addXRayRuntime
bool addXRayRuntime(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
clang::driver::MultilibSet::filePathsCallback
const IncludeDirsFunc & filePathsCallback() const
Definition: Multilib.h:186
clang::driver::SanitizerArgs
Definition: SanitizerArgs.h:24
SanitizerArgs.h
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:165
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:248
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:1039
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:1014
clang::driver::tools::addLTOOptions
void addLTOOptions(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const InputInfo &Output, const InputInfo &Input, bool IsThinLTO)
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:1082
clang::driver::Driver::isUsingLTO
bool isUsingLTO(bool IsOffload=false) const
Returns true if we are performing any kind of LTO.
Definition: Driver.h:663
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:1020
Compilation.h
clang::driver::ToolChain::addProfileRTLibs
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 ...
Definition: ToolChain.cpp:823
clang::driver::toolchains::Fuchsia::GetRuntimeLibType
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override
Definition: Fuchsia.cpp:310
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::ToolChain::GetLinkerPath
std::string GetLinkerPath(bool *LinkerIsLLD=nullptr) const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name.
Definition: ToolChain.cpp:618
clang::driver::ToolChain::RLT_CompilerRT
@ RLT_CompilerRT
Definition: ToolChain.h:101
Value
Value
Definition: UninitializedValues.cpp:103
clang::driver::ToolChain::ComputeLLVMTriple
virtual std::string ComputeLLVMTriple(const llvm::opt::ArgList &Args, types::ID InputType=types::TY_INVALID) const
ComputeLLVMTriple - Return the LLVM target triple to use, after taking command line arguments into ac...
Definition: ToolChain.cpp:752
clang::driver::tools::AddRunTimeLibs
void AddRunTimeLibs(const ToolChain &TC, const Driver &D, llvm::opt::ArgStringList &CmdArgs, const llvm::opt::ArgList &Args)
clang::driver::types::ID
ID
Definition: Types.h:23
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::toolchains::Fuchsia::AddClangSystemIncludeArgs
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition: Fuchsia.cpp:342
clang::driver::toolchains::Fuchsia::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: Fuchsia.cpp:431
clang::driver::toolchains::Fuchsia::ComputeEffectiveClangTriple
std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, types::ID InputType) const override
ComputeEffectiveClangTriple - Return the Clang triple to use for this target, which may take into acc...
Definition: Fuchsia.cpp:300
clang::driver::tools::fuchsia::Linker
Definition: Fuchsia.h:21
clang::driver::InputInfo::getFilename
const char * getFilename() const
Definition: InputInfo.h:83
CommonArgs.h
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:75
clang::driver::tools::addSanitizerRuntimes
bool addSanitizerRuntimes(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
clang::driver::tools::addMultilibFlag
void addMultilibFlag(bool Enabled, const char *const Flag, Multilib::flags_list &Flags)
Flag must be a flag accepted by the driver with its leading '-' removed,
Definition: CommonArgs.cpp:1734
clang::driver::ToolChain::Multilibs
MultilibSet Multilibs
Definition: ToolChain.h:189
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:934
clang::driver::tools::addLinkerCompressDebugSectionsOption
void addLinkerCompressDebugSectionsOption(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
Definition: CommonArgs.cpp:285
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:86
clang::driver
Definition: Action.h:31
clang::driver::ResponseFileSupport::None
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
Definition: Job.h:78
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:919
clang::driver::SanitizerArgs::needsSharedRt
bool needsSharedRt() const
Definition: SanitizerArgs.h:75
clang::driver::MultilibSet::select
bool select(const Multilib::flags_list &Flags, Multilib &M) const
Pick the best multilib in the set,.
Definition: Multilib.cpp:244
clang::driver::JobAction
Definition: Action.h:398
clang::driver::Driver::DyldPrefix
std::string DyldPrefix
Dynamic loader prefix, if present.
Definition: Driver.h:184
Fuchsia.h
clang::driver::toolchains::Fuchsia
Definition: Fuchsia.h:38
clang::driver::toolchains::Fuchsia::addClangTargetOptions
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition: Fuchsia.cpp:334
clang::SanitizerMask
Definition: Sanitizers.h:30