clang  15.0.0git
Linux.cpp
Go to the documentation of this file.
1 //===--- Linux.h - Linux 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 "Linux.h"
10 #include "Arch/ARM.h"
11 #include "Arch/Mips.h"
12 #include "Arch/PPC.h"
13 #include "Arch/RISCV.h"
14 #include "CommonArgs.h"
15 #include "clang/Config/config.h"
16 #include "clang/Driver/Distro.h"
17 #include "clang/Driver/Driver.h"
18 #include "clang/Driver/Options.h"
20 #include "llvm/Option/ArgList.h"
21 #include "llvm/ProfileData/InstrProf.h"
22 #include "llvm/Support/Path.h"
23 #include "llvm/Support/ScopedPrinter.h"
24 #include "llvm/Support/VirtualFileSystem.h"
25 #include <system_error>
26 
27 using namespace clang::driver;
28 using namespace clang::driver::toolchains;
29 using namespace clang;
30 using namespace llvm::opt;
31 
33 
34 /// Get our best guess at the multiarch triple for a target.
35 ///
36 /// Debian-based systems are starting to use a multiarch setup where they use
37 /// a target-triple directory in the library and header search paths.
38 /// Unfortunately, this triple does not align with the vanilla target triple,
39 /// so we provide a rough mapping here.
41  const llvm::Triple &TargetTriple,
42  StringRef SysRoot) const {
43  llvm::Triple::EnvironmentType TargetEnvironment =
44  TargetTriple.getEnvironment();
45  bool IsAndroid = TargetTriple.isAndroid();
46  bool IsMipsR6 = TargetTriple.getSubArch() == llvm::Triple::MipsSubArch_r6;
47  bool IsMipsN32Abi = TargetTriple.getEnvironment() == llvm::Triple::GNUABIN32;
48 
49  // For most architectures, just use whatever we have rather than trying to be
50  // clever.
51  switch (TargetTriple.getArch()) {
52  default:
53  break;
54 
55  // We use the existence of '/lib/<triple>' as a directory to detect some
56  // common linux triples that don't quite match the Clang triple for both
57  // 32-bit and 64-bit targets. Multiarch fixes its install triples to these
58  // regardless of what the actual target triple is.
59  case llvm::Triple::arm:
60  case llvm::Triple::thumb:
61  if (IsAndroid)
62  return "arm-linux-androideabi";
63  if (TargetEnvironment == llvm::Triple::GNUEABIHF)
64  return "arm-linux-gnueabihf";
65  return "arm-linux-gnueabi";
66  case llvm::Triple::armeb:
67  case llvm::Triple::thumbeb:
68  if (TargetEnvironment == llvm::Triple::GNUEABIHF)
69  return "armeb-linux-gnueabihf";
70  return "armeb-linux-gnueabi";
71  case llvm::Triple::x86:
72  if (IsAndroid)
73  return "i686-linux-android";
74  return "i386-linux-gnu";
75  case llvm::Triple::x86_64:
76  if (IsAndroid)
77  return "x86_64-linux-android";
78  if (TargetEnvironment == llvm::Triple::GNUX32)
79  return "x86_64-linux-gnux32";
80  return "x86_64-linux-gnu";
81  case llvm::Triple::aarch64:
82  if (IsAndroid)
83  return "aarch64-linux-android";
84  return "aarch64-linux-gnu";
85  case llvm::Triple::aarch64_be:
86  return "aarch64_be-linux-gnu";
87 
88  case llvm::Triple::m68k:
89  return "m68k-linux-gnu";
90 
91  case llvm::Triple::mips:
92  return IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu";
93  case llvm::Triple::mipsel:
94  if (IsAndroid)
95  return "mipsel-linux-android";
96  return IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu";
97  case llvm::Triple::mips64: {
98  std::string MT = std::string(IsMipsR6 ? "mipsisa64r6" : "mips64") +
99  "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
100  if (D.getVFS().exists(SysRoot + "/lib/" + MT))
101  return MT;
102  if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
103  return "mips64-linux-gnu";
104  break;
105  }
106  case llvm::Triple::mips64el: {
107  if (IsAndroid)
108  return "mips64el-linux-android";
109  std::string MT = std::string(IsMipsR6 ? "mipsisa64r6el" : "mips64el") +
110  "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
111  if (D.getVFS().exists(SysRoot + "/lib/" + MT))
112  return MT;
113  if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu"))
114  return "mips64el-linux-gnu";
115  break;
116  }
117  case llvm::Triple::ppc:
118  if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnuspe"))
119  return "powerpc-linux-gnuspe";
120  return "powerpc-linux-gnu";
121  case llvm::Triple::ppcle:
122  return "powerpcle-linux-gnu";
123  case llvm::Triple::ppc64:
124  return "powerpc64-linux-gnu";
125  case llvm::Triple::ppc64le:
126  return "powerpc64le-linux-gnu";
127  case llvm::Triple::sparc:
128  return "sparc-linux-gnu";
129  case llvm::Triple::sparcv9:
130  return "sparc64-linux-gnu";
131  case llvm::Triple::systemz:
132  return "s390x-linux-gnu";
133  }
134  return TargetTriple.str();
135 }
136 
137 static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
138  if (Triple.isMIPS()) {
139  if (Triple.isAndroid()) {
140  StringRef CPUName;
141  StringRef ABIName;
142  tools::mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
143  if (CPUName == "mips32r6")
144  return "libr6";
145  if (CPUName == "mips32r2")
146  return "libr2";
147  }
148  // lib32 directory has a special meaning on MIPS targets.
149  // It contains N32 ABI binaries. Use this folder if produce
150  // code for N32 ABI only.
151  if (tools::mips::hasMipsAbiArg(Args, "n32"))
152  return "lib32";
153  return Triple.isArch32Bit() ? "lib" : "lib64";
154  }
155 
156  // It happens that only x86, PPC and SPARC use the 'lib32' variant of
157  // oslibdir, and using that variant while targeting other architectures causes
158  // problems because the libraries are laid out in shared system roots that
159  // can't cope with a 'lib32' library search path being considered. So we only
160  // enable them when we know we may need it.
161  //
162  // FIXME: This is a bit of a hack. We should really unify this code for
163  // reasoning about oslibdir spellings with the lib dir spellings in the
164  // GCCInstallationDetector, but that is a more significant refactoring.
165  if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
166  Triple.getArch() == llvm::Triple::sparc)
167  return "lib32";
168 
169  if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32())
170  return "libx32";
171 
172  if (Triple.getArch() == llvm::Triple::riscv32)
173  return "lib32";
174 
175  return Triple.isArch32Bit() ? "lib" : "lib64";
176 }
177 
178 Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
179  : Generic_ELF(D, Triple, Args) {
180  GCCInstallation.init(Triple, Args);
183  llvm::Triple::ArchType Arch = Triple.getArch();
184  std::string SysRoot = computeSysRoot();
186 
187  Generic_GCC::PushPPaths(PPaths);
188 
189  Distro Distro(D.getVFS(), Triple);
190 
191  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
192  ExtraOpts.push_back("-z");
193  ExtraOpts.push_back("now");
194  }
195 
197  Triple.isAndroid()) {
198  ExtraOpts.push_back("-z");
199  ExtraOpts.push_back("relro");
200  }
201 
202  // Android ARM/AArch64 use max-page-size=4096 to reduce VMA usage. Note, lld
203  // from 11 onwards default max-page-size to 65536 for both ARM and AArch64.
204  if ((Triple.isARM() || Triple.isAArch64()) && Triple.isAndroid()) {
205  ExtraOpts.push_back("-z");
206  ExtraOpts.push_back("max-page-size=4096");
207  }
208 
209  if (GCCInstallation.getParentLibPath().contains("opt/rh/"))
210  // With devtoolset on RHEL, we want to add a bin directory that is relative
211  // to the detected gcc install, because if we are using devtoolset gcc then
212  // we want to use other tools from devtoolset (e.g. ld) instead of the
213  // standard system tools.
214  PPaths.push_back(Twine(GCCInstallation.getParentLibPath() +
215  "/../bin").str());
216 
217  if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
218  ExtraOpts.push_back("-X");
219 
220  const bool IsAndroid = Triple.isAndroid();
221  const bool IsMips = Triple.isMIPS();
222  const bool IsHexagon = Arch == llvm::Triple::hexagon;
223  const bool IsRISCV = Triple.isRISCV();
224  const bool IsCSKY = Triple.isCSKY();
225 
226  if (IsCSKY)
227  SysRoot = SysRoot + SelectedMultilib.osSuffix();
228 
229  if ((IsMips || IsCSKY) && !SysRoot.empty())
230  ExtraOpts.push_back("--sysroot=" + SysRoot);
231 
232  // Do not use 'gnu' hash style for Mips targets because .gnu.hash
233  // and the MIPS ABI require .dynsym to be sorted in different ways.
234  // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
235  // ABI requires a mapping between the GOT and the symbol table.
236  // Android loader does not support .gnu.hash until API 23.
237  // Hexagon linker/loader does not support .gnu.hash
238  if (!IsMips && !IsHexagon) {
241  (IsAndroid && !Triple.isAndroidVersionLT(23)))
242  ExtraOpts.push_back("--hash-style=gnu");
243 
244  if (Distro.IsDebian() || Distro.IsOpenSUSE() ||
247  (IsAndroid && Triple.isAndroidVersionLT(23)))
248  ExtraOpts.push_back("--hash-style=both");
249  }
250 
251 #ifdef ENABLE_LINKER_BUILD_ID
252  ExtraOpts.push_back("--build-id");
253 #endif
254 
255  if (IsAndroid || Distro.IsOpenSUSE())
256  ExtraOpts.push_back("--enable-new-dtags");
257 
258  // The selection of paths to try here is designed to match the patterns which
259  // the GCC driver itself uses, as this is part of the GCC-compatible driver.
260  // This was determined by running GCC in a fake filesystem, creating all
261  // possible permutations of these directories, and seeing which ones it added
262  // to the link paths.
263  path_list &Paths = getFilePaths();
264 
265  const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
266  const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
267 
268  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
269  // used. We need add both libo32 and /lib.
270  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
271  Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths);
272  addPathIfExists(D, SysRoot + "/libo32", Paths);
273  addPathIfExists(D, SysRoot + "/usr/libo32", Paths);
274  }
275  Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
276 
277  addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
278  addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
279 
280  if (IsAndroid) {
281  // Android sysroots contain a library directory for each supported OS
282  // version as well as some unversioned libraries in the usual multiarch
283  // directory.
285  D,
286  SysRoot + "/usr/lib/" + MultiarchTriple + "/" +
287  llvm::to_string(Triple.getEnvironmentVersion().getMajor()),
288  Paths);
289  }
290 
291  addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
292  // 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot
293  // find /usr/lib64 as it is referenced as /usr/lib/../lib64. So we handle
294  // this here.
295  if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
296  Triple.isArch64Bit())
297  addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
298  else
299  addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
300  if (IsRISCV) {
301  StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
302  addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths);
303  addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths);
304  }
305 
306  Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
307 
308  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
309  // libc++.so in D.Dir+"/../lib/". Detect this path.
310  // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
311  if (StringRef(D.Dir).startswith(SysRoot) &&
312  D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
313  addPathIfExists(D, D.Dir + "/../lib", Paths);
314 
315  addPathIfExists(D, SysRoot + "/lib", Paths);
316  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
317 }
318 
320  if (getTriple().isAndroid())
323 }
324 
326  if (getTriple().isAndroid())
327  return 4;
329 }
330 
332  if (getTriple().isAndroid())
333  return ToolChain::CST_Libcxx;
335 }
336 
337 bool Linux::HasNativeLLVMSupport() const { return true; }
338 
339 Tool *Linux::buildLinker() const { return new tools::gnutools::Linker(*this); }
340 
342  return new tools::gnutools::StaticLibTool(*this);
343 }
344 
346  return new tools::gnutools::Assembler(*this);
347 }
348 
350  if (!getDriver().SysRoot.empty())
351  return getDriver().SysRoot;
352 
353  if (getTriple().isAndroid()) {
354  // Android toolchains typically include a sysroot at ../sysroot relative to
355  // the clang binary.
356  const StringRef ClangDir = getDriver().getInstalledDir();
357  std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str();
358  if (getVFS().exists(AndroidSysRootPath))
359  return AndroidSysRootPath;
360  }
361 
362  if (getTriple().isCSKY()) {
363  // CSKY toolchains use different names for sysroot folder.
364  if (!GCCInstallation.isValid())
365  return std::string();
366  // GCCInstallation.getInstallPath() =
367  // $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0
368  // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
369  std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" +
370  GCCInstallation.getTriple().str() + "/libc")
371  .str();
372  if (getVFS().exists(Path))
373  return Path;
374  return std::string();
375  }
376 
377  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
378  return std::string();
379 
380  // Standalone MIPS toolchains use different names for sysroot folder
381  // and put it into different places. Here we try to check some known
382  // variants.
383 
384  const StringRef InstallDir = GCCInstallation.getInstallPath();
385  const StringRef TripleStr = GCCInstallation.getTriple().str();
387 
388  std::string Path =
389  (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
390  .str();
391 
392  if (getVFS().exists(Path))
393  return Path;
394 
395  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
396 
397  if (getVFS().exists(Path))
398  return Path;
399 
400  return std::string();
401 }
402 
403 std::string Linux::getDynamicLinker(const ArgList &Args) const {
404  const llvm::Triple::ArchType Arch = getArch();
405  const llvm::Triple &Triple = getTriple();
406 
407  const Distro Distro(getDriver().getVFS(), Triple);
408 
409  if (Triple.isAndroid())
410  return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
411 
412  if (Triple.isMusl()) {
413  std::string ArchName;
414  bool IsArm = false;
415 
416  switch (Arch) {
417  case llvm::Triple::arm:
418  case llvm::Triple::thumb:
419  ArchName = "arm";
420  IsArm = true;
421  break;
422  case llvm::Triple::armeb:
423  case llvm::Triple::thumbeb:
424  ArchName = "armeb";
425  IsArm = true;
426  break;
427  case llvm::Triple::x86:
428  ArchName = "i386";
429  break;
430  case llvm::Triple::x86_64:
431  ArchName = Triple.isX32() ? "x32" : Triple.getArchName().str();
432  break;
433  default:
434  ArchName = Triple.getArchName().str();
435  }
436  if (IsArm &&
437  (Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
439  ArchName += "hf";
440  if (Arch == llvm::Triple::ppc &&
441  Triple.getSubArch() == llvm::Triple::PPCSubArch_spe)
442  ArchName = "powerpc-sf";
443 
444  return "/lib/ld-musl-" + ArchName + ".so.1";
445  }
446 
447  std::string LibDir;
448  std::string Loader;
449 
450  switch (Arch) {
451  default:
452  llvm_unreachable("unsupported architecture");
453 
454  case llvm::Triple::aarch64:
455  LibDir = "lib";
456  Loader = "ld-linux-aarch64.so.1";
457  break;
458  case llvm::Triple::aarch64_be:
459  LibDir = "lib";
460  Loader = "ld-linux-aarch64_be.so.1";
461  break;
462  case llvm::Triple::arm:
463  case llvm::Triple::thumb:
464  case llvm::Triple::armeb:
465  case llvm::Triple::thumbeb: {
466  const bool HF =
467  Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
469 
470  LibDir = "lib";
471  Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3";
472  break;
473  }
474  case llvm::Triple::m68k:
475  LibDir = "lib";
476  Loader = "ld.so.1";
477  break;
478  case llvm::Triple::mips:
479  case llvm::Triple::mipsel:
480  case llvm::Triple::mips64:
481  case llvm::Triple::mips64el: {
482  bool IsNaN2008 = tools::mips::isNaN2008(getDriver(), Args, Triple);
483 
484  LibDir = "lib" + tools::mips::getMipsABILibSuffix(Args, Triple);
485 
486  if (tools::mips::isUCLibc(Args))
487  Loader = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0";
488  else if (!Triple.hasEnvironment() &&
489  Triple.getVendor() == llvm::Triple::VendorType::MipsTechnologies)
490  Loader =
491  Triple.isLittleEndian() ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1";
492  else
493  Loader = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1";
494 
495  break;
496  }
497  case llvm::Triple::ppc:
498  LibDir = "lib";
499  Loader = "ld.so.1";
500  break;
501  case llvm::Triple::ppcle:
502  LibDir = "lib";
503  Loader = "ld.so.1";
504  break;
505  case llvm::Triple::ppc64:
506  LibDir = "lib64";
507  Loader =
508  (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1";
509  break;
510  case llvm::Triple::ppc64le:
511  LibDir = "lib64";
512  Loader =
513  (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
514  break;
515  case llvm::Triple::riscv32: {
516  StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
517  LibDir = "lib";
518  Loader = ("ld-linux-riscv32-" + ABIName + ".so.1").str();
519  break;
520  }
521  case llvm::Triple::riscv64: {
522  StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
523  LibDir = "lib";
524  Loader = ("ld-linux-riscv64-" + ABIName + ".so.1").str();
525  break;
526  }
527  case llvm::Triple::sparc:
528  case llvm::Triple::sparcel:
529  LibDir = "lib";
530  Loader = "ld-linux.so.2";
531  break;
532  case llvm::Triple::sparcv9:
533  LibDir = "lib64";
534  Loader = "ld-linux.so.2";
535  break;
536  case llvm::Triple::systemz:
537  LibDir = "lib";
538  Loader = "ld64.so.1";
539  break;
540  case llvm::Triple::x86:
541  LibDir = "lib";
542  Loader = "ld-linux.so.2";
543  break;
544  case llvm::Triple::x86_64: {
545  bool X32 = Triple.isX32();
546 
547  LibDir = X32 ? "libx32" : "lib64";
548  Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
549  break;
550  }
551  case llvm::Triple::ve:
552  return "/opt/nec/ve/lib/ld-linux-ve.so.1";
553  case llvm::Triple::csky: {
554  LibDir = "lib";
555  Loader = "ld.so.1";
556  break;
557  }
558  }
559 
560  if (Distro == Distro::Exherbo &&
561  (Triple.getVendor() == llvm::Triple::UnknownVendor ||
562  Triple.getVendor() == llvm::Triple::PC))
563  return "/usr/" + Triple.str() + "/lib/" + Loader;
564  return "/" + LibDir + "/" + Loader;
565 }
566 
567 void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
568  ArgStringList &CC1Args) const {
569  const Driver &D = getDriver();
570  std::string SysRoot = computeSysRoot();
571 
572  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
573  return;
574 
575  // Add 'include' in the resource directory, which is similar to
576  // GCC_INCLUDE_DIR (private headers) in GCC. Note: the include directory
577  // contains some files conflicting with system /usr/include. musl systems
578  // prefer the /usr/include copies which are more relevant.
579  SmallString<128> ResourceDirInclude(D.ResourceDir);
580  llvm::sys::path::append(ResourceDirInclude, "include");
581  if (!DriverArgs.hasArg(options::OPT_nobuiltininc) &&
582  (!getTriple().isMusl() || DriverArgs.hasArg(options::OPT_nostdlibinc)))
583  addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
584 
585  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
586  return;
587 
588  // LOCAL_INCLUDE_DIR
589  addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
590  // TOOL_INCLUDE_DIR
591  AddMultilibIncludeArgs(DriverArgs, CC1Args);
592 
593  // Check for configure-time C include directories.
594  StringRef CIncludeDirs(C_INCLUDE_DIRS);
595  if (CIncludeDirs != "") {
597  CIncludeDirs.split(dirs, ":");
598  for (StringRef dir : dirs) {
599  StringRef Prefix =
600  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
601  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
602  }
603  return;
604  }
605 
606  // On systems using multiarch and Android, add /usr/include/$triple before
607  // /usr/include.
608  std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), SysRoot);
609  if (!MultiarchIncludeDir.empty() &&
610  D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir))
611  addExternCSystemInclude(DriverArgs, CC1Args,
612  SysRoot + "/usr/include/" + MultiarchIncludeDir);
613 
614  if (getTriple().getOS() == llvm::Triple::RTEMS)
615  return;
616 
617  // Add an include of '/include' directly. This isn't provided by default by
618  // system GCCs, but is often used with cross-compiling GCCs, and harmless to
619  // add even when Clang is acting as-if it were a system compiler.
620  addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
621 
622  addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
623 
624  if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl())
625  addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
626 }
627 
628 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
629  llvm::opt::ArgStringList &CC1Args) const {
630  // We need a detected GCC installation on Linux to provide libstdc++'s
631  // headers in odd Linuxish places.
632  if (!GCCInstallation.isValid())
633  return;
634 
635  // Detect Debian g++-multiarch-incdir.diff.
636  StringRef TripleStr = GCCInstallation.getTriple().str();
637  StringRef DebianMultiarch =
638  GCCInstallation.getTriple().getArch() == llvm::Triple::x86
639  ? "i386-linux-gnu"
640  : TripleStr;
641 
642  // Try generic GCC detection first.
643  if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args,
644  DebianMultiarch))
645  return;
646 
647  StringRef LibDir = GCCInstallation.getParentLibPath();
649  const GCCVersion &Version = GCCInstallation.getVersion();
650 
651  const std::string LibStdCXXIncludePathCandidates[] = {
652  // Android standalone toolchain has C++ headers in yet another place.
653  LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
654  // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
655  // without a subdirectory corresponding to the gcc version.
656  LibDir.str() + "/../include/c++",
657  // Cray's gcc installation puts headers under "g++" without a
658  // version suffix.
659  LibDir.str() + "/../include/g++",
660  };
661 
662  for (const auto &IncludePath : LibStdCXXIncludePathCandidates) {
663  if (addLibStdCXXIncludePaths(IncludePath, TripleStr,
664  Multilib.includeSuffix(), DriverArgs, CC1Args))
665  break;
666  }
667 }
668 
669 void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
670  ArgStringList &CC1Args) const {
671  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
672 }
673 
674 void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs,
675  ArgStringList &CC1Args) const {
676  RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
677 }
678 
679 void Linux::AddHIPRuntimeLibArgs(const ArgList &Args,
680  ArgStringList &CmdArgs) const {
681  CmdArgs.append(
682  {Args.MakeArgString(StringRef("-L") + RocmInstallation.getLibPath()),
683  "-rpath", Args.MakeArgString(RocmInstallation.getLibPath())});
684 
685  CmdArgs.push_back("-lamdhip64");
686 }
687 
688 void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
689  ArgStringList &CC1Args) const {
690  if (GCCInstallation.isValid()) {
691  CC1Args.push_back("-isystem");
692  CC1Args.push_back(DriverArgs.MakeArgString(
693  GCCInstallation.getParentLibPath() + "/../" +
694  GCCInstallation.getTriple().str() + "/include"));
695  }
696 }
697 
698 bool Linux::isPIEDefault(const llvm::opt::ArgList &Args) const {
699  return CLANG_DEFAULT_PIE_ON_LINUX || getTriple().isAndroid() ||
700  getTriple().isMusl() || getSanitizerArgs(Args).requiresPIE();
701 }
702 
703 bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
704  // Outline atomics for AArch64 are supported by compiler-rt
705  // and libgcc since 9.3.1
706  assert(getTriple().isAArch64() && "expected AArch64 target!");
708  if (RtLib == ToolChain::RLT_CompilerRT)
709  return true;
710  assert(RtLib == ToolChain::RLT_Libgcc && "unexpected runtime library type!");
711  if (GCCInstallation.getVersion().isOlderThan(9, 3, 1))
712  return false;
713  return true;
714 }
715 
717  if (getTriple().isAndroid() || getTriple().isMusl())
718  return false;
720 }
721 
723  const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
724  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
725  const bool IsMIPS = getTriple().isMIPS32();
726  const bool IsMIPS64 = getTriple().isMIPS64();
727  const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 ||
728  getTriple().getArch() == llvm::Triple::ppc64le;
729  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
730  getTriple().getArch() == llvm::Triple::aarch64_be;
731  const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
732  getTriple().getArch() == llvm::Triple::thumb ||
733  getTriple().getArch() == llvm::Triple::armeb ||
734  getTriple().getArch() == llvm::Triple::thumbeb;
735  const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
736  const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
737  const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
739  Res |= SanitizerKind::Address;
740  Res |= SanitizerKind::PointerCompare;
741  Res |= SanitizerKind::PointerSubtract;
742  Res |= SanitizerKind::Fuzzer;
743  Res |= SanitizerKind::FuzzerNoLink;
744  Res |= SanitizerKind::KernelAddress;
745  Res |= SanitizerKind::Memory;
746  Res |= SanitizerKind::Vptr;
747  Res |= SanitizerKind::SafeStack;
748  if (IsX86_64 || IsMIPS64 || IsAArch64)
749  Res |= SanitizerKind::DataFlow;
750  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
751  IsRISCV64 || IsSystemZ || IsHexagon)
752  Res |= SanitizerKind::Leak;
753  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ)
754  Res |= SanitizerKind::Thread;
755  if (IsX86_64)
756  Res |= SanitizerKind::KernelMemory;
757  if (IsX86 || IsX86_64)
758  Res |= SanitizerKind::Function;
759  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
760  IsPowerPC64 || IsHexagon)
761  Res |= SanitizerKind::Scudo;
762  if (IsX86_64 || IsAArch64) {
763  Res |= SanitizerKind::HWAddress;
764  Res |= SanitizerKind::KernelHWAddress;
765  }
766  return Res;
767 }
768 
769 void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
770  llvm::opt::ArgStringList &CmdArgs) const {
771  // Add linker option -u__llvm_profile_runtime to cause runtime
772  // initialization module to be linked in.
773  if (needsProfileRT(Args))
774  CmdArgs.push_back(Args.MakeArgString(
775  Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
776  ToolChain::addProfileRTLibs(Args, CmdArgs);
777 }
778 
779 llvm::DenormalMode
780 Linux::getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs,
781  const JobAction &JA,
782  const llvm::fltSemantics *FPType) const {
783  switch (getTriple().getArch()) {
784  case llvm::Triple::x86:
785  case llvm::Triple::x86_64: {
787  // DAZ and FTZ are turned on in crtfastmath.o
788  if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
789  isFastMathRuntimeAvailable(DriverArgs, Unused))
790  return llvm::DenormalMode::getPreserveSign();
791  return llvm::DenormalMode::getIEEE();
792  }
793  default:
794  return llvm::DenormalMode::getIEEE();
795  }
796 }
797 
798 void Linux::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
799  for (const auto &Opt : ExtraOpts)
800  CmdArgs.push_back(Opt.c_str());
801 }
clang::driver::toolchains
Definition: AIX.h:55
Mips.h
clang::driver::Distro::IsUbuntu
bool IsUbuntu() const
Definition: Distro.h:127
clang::driver::tools::gnutools::StaticLibTool
Definition: Gnu.h:66
clang::driver::RocmInstallationDetector::getLibPath
StringRef getLibPath() const
Get the detected Rocm library path.
Definition: ROCm.h:198
clang::driver::ToolChain::GetDefaultDwarfVersion
virtual unsigned GetDefaultDwarfVersion() const
Definition: ToolChain.h:523
clang::driver::ToolChain::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: ToolChain.cpp:99
clang::driver::RocmInstallationDetector::AddHIPIncludeArgs
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition: AMDGPU.cpp:486
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< std::string, 16 >
clang::driver::toolchains::Generic_GCC::GCCInstallation
GCCInstallationDetector GCCInstallation
Definition: Gnu.h:288
clang::driver::tools::arm::getARMFloatABI
FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args)
clang::driver::toolchains::Generic_GCC::AddMultiarchPaths
void AddMultiarchPaths(const Driver &D, const std::string &SysRoot, const std::string &OSLibDir, path_list &Paths)
Definition: Gnu.cpp:2965
clang::driver::ToolChain::needsProfileRT
static bool needsProfileRT(const llvm::opt::ArgList &Args)
needsProfileRT - returns true if instrumentation profile is on.
Definition: ToolChain.cpp:548
clang::driver::Distro::IsDebian
bool IsDebian() const
Definition: Distro.h:123
clang::driver::toolchains::Generic_GCC::CudaInstallation
CudaInstallationDetector CudaInstallation
Definition: Gnu.h:289
clang::driver::tools::mips::hasMipsAbiArg
bool hasMipsAbiArg(const llvm::opt::ArgList &Args, const char *Value)
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:225
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::isValid
bool isValid() const
Check whether we detected a valid GCC install.
Definition: Gnu.h:224
clang::driver::Distro::IsOpenSUSE
bool IsOpenSUSE() const
Definition: Distro.h:121
clang::driver::toolchains::Generic_GCC::AddMultilibPaths
void AddMultilibPaths(const Driver &D, const std::string &SysRoot, const std::string &OSLibDir, const std::string &MultiarchTriple, path_list &Paths)
Definition: Gnu.cpp:2901
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::init
void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args, ArrayRef< std::string > ExtraTripleAliases=None)
Initialize a GCCInstallationDetector from the driver.
Definition: Gnu.cpp:1993
clang::driver::ToolChain::getSanitizerArgs
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const
Definition: ToolChain.cpp:118
RISCV.h
clang::driver::toolchains::Linux::GetDefaultDwarfVersion
unsigned GetDefaultDwarfVersion() const override
Definition: Linux.cpp:325
clang::driver::toolchains::Generic_GCC::PushPPaths
void PushPPaths(ToolChain::path_list &PPaths)
Definition: Gnu.cpp:2886
clang::driver::toolchains::Linux::IsAArch64OutlineAtomicsDefault
bool IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain supports outline atomics by default.
Definition: Linux.cpp:703
clang::driver::ToolChain::RuntimeLibType
RuntimeLibType
Definition: ToolChain.h:100
clang::driver::toolchains::Generic_GCC::AddMultilibIncludeArgs
void AddMultilibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition: Gnu.cpp:2980
clang::driver::toolchains::Linux::AddHIPIncludeArgs
void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific HIP includes.
Definition: Linux.cpp:674
clang::driver::toolchains::Generic_GCC::GCCVersion
Struct to store and manipulate GCC versions.
Definition: Gnu.h:161
clang::driver::toolchains::Linux::GetDefaultRuntimeLibType
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: Linux.cpp:319
clang::driver::toolchains::Linux::AddClangSystemIncludeArgs
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition: Linux.cpp:567
clang::driver::ToolChain::getFilePaths
path_list & getFilePaths()
Definition: ToolChain.h:263
clang::driver::toolchains::Linux::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: Linux.cpp:722
clang::driver::SanitizerArgs::requiresPIE
bool requiresPIE() const
Definition: SanitizerArgs.cpp:278
clang::driver::toolchains::Linux::buildStaticLibTool
Tool * buildStaticLibTool() const override
Definition: Linux.cpp:341
getOSLibDir
static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args)
Definition: Linux.cpp:137
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::toolchains::Generic_GCC::GCCVersion::isOlderThan
bool isOlderThan(int RHSMajor, int RHSMinor, int RHSPatch, StringRef RHSPatchSuffix=StringRef()) const
Generic_GCC - A tool chain using the 'gcc' command to perform all subcommands; this relies on gcc tra...
Definition: Gnu.cpp:1885
clang::driver::toolchains::Generic_ELF
Definition: Gnu.h:362
Options.h
clang::driver::toolchains::Generic_GCC::GCCVersion::Text
std::string Text
The unparsed text of the version.
Definition: Gnu.h:163
clang::driver::toolchains::Linux::IsMathErrnoDefault
bool IsMathErrnoDefault() const override
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: Linux.cpp:716
clang::driver::Multilib::osSuffix
const std::string & osSuffix() const
Get the detected os path suffix for the multi-arch target variant.
Definition: Multilib.h:56
clang::driver::tools::gnutools::Linker
Definition: Gnu.h:53
clang::driver::toolchains::Linux::GetDefaultCXXStdlibType
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: Linux.cpp:331
clang::driver::toolchains::Linux::buildLinker
Tool * buildLinker() const override
Definition: Linux.cpp:339
clang::driver::Distro::UbuntuMaverick
@ UbuntuMaverick
Definition: Distro.h:53
clang::driver::ToolChain::isFastMathRuntimeAvailable
virtual bool isFastMathRuntimeAvailable(const llvm::opt::ArgList &Args, std::string &Path) const
If a runtime library exists that sets global flags for unsafe floating point math,...
Definition: ToolChain.cpp:1000
clang::driver::ToolChain::getOS
StringRef getOS() const
Definition: ToolChain.h:244
clang::driver::toolchains::Linux::ExtraOpts
std::vector< std::string > ExtraOpts
Definition: Linux.h:60
clang::driver::toolchains::Linux::AddIAMCUIncludeArgs
void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use MCU GCC toolchain includes.
Definition: Linux.cpp:688
llvm::opt
Definition: DiagnosticOptions.h:19
clang::driver::ToolChain::RLT_Libgcc
@ RLT_Libgcc
Definition: ToolChain.h:102
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::getTriple
const llvm::Triple & getTriple() const
Get the GCC triple for the detected install.
Definition: Gnu.h:227
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
clang::driver::tools::arm::FloatABI::Hard
@ Hard
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::getParentLibPath
StringRef getParentLibPath() const
Get the detected GCC parent lib path.
Definition: Gnu.h:233
clang::driver::tools::mips::isNaN2008
bool isNaN2008(const Driver &D, const llvm::opt::ArgList &Args, const llvm::Triple &Triple)
clang::driver::tools::addPathIfExists
void addPathIfExists(const Driver &D, const Twine &Path, ToolChain::path_list &Paths)
Definition: CommonArgs.cpp:122
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::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::Distro::IsRedhat
bool IsRedhat() const
Definition: Distro.h:117
Linux.h
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::toolchains::Linux::buildAssembler
Tool * buildAssembler() const override
Definition: Linux.cpp:345
clang::driver::ToolChain::IsMathErrnoDefault
virtual bool IsMathErrnoDefault() const
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChain.h:399
clang::driver::toolchains::Generic_GCC::addGCCLibStdCxxIncludePaths
bool addGCCLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, StringRef DebianMultiarch) const
Definition: Gnu.cpp:3086
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:241
clang::driver::toolchains::Linux::computeSysRoot
std::string computeSysRoot() const override
Return the sysroot, possibly searching for a default sysroot using target-specific logic.
Definition: Linux.cpp:349
clang::driver::toolchains::Linux::Linux
Linux(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition: Linux.cpp:178
clang::driver::tools::ppc::hasPPCAbiArg
bool hasPPCAbiArg(const llvm::opt::ArgList &Args, const char *Value)
clang::driver::toolchains::Linux::isPIEDefault
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: Linux.cpp:698
clang::driver::toolchains::Generic_GCC::RocmInstallation
RocmInstallationDetector RocmInstallation
Definition: Gnu.h:290
clang::driver::toolchains::Linux::addLibStdCxxIncludePaths
void addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Definition: Linux.cpp:628
clang::driver::Distro::UbuntuLucid
@ UbuntuLucid
Definition: Distro.h:52
clang::driver::ToolChain::getSupportedSanitizers
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1031
clang::driver::Distro::Exherbo
@ Exherbo
Definition: Distro.h:41
clang::driver::toolchains::Linux::getDefaultDenormalModeForType
llvm::DenormalMode getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs, const JobAction &JA, const llvm::fltSemantics *FPType=nullptr) const override
Returns the output denormal handling type in the default floating point environment for the given FPT...
Definition: Linux.cpp:780
clang::driver::ToolChain::GetRuntimeLibType
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:790
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::Distro
Distro - Helper class for detecting and classifying Linux distributions.
Definition: Distro.h:23
clang::driver::toolchains::Linux::AddHIPRuntimeLibArgs
void AddHIPRuntimeLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
Add the system specific linker arguments to use for the given HIP runtime library type.
Definition: Linux.cpp:679
clang::driver::ToolChain::RLT_CompilerRT
@ RLT_CompilerRT
Definition: ToolChain.h:101
clang::driver::toolchains::Linux::AddCudaIncludeArgs
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add arguments to use system-specific CUDA includes.
Definition: Linux.cpp:669
clang::driver::tools::gnutools::Assembler
Definition: Gnu.h:41
clang::driver::CudaInstallationDetector::AddCudaIncludeArgs
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Definition: Cuda.cpp:284
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::getInstallPath
StringRef getInstallPath() const
Get the detected GCC installation path.
Definition: Gnu.h:230
clang::driver::toolchains::Linux::HasNativeLLVMSupport
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: Linux.cpp:337
Unused
@ Unused
Definition: ObjCUnusedIVarsChecker.cpp:29
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::getVersion
const GCCVersion & getVersion() const
Get the detected GCC version string.
Definition: Gnu.h:246
clang::driver::toolchains::Generic_GCC::addLibStdCXXIncludePaths
bool addLibStdCXXIncludePaths(Twine IncludeDir, StringRef Triple, Twine IncludeSuffix, const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, bool DetectDebian=false) const
Definition: Gnu.cpp:3052
clang::driver::tools::mips::getMipsABILibSuffix
std::string getMipsABILibSuffix(const llvm::opt::ArgList &Args, const llvm::Triple &Triple)
clang::driver::tools::mips::getMipsCPUAndABI
void getMipsCPUAndABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple, StringRef &CPUName, StringRef &ABIName)
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::Distro::IsAlpineLinux
bool IsAlpineLinux() const
Definition: Distro.h:131
clang::driver::toolchains::Linux::getDynamicLinker
std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override
Definition: Linux.cpp:403
clang::driver::tools::mips::isUCLibc
bool isUCLibc(const llvm::opt::ArgList &Args)
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::getMultilib
const Multilib & getMultilib() const
Get the detected Multilib.
Definition: Gnu.h:236
clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::getMultilibs
const MultilibSet & getMultilibs() const
Get the whole MultilibSet.
Definition: Gnu.h:239
clang::driver::ToolChain::Multilibs
MultilibSet Multilibs
Definition: ToolChain.h:185
clang::driver::toolchains::Linux::addExtraOpts
void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override
Definition: Linux.cpp:798
clang::driver::Driver::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:362
clang::driver::tools::riscv::getRISCVABI
StringRef getRISCVABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple)
clang::driver::Multilib::includeSuffix
const std::string & includeSuffix() const
Get the include directory suffix.
Definition: Multilib.h:67
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
Distro.h
ARM.h
clang::driver
Definition: Action.h:31
clang::driver::ToolChain::addSystemInclude
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory to CC1 arguments.
Definition: ToolChain.cpp:878
clang::driver::JobAction
Definition: Action.h:395
clang::driver::toolchains::Linux::getMultiarchTriple
std::string getMultiarchTriple(const Driver &D, const llvm::Triple &TargetTriple, StringRef SysRoot) const override
Get our best guess at the multiarch triple for a target.
Definition: Linux.cpp:40
PPC.h
clang::driver::Distro::UbuntuKarmic
@ UbuntuKarmic
Definition: Distro.h:51
clang::driver::Distro::UbuntuJaunty
@ UbuntuJaunty
Definition: Distro.h:50
clang::driver::ToolChain::GetDefaultRuntimeLibType
virtual RuntimeLibType GetDefaultRuntimeLibType() const
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: ToolChain.h:436
clang::SanitizerMask
Definition: Sanitizers.h:30
clang::driver::Driver::getInstalledDir
const char * getInstalledDir() const
Get the path to where the clang executable was installed.
Definition: Driver.h:384
clang::driver::toolchains::Linux::addProfileRTLibs
void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass a suitable profile runtime ...
Definition: Linux.cpp:769