clang  14.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  ArgStringList CmdArgs;
41 
42  // Silence warning for "clang -g foo.o -o foo"
43  Args.ClaimAllArgs(options::OPT_g_Group);
44  // and "clang -emit-llvm foo.o -o foo"
45  Args.ClaimAllArgs(options::OPT_emit_llvm);
46  // and for "clang -w foo.o -o foo". Other warning options are already
47  // handled somewhere else.
48  Args.ClaimAllArgs(options::OPT_w);
49 
50  CmdArgs.push_back("-z");
51  CmdArgs.push_back("max-page-size=4096");
52 
53  CmdArgs.push_back("-z");
54  CmdArgs.push_back("now");
55 
56  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
57  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
58  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
59  CmdArgs.push_back("-z");
60  CmdArgs.push_back("rodynamic");
61  CmdArgs.push_back("-z");
62  CmdArgs.push_back("separate-loadable-segments");
63  CmdArgs.push_back("--pack-dyn-relocs=relr");
64  }
65 
66  if (!D.SysRoot.empty())
67  CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
68 
69  if (!Args.hasArg(options::OPT_shared) && !Args.hasArg(options::OPT_r))
70  CmdArgs.push_back("-pie");
71 
72  if (Args.hasArg(options::OPT_rdynamic))
73  CmdArgs.push_back("-export-dynamic");
74 
75  if (Args.hasArg(options::OPT_s))
76  CmdArgs.push_back("-s");
77 
78  if (Args.hasArg(options::OPT_r)) {
79  CmdArgs.push_back("-r");
80  } else {
81  CmdArgs.push_back("--build-id");
82  CmdArgs.push_back("--hash-style=gnu");
83  }
84 
85  CmdArgs.push_back("--eh-frame-hdr");
86 
87  if (Args.hasArg(options::OPT_static))
88  CmdArgs.push_back("-Bstatic");
89  else if (Args.hasArg(options::OPT_shared))
90  CmdArgs.push_back("-shared");
91 
92  const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs();
93 
94  if (!Args.hasArg(options::OPT_shared)) {
95  std::string Dyld = D.DyldPrefix;
96  if (SanArgs.needsAsanRt() && SanArgs.needsSharedRt())
97  Dyld += "asan/";
98  if (SanArgs.needsHwasanRt() && SanArgs.needsSharedRt())
99  Dyld += "hwasan/";
100  if (SanArgs.needsTsanRt() && SanArgs.needsSharedRt())
101  Dyld += "tsan/";
102  Dyld += "ld.so.1";
103  CmdArgs.push_back("-dynamic-linker");
104  CmdArgs.push_back(Args.MakeArgString(Dyld));
105  }
106 
107  CmdArgs.push_back("-o");
108  CmdArgs.push_back(Output.getFilename());
109 
110  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
111  if (!Args.hasArg(options::OPT_shared)) {
112  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
113  }
114  }
115 
116  Args.AddAllArgs(CmdArgs, options::OPT_L);
117  Args.AddAllArgs(CmdArgs, options::OPT_u);
118 
119  ToolChain.AddFilePathLibArgs(Args, CmdArgs);
120 
121  if (D.isUsingLTO()) {
122  assert(!Inputs.empty() && "Must have at least one input.");
123  addLTOOptions(ToolChain, Args, CmdArgs, Output, Inputs[0],
124  D.getLTOMode() == LTOK_Thin);
125  }
126 
127  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
128  bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
129  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
130  ToolChain.addProfileRTLibs(Args, CmdArgs);
131 
132  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
133  if (Args.hasArg(options::OPT_static))
134  CmdArgs.push_back("-Bdynamic");
135 
136  if (D.CCCIsCXX()) {
137  if (ToolChain.ShouldLinkCXXStdlib(Args)) {
138  bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
139  !Args.hasArg(options::OPT_static);
140  CmdArgs.push_back("--push-state");
141  CmdArgs.push_back("--as-needed");
142  if (OnlyLibstdcxxStatic)
143  CmdArgs.push_back("-Bstatic");
144  ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
145  if (OnlyLibstdcxxStatic)
146  CmdArgs.push_back("-Bdynamic");
147  CmdArgs.push_back("-lm");
148  CmdArgs.push_back("--pop-state");
149  }
150  }
151 
152  if (NeedsSanitizerDeps)
154 
155  if (NeedsXRayDeps)
156  linkXRayRuntimeDeps(ToolChain, CmdArgs);
157 
158  AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
159 
160  if (Args.hasArg(options::OPT_pthread) ||
161  Args.hasArg(options::OPT_pthreads))
162  CmdArgs.push_back("-lpthread");
163 
164  if (Args.hasArg(options::OPT_fsplit_stack))
165  CmdArgs.push_back("--wrap=pthread_create");
166 
167  if (!Args.hasArg(options::OPT_nolibc))
168  CmdArgs.push_back("-lc");
169  }
170 
171  C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
172  Exec, CmdArgs, Inputs, Output));
173 }
174 
175 /// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly.
176 
177 Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
178  const ArgList &Args)
179  : ToolChain(D, Triple, Args) {
180  getProgramPaths().push_back(getDriver().getInstalledDir());
181  if (getDriver().getInstalledDir() != D.Dir)
182  getProgramPaths().push_back(D.Dir);
183 
184  if (!D.SysRoot.empty()) {
186  llvm::sys::path::append(P, "lib");
187  getFilePaths().push_back(std::string(P.str()));
188  }
189 
190  auto FilePaths = [&](const Multilib &M) -> std::vector<std::string> {
191  std::vector<std::string> FP;
193  llvm::sys::path::append(P, M.gccSuffix());
194  FP.push_back(std::string(P.str()));
195  return FP;
196  };
197 
199  // Use the noexcept variant with -fno-exceptions to avoid the extra overhead.
200  Multilibs.push_back(Multilib("noexcept", {}, {}, 1)
201  .flag("-fexceptions")
202  .flag("+fno-exceptions"));
203  // ASan has higher priority because we always want the instrumentated version.
204  Multilibs.push_back(Multilib("asan", {}, {}, 2)
205  .flag("+fsanitize=address"));
206  // Use the asan+noexcept variant with ASan and -fno-exceptions.
207  Multilibs.push_back(Multilib("asan+noexcept", {}, {}, 3)
208  .flag("+fsanitize=address")
209  .flag("-fexceptions")
210  .flag("+fno-exceptions"));
211  // HWASan has higher priority because we always want the instrumentated
212  // version.
214  Multilib("hwasan", {}, {}, 4).flag("+fsanitize=hwaddress"));
215  // Use the hwasan+noexcept variant with HWASan and -fno-exceptions.
216  Multilibs.push_back(Multilib("hwasan+noexcept", {}, {}, 5)
217  .flag("+fsanitize=hwaddress")
218  .flag("-fexceptions")
219  .flag("+fno-exceptions"));
220  // Use the relative vtables ABI.
221  // TODO: Remove these multilibs once relative vtables are enabled by default
222  // for Fuchsia.
223  Multilibs.push_back(Multilib("relative-vtables", {}, {}, 6)
224  .flag("+fexperimental-relative-c++-abi-vtables"));
225  Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 7)
226  .flag("+fexperimental-relative-c++-abi-vtables")
227  .flag("-fexceptions")
228  .flag("+fno-exceptions"));
229  Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 8)
230  .flag("+fexperimental-relative-c++-abi-vtables")
231  .flag("+fsanitize=address"));
232  Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 9)
233  .flag("+fexperimental-relative-c++-abi-vtables")
234  .flag("+fsanitize=address")
235  .flag("-fexceptions")
236  .flag("+fno-exceptions"));
237  Multilibs.push_back(Multilib("relative-vtables+hwasan", {}, {}, 10)
238  .flag("+fexperimental-relative-c++-abi-vtables")
239  .flag("+fsanitize=hwaddress"));
240  Multilibs.push_back(Multilib("relative-vtables+hwasan+noexcept", {}, {}, 11)
241  .flag("+fexperimental-relative-c++-abi-vtables")
242  .flag("+fsanitize=hwaddress")
243  .flag("-fexceptions")
244  .flag("+fno-exceptions"));
245  // Use Itanium C++ ABI for the compat multilib.
246  Multilibs.push_back(Multilib("compat", {}, {}, 12).flag("+fc++-abi=itanium"));
247 
248  Multilibs.FilterOut([&](const Multilib &M) {
249  std::vector<std::string> RD = FilePaths(M);
250  return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
251  return !getVFS().exists(P);
252  });
253  });
254 
255  Multilib::flags_list Flags;
257  Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true),
258  "fexceptions", Flags);
259  addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", Flags);
260  addMultilibFlag(getSanitizerArgs().needsHwasanRt(), "fsanitize=hwaddress",
261  Flags);
262 
264  Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
265  options::OPT_fno_experimental_relative_cxx_abi_vtables,
266  /*default=*/false),
267  "fexperimental-relative-c++-abi-vtables", Flags);
268  addMultilibFlag(Args.getLastArgValue(options::OPT_fcxx_abi_EQ) == "itanium",
269  "fc++-abi=itanium", Flags);
270 
271  Multilibs.setFilePathsCallback(FilePaths);
272 
273  if (Multilibs.select(Flags, SelectedMultilib))
275  if (const auto &PathsCallback = Multilibs.filePathsCallback())
276  for (const auto &Path : PathsCallback(SelectedMultilib))
277  // Prepend the multilib path to ensure it takes the precedence.
278  getFilePaths().insert(getFilePaths().begin(), Path);
279 }
280 
282  types::ID InputType) const {
283  llvm::Triple Triple(ComputeLLVMTriple(Args, InputType));
284  return Triple.str();
285 }
286 
288  return new tools::fuchsia::Linker(*this);
289 }
290 
292  const ArgList &Args) const {
293  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
294  StringRef Value = A->getValue();
295  if (Value != "compiler-rt")
296  getDriver().Diag(clang::diag::err_drv_invalid_rtlib_name)
297  << A->getAsString(Args);
298  }
299 
301 }
302 
304 Fuchsia::GetCXXStdlibType(const ArgList &Args) const {
305  if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
306  StringRef Value = A->getValue();
307  if (Value != "libc++")
308  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
309  << A->getAsString(Args);
310  }
311 
312  return ToolChain::CST_Libcxx;
313 }
314 
315 void Fuchsia::addClangTargetOptions(const ArgList &DriverArgs,
316  ArgStringList &CC1Args,
317  Action::OffloadKind) const {
318  if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
319  options::OPT_fno_use_init_array, true))
320  CC1Args.push_back("-fno-use-init-array");
321 }
322 
323 void Fuchsia::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
324  ArgStringList &CC1Args) const {
325  const Driver &D = getDriver();
326 
327  if (DriverArgs.hasArg(options::OPT_nostdinc))
328  return;
329 
330  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
332  llvm::sys::path::append(P, "include");
333  addSystemInclude(DriverArgs, CC1Args, P);
334  }
335 
336  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
337  return;
338 
339  // Check for configure-time C include directories.
340  StringRef CIncludeDirs(C_INCLUDE_DIRS);
341  if (CIncludeDirs != "") {
343  CIncludeDirs.split(dirs, ":");
344  for (StringRef dir : dirs) {
345  StringRef Prefix =
346  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
347  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
348  }
349  return;
350  }
351 
352  if (!D.SysRoot.empty()) {
354  llvm::sys::path::append(P, "include");
355  addExternCSystemInclude(DriverArgs, CC1Args, P.str());
356  }
357 }
358 
359 void Fuchsia::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
360  ArgStringList &CC1Args) const {
361  if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
362  DriverArgs.hasArg(options::OPT_nostdincxx))
363  return;
364 
365  const Driver &D = getDriver();
367 
368  auto AddCXXIncludePath = [&](StringRef Path) {
369  std::string Version = detectLibcxxVersion(Path);
370  if (Version.empty())
371  return;
372 
373  // First add the per-target include path.
374  SmallString<128> TargetDir(Path);
375  llvm::sys::path::append(TargetDir, Target, "c++", Version);
376  if (getVFS().exists(TargetDir))
377  addSystemInclude(DriverArgs, CC1Args, TargetDir);
378 
379  // Second add the generic one.
380  SmallString<128> Dir(Path);
381  llvm::sys::path::append(Dir, "c++", Version);
382  addSystemInclude(DriverArgs, CC1Args, Dir);
383  };
384 
385  switch (GetCXXStdlibType(DriverArgs)) {
386  case ToolChain::CST_Libcxx: {
388  llvm::sys::path::append(P, "..", "include");
389  AddCXXIncludePath(P);
390  break;
391  }
392 
393  default:
394  llvm_unreachable("invalid stdlib name");
395  }
396 }
397 
398 void Fuchsia::AddCXXStdlibLibArgs(const ArgList &Args,
399  ArgStringList &CmdArgs) const {
400  switch (GetCXXStdlibType(Args)) {
402  CmdArgs.push_back("-lc++");
403  break;
404 
406  llvm_unreachable("invalid stdlib name");
407  }
408 }
409 
412  Res |= SanitizerKind::Address;
413  Res |= SanitizerKind::HWAddress;
414  Res |= SanitizerKind::PointerCompare;
415  Res |= SanitizerKind::PointerSubtract;
416  Res |= SanitizerKind::Fuzzer;
417  Res |= SanitizerKind::FuzzerNoLink;
418  Res |= SanitizerKind::Leak;
419  Res |= SanitizerKind::SafeStack;
420  Res |= SanitizerKind::Scudo;
421  Res |= SanitizerKind::Thread;
422  return Res;
423 }
424 
426  SanitizerMask Res;
427  switch (getTriple().getArch()) {
428  case llvm::Triple::aarch64:
429  Res |= SanitizerKind::ShadowCallStack;
430  break;
431  case llvm::Triple::x86_64:
432  Res |= SanitizerKind::SafeStack;
433  break;
434  default:
435  // TODO: Enable SafeStack on RISC-V once tested.
436  break;
437  }
438  return Res;
439 }
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::getSanitizerArgs
const SanitizerArgs & getSanitizerArgs() const
Definition: ToolChain.cpp:117
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:177
clang::driver::ToolChain::getProgramPaths
path_list & getProgramPaths()
Definition: ToolChain.h:262
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:123
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::toolchains::Fuchsia::GetCXXStdlibType
CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override
Definition: Fuchsia.cpp:304
clang::MultiVersionKind::Target
@ Target
clang::driver::tools
Definition: AIX.h:17
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:221
clang::driver::ToolChain::detectLibcxxVersion
virtual std::string detectLibcxxVersion(StringRef IncludePath) const
Definition: ToolChain.cpp:884
clang::driver::SanitizerArgs::needsTsanRt
bool needsTsanRt() const
Definition: SanitizerArgs.h:80
clang::driver::ToolChain::getTripleString
std::string getTripleString() const
Definition: ToolChain.h:246
clang::driver::toolchains::Fuchsia::getDefaultSanitizers
SanitizerMask getDefaultSanitizers() const override
Return sanitizers which are enabled by default.
Definition: Fuchsia.cpp:425
clang::driver::SanitizerArgs::needsHwasanRt
bool needsHwasanRt() const
Definition: SanitizerArgs.h:74
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:359
clang::driver::ToolChain::GetFilePath
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:538
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::GetLinkerPath
std::string GetLinkerPath(bool *LinkerIsLLD=nullptr, bool *LinkerIsLLDDarwinNew=nullptr) const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name.
Definition: ToolChain.cpp:546
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:259
clang::driver::Driver::getLTOMode
LTOKind getLTOMode(bool IsOffload=false) const
Get the specific kind of LTO being performed.
Definition: Driver.h:564
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:112
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:287
clang::driver::LTOK_Thin
@ LTOK_Thin
Definition: Driver.h:53
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:223
clang::driver::ToolChain::SelectedMultilib
Multilib SelectedMultilib
Definition: ToolChain.h:182
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:151
clang::driver::SanitizerArgs::needsAsanRt
bool needsAsanRt() const
Definition: SanitizerArgs.h:73
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:398
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:179
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:135
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:237
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:955
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:932
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:998
clang::driver::Driver::isUsingLTO
bool isUsingLTO(bool IsOffload=false) const
Returns true if we are performing any kind of LTO.
Definition: Driver.h:559
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:938
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:749
clang::driver::toolchains::Fuchsia::GetRuntimeLibType
RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override
Definition: Fuchsia.cpp:291
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::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:681
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:323
clang::driver::toolchains::Fuchsia::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: Fuchsia.cpp:410
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:281
clang::driver::tools::fuchsia::Linker
Definition: Fuchsia.h:21
clang::driver::InputInfo::getFilename
const char * getFilename() const
Definition: InputInfo.h:83
clang::driver::tools::linkSanitizerRuntimeDeps
void linkSanitizerRuntimeDeps(const ToolChain &TC, llvm::opt::ArgStringList &CmdArgs)
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:59
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:1536
clang::driver::ToolChain::Multilibs
MultilibSet Multilibs
Definition: ToolChain.h:181
clang::driver::tools::linkXRayRuntimeDeps
void linkXRayRuntimeDeps(const ToolChain &TC, llvm::opt::ArgStringList &CmdArgs)
clang::driver::ToolChain::getStdlibPath
virtual std::string getStdlibPath() const
Definition: ToolChain.cpp:496
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:860
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:85
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:845
clang::driver::SanitizerArgs::needsSharedRt
bool needsSharedRt() const
Definition: SanitizerArgs.h:70
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:380
clang::driver::Driver::DyldPrefix
std::string DyldPrefix
Dynamic loader prefix, if present.
Definition: Driver.h:154
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:315
clang::SanitizerMask
Definition: Sanitizers.h:30