clang  15.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  std::string CPU = getCPUName(D, Args, Triple);
91  if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
92  CmdArgs.push_back("--fix-cortex-a53-843419");
93  }
94 
95  CmdArgs.push_back("--eh-frame-hdr");
96 
97  if (Args.hasArg(options::OPT_static))
98  CmdArgs.push_back("-Bstatic");
99  else if (Args.hasArg(options::OPT_shared))
100  CmdArgs.push_back("-shared");
101 
102  const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs(Args);
103 
104  if (!Args.hasArg(options::OPT_shared)) {
105  std::string Dyld = D.DyldPrefix;
106  if (SanArgs.needsAsanRt() && SanArgs.needsSharedRt())
107  Dyld += "asan/";
108  if (SanArgs.needsHwasanRt() && SanArgs.needsSharedRt())
109  Dyld += "hwasan/";
110  if (SanArgs.needsTsanRt() && SanArgs.needsSharedRt())
111  Dyld += "tsan/";
112  Dyld += "ld.so.1";
113  CmdArgs.push_back("-dynamic-linker");
114  CmdArgs.push_back(Args.MakeArgString(Dyld));
115  }
116 
117  CmdArgs.push_back("-o");
118  CmdArgs.push_back(Output.getFilename());
119 
120  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
121  options::OPT_r)) {
122  if (!Args.hasArg(options::OPT_shared)) {
123  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
124  }
125  }
126 
127  Args.AddAllArgs(CmdArgs, options::OPT_L);
128  Args.AddAllArgs(CmdArgs, options::OPT_u);
129 
130  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
131 
132  if (D.isUsingLTO()) {
133  assert(!Inputs.empty() && "Must have at least one input.");
134  addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
135  D.getLTOMode() == LTOK_Thin);
136  }
137 
139  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
140 
141  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
142  options::OPT_r)) {
143  if (Args.hasArg(options::OPT_static))
144  CmdArgs.push_back("-Bdynamic");
145 
146  if (D.CCCIsCXX()) {
147  if (ToolChain.ShouldLinkCXXStdlib(Args)) {
148  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
149  !Args.hasArg(options::OPT_static);
150  CmdArgs.push_back("--push-state");
151  CmdArgs.push_back("--as-needed");
152  if (OnlyLibstdcxxStatic)
153  CmdArgs.push_back("-Bstatic");
154  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
155  if (OnlyLibstdcxxStatic)
156  CmdArgs.push_back("-Bdynamic");
157  CmdArgs.push_back("-lm");
158  CmdArgs.push_back("--pop-state");
159  }
160  }
161 
162  // Note that Fuchsia never needs to link in sanitizer runtime deps. Any
163  // sanitizer runtimes with system dependencies use the `.deplibs` feature
164  // instead.
165  addSanitizerRuntimes(ToolChain, Args, CmdArgs);
166 
167  addXRayRuntime(ToolChain, Args, CmdArgs);
168 
169  ToolChain.addProfileRTLibs(Args, CmdArgs);
170 
171  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
172 
173  if (Args.hasArg(options::OPT_pthread) ||
174  Args.hasArg(options::OPT_pthreads))
175  CmdArgs.push_back("-lpthread");
176 
177  if (Args.hasArg(options::OPT_fsplit_stack))
178  CmdArgs.push_back("--wrap=pthread_create");
179 
180  if (!Args.hasArg(options::OPT_nolibc))
181  CmdArgs.push_back("-lc");
182  }
183 
184  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
185  Exec, CmdArgs, Inputs, Output));
186 }
187 
188 /// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly.
189 
190 Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
191  const ArgList &Args)
192  : ToolChain(D, Triple, Args) {
193  getProgramPaths().push_back(getDriver().getInstalledDir());
194  if (getDriver().getInstalledDir() != D.Dir)
195  getProgramPaths().push_back(D.Dir);
196 
197  if (!D.SysRoot.empty()) {
199  llvm::sys::path::append(P, "lib");
200  getFilePaths().push_back(std::string(P.str()));
201  }
202 
203  auto FilePaths = [&](const Multilib &M) -> std::vector<std::string> {
204  std::vector<std::string> FP;
205  for (const std::string &Path : getStdlibPaths()) {
206  SmallString<128> P(Path);
207  llvm::sys::path::append(P, M.gccSuffix());
208  FP.push_back(std::string(P.str()));
209  }
210  return FP;
211  };
212 
214  // Use the noexcept variant with -fno-exceptions to avoid the extra overhead.
215  Multilibs.push_back(Multilib("noexcept", {}, {}, 1)
216  .flag("-fexceptions")
217  .flag("+fno-exceptions"));
218  // ASan has higher priority because we always want the instrumentated version.
219  Multilibs.push_back(Multilib("asan", {}, {}, 2)
220  .flag("+fsanitize=address"));
221  // Use the asan+noexcept variant with ASan and -fno-exceptions.
222  Multilibs.push_back(Multilib("asan+noexcept", {}, {}, 3)
223  .flag("+fsanitize=address")
224  .flag("-fexceptions")
225  .flag("+fno-exceptions"));
226  // HWASan has higher priority because we always want the instrumentated
227  // version.
229  Multilib("hwasan", {}, {}, 4).flag("+fsanitize=hwaddress"));
230  // Use the hwasan+noexcept variant with HWASan and -fno-exceptions.
231  Multilibs.push_back(Multilib("hwasan+noexcept", {}, {}, 5)
232  .flag("+fsanitize=hwaddress")
233  .flag("-fexceptions")
234  .flag("+fno-exceptions"));
235  // Use the relative vtables ABI.
236  // TODO: Remove these multilibs once relative vtables are enabled by default
237  // for Fuchsia.
238  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 6)
239  .flag("+fexperimental-relative-c++-abi-vtables"));
240  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 7)
241  .flag("+fexperimental-relative-c++-abi-vtables")
242  .flag("-fexceptions")
243  .flag("+fno-exceptions"));
244  Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 8)
245  .flag("+fexperimental-relative-c++-abi-vtables")
246  .flag("+fsanitize=address"));
247  Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 9)
248  .flag("+fexperimental-relative-c++-abi-vtables")
249  .flag("+fsanitize=address")
250  .flag("-fexceptions")
251  .flag("+fno-exceptions"));
252  Multilibs.push_back(Multilib("relative-vtables+hwasan", {}, {}, 10)
253  .flag("+fexperimental-relative-c++-abi-vtables")
254  .flag("+fsanitize=hwaddress"));
255  Multilibs.push_back(Multilib("relative-vtables+hwasan+noexcept", {}, {}, 11)
256  .flag("+fexperimental-relative-c++-abi-vtables")
257  .flag("+fsanitize=hwaddress")
258  .flag("-fexceptions")
259  .flag("+fno-exceptions"));
260  // Use Itanium C++ ABI for the compat multilib.
261  Multilibs.push_back(Multilib("compat", {}, {}, 12).flag("+fc++-abi=itanium"));
262 
263  Multilibs.FilterOut([&](const Multilib &M) {
264  std::vector<std::string> RD = FilePaths(M);
265  return llvm::all_of(RD, [&](std::string P) { return !getVFS().exists(P); });
266  });
267 
268  Multilib::flags_list Flags;
270  Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true),
271  "fexceptions", Flags);
272  addMultilibFlag(getSanitizerArgs(Args).needsAsanRt(), "fsanitize=address",
273  Flags);
274  addMultilibFlag(getSanitizerArgs(Args).needsHwasanRt(), "fsanitize=hwaddress",
275  Flags);
276 
278  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
279  options::OPT_fno_experimental_relative_cxx_abi_vtables,
280  /*default=*/false),
281  "fexperimental-relative-c++-abi-vtables", Flags);
282  addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
283  "fc++-abi=itanium", Flags);
284 
285  Multilibs.setFilePathsCallback(FilePaths);
286 
287  if (Multilibs.select(Flags, SelectedMultilib))
289  if (const auto &PathsCallback = Multilibs.filePathsCallback())
290  for (const auto &Path : PathsCallback(SelectedMultilib))
291  // Prepend the multilib path to ensure it takes the precedence.
292  getFilePaths().insert(getFilePaths().begin(), Path);
293 }
294 
296  types::ID InputType) const {
297  llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
298  return Triple.str();
299 }
300 
302  return new tools::fuchsia::Linker(*this);
303 }
304 
306  const ArgList &Args) const {
307  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
308  StringRef Value = A->getValue();
309  if (Value != "compiler-rt")
310  getDriver().Diag(clang::diag::err_drv_invalid_rtlib_name)
311  << A->getAsString(Args);
312  }
313 
315 }
316 
318 Fuchsia::GetCXXStdlibType(const ArgList &Args) const {
319  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
320  StringRef Value = A->getValue();
321  if (Value != "libc++")
322  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
323  << A->getAsString(Args);
324  }
325 
326  return ToolChain::CST_Libcxx;
327 }
328 
329 void Fuchsia::addClangTargetOptions(const ArgList &DriverArgs,
330  ArgStringList &CC1Args,
331  Action::OffloadKind) const {
332  if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
333  options::OPT_fno_use_init_array, true))
334  CC1Args.push_back("-fno-use-init-array");
335 }
336 
337 void Fuchsia::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
338  ArgStringList &CC1Args) const {
339  const Driver &D = getDriver();
340 
341  if (DriverArgs.hasArg(options::OPT_nostdinc))
342  return;
343 
344  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
346  llvm::sys::path::append(P, "include");
347  addSystemInclude(DriverArgs, CC1Args, P);
348  }
349 
350  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
351  return;
352 
353  // Check for configure-time C include directories.
354  StringRef CIncludeDirs(C_INCLUDE_DIRS);
355  if (CIncludeDirs != "") {
357  CIncludeDirs.split(dirs, ":");
358  for (StringRef dir : dirs) {
359  StringRef Prefix =
360  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
361  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
362  }
363  return;
364  }
365 
366  if (!D.SysRoot.empty()) {
368  llvm::sys::path::append(P, "include");
369  addExternCSystemInclude(DriverArgs, CC1Args, P.str());
370  }
371 }
372 
373 void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
374  ArgStringList &CC1Args) const {
375  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
376  DriverArgs.hasArg(options::OPT_nostdincxx))
377  return;
378 
379  const Driver &D = getDriver();
381 
382  auto AddCXXIncludePath = [&](StringRef Path) {
383  std::string Version = detectLibcxxVersion(Path);
384  if (Version.empty())
385  return;
386 
387  // First add the per-target include path.
388  SmallString<128> TargetDir(Path);
389  llvm::sys::path::append(TargetDir, Target, "c++", Version);
390  if (getVFS().exists(TargetDir))
391  addSystemInclude(DriverArgs, CC1Args, TargetDir);
392 
393  // Second add the generic one.
394  SmallString<128> Dir(Path);
395  llvm::sys::path::append(Dir, "c++", Version);
396  addSystemInclude(DriverArgs, CC1Args, Dir);
397  };
398 
399  switch (GetCXXStdlibType(DriverArgs)) {
400  case ToolChain::CST_Libcxx: {
402  llvm::sys::path::append(P, "..", "include");
403  AddCXXIncludePath(P);
404  break;
405  }
406 
407  default:
408  llvm_unreachable("invalid stdlib name");
409  }
410 }
411 
412 void Fuchsia::AddCXXStdlibLibArgs(const ArgList &Args,
413  ArgStringList &CmdArgs) const {
414  switch (GetCXXStdlibType(Args)) {
416  CmdArgs.push_back("-lc++");
417  break;
418 
420  llvm_unreachable("invalid stdlib name");
421  }
422 }
423 
426  Res |= SanitizerKind::Address;
427  Res |= SanitizerKind::HWAddress;
428  Res |= SanitizerKind::PointerCompare;
429  Res |= SanitizerKind::PointerSubtract;
430  Res |= SanitizerKind::Fuzzer;
431  Res |= SanitizerKind::FuzzerNoLink;
432  Res |= SanitizerKind::Leak;
433  Res |= SanitizerKind::SafeStack;
434  Res |= SanitizerKind::Scudo;
435  Res |= SanitizerKind::Thread;
436  return Res;
437 }
438 
440  SanitizerMask Res;
441  switch (getTriple().getArch()) {
442  case llvm::Triple::aarch64:
443  Res |= SanitizerKind::ShadowCallStack;
444  break;
445  case llvm::Triple::x86_64:
446  Res |= SanitizerKind::SafeStack;
447  break;
448  default:
449  // TODO: Enable SafeStack on RISC-V once tested.
450  break;
451  }
452  return Res;
453 }
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:255
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:190
clang::driver::ToolChain::getProgramPaths
path_list & getProgramPaths()
Definition: ToolChain.h:266
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:143
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::toolchains::Fuchsia::GetCXXStdlibType
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: Fuchsia.cpp:318
clang::MultiVersionKind::Target
@ Target
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::SanitizerArgs::needsTsanRt
bool needsTsanRt() const
Definition: SanitizerArgs.h:84
clang::driver::ToolChain::getTripleString
std::string getTripleString() const
Definition: ToolChain.h:250
clang::driver::toolchains::Fuchsia::getDefaultSanitizers
SanitizerMask getDefaultSanitizers() const override
Return sanitizers which are enabled by default.
Definition: Fuchsia.cpp:439
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:78
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:373
clang::driver::ToolChain::GetFilePath
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:577
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:118
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:263
clang::driver::Driver::getLTOMode
LTOKind getLTOMode(bool IsOffload=false) const
Get the specific kind of LTO being performed.
Definition: Driver.h:624
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::Fuchsia::buildLinker
Tool * buildLinker() const override
Definition: Fuchsia.cpp:301
clang::driver::LTOK_Thin
@ LTOK_Thin
Definition: Driver.h:55
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:227
clang::driver::ToolChain::SelectedMultilib
Multilib SelectedMultilib
Definition: ToolChain.h:186
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:171
clang::driver::SanitizerArgs::needsAsanRt
bool needsAsanRt() const
Definition: SanitizerArgs.h:77
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:412
clang::driver::ToolChain::getStdlibPaths
path_list getStdlibPaths() const
Definition: ToolChain.cpp:532
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:201
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:155
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:241
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::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: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
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:782
clang::driver::toolchains::Fuchsia::GetRuntimeLibType
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override
Definition: Fuchsia.cpp:305
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:585
clang::driver::ToolChain::RLT_CompilerRT
@ RLT_CompilerRT
Definition: ToolChain.h:101
Value
Value
Definition: UninitializedValues.cpp:102
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:714
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:337
clang::driver::toolchains::Fuchsia::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: Fuchsia.cpp:424
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:295
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:71
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:1611
clang::driver::ToolChain::Multilibs
MultilibSet Multilibs
Definition: ToolChain.h:185
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::tools::addLinkerCompressDebugSectionsOption
void addLinkerCompressDebugSectionsOption(const ToolChain &TC, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs)
Definition: CommonArgs.cpp:289
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:88
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:878
clang::driver::SanitizerArgs::needsSharedRt
bool needsSharedRt() const
Definition: SanitizerArgs.h:74
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:395
clang::driver::Driver::DyldPrefix
std::string DyldPrefix
Dynamic loader prefix, if present.
Definition: Driver.h:174
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:329
clang::SanitizerMask
Definition: Sanitizers.h:30