clang  14.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 
225  if (IsMips && !SysRoot.empty())
226  ExtraOpts.push_back("--sysroot=" + SysRoot);
227 
228  // Do not use 'gnu' hash style for Mips targets because .gnu.hash
229  // and the MIPS ABI require .dynsym to be sorted in different ways.
230  // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
231  // ABI requires a mapping between the GOT and the symbol table.
232  // Android loader does not support .gnu.hash until API 23.
233  // Hexagon linker/loader does not support .gnu.hash
234  if (!IsMips && !IsHexagon) {
237  (IsAndroid && !Triple.isAndroidVersionLT(23)))
238  ExtraOpts.push_back("--hash-style=gnu");
239 
240  if (Distro.IsDebian() || Distro.IsOpenSUSE() ||
243  (IsAndroid && Triple.isAndroidVersionLT(23)))
244  ExtraOpts.push_back("--hash-style=both");
245  }
246 
247 #ifdef ENABLE_LINKER_BUILD_ID
248  ExtraOpts.push_back("--build-id");
249 #endif
250 
251  if (IsAndroid || Distro.IsOpenSUSE())
252  ExtraOpts.push_back("--enable-new-dtags");
253 
254  // The selection of paths to try here is designed to match the patterns which
255  // the GCC driver itself uses, as this is part of the GCC-compatible driver.
256  // This was determined by running GCC in a fake filesystem, creating all
257  // possible permutations of these directories, and seeing which ones it added
258  // to the link paths.
259  path_list &Paths = getFilePaths();
260 
261  const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
262  const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
263 
264  Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
265 
266  addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
267  addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
268 
269  if (IsAndroid) {
270  // Android sysroots contain a library directory for each supported OS
271  // version as well as some unversioned libraries in the usual multiarch
272  // directory.
273  unsigned Major;
274  unsigned Minor;
275  unsigned Micro;
276  Triple.getEnvironmentVersion(Major, Minor, Micro);
277  addPathIfExists(D,
278  SysRoot + "/usr/lib/" + MultiarchTriple + "/" +
279  llvm::to_string(Major),
280  Paths);
281  }
282 
283  addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
284  // 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot
285  // find /usr/lib64 as it is referenced as /usr/lib/../lib64. So we handle
286  // this here.
287  if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
288  Triple.isArch64Bit())
289  addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
290  else
291  addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
292  if (IsRISCV) {
293  StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
294  addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths);
295  addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths);
296  }
297 
298  Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
299 
300  // Similar to the logic for GCC above, if we are currently running Clang
301  // inside of the requested system root, add its parent library path to those
302  // searched.
303  // FIXME: It's not clear whether we should use the driver's installed
304  // directory ('Dir' below) or the ResourceDir.
305  if (StringRef(D.Dir).startswith(SysRoot)) {
306  // Even if OSLibDir != "lib", this is needed for Clang in the build
307  // directory (not installed) to find libc++.
308  addPathIfExists(D, D.Dir + "/../lib", Paths);
309  if (OSLibDir != "lib")
310  addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
311  }
312 
313  addPathIfExists(D, SysRoot + "/lib", Paths);
314  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
315 }
316 
318  if (getTriple().isAndroid())
321 }
322 
324  if (getTriple().isAndroid())
325  return ToolChain::CST_Libcxx;
327 }
328 
329 bool Linux::HasNativeLLVMSupport() const { return true; }
330 
331 Tool *Linux::buildLinker() const { return new tools::gnutools::Linker(*this); }
332 
334  return new tools::gnutools::StaticLibTool(*this);
335 }
336 
338  return new tools::gnutools::Assembler(*this);
339 }
340 
342  if (!getDriver().SysRoot.empty())
343  return getDriver().SysRoot;
344 
345  if (getTriple().isAndroid()) {
346  // Android toolchains typically include a sysroot at ../sysroot relative to
347  // the clang binary.
348  const StringRef ClangDir = getDriver().getInstalledDir();
349  std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str();
350  if (getVFS().exists(AndroidSysRootPath))
351  return AndroidSysRootPath;
352  }
353 
354  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
355  return std::string();
356 
357  // Standalone MIPS toolchains use different names for sysroot folder
358  // and put it into different places. Here we try to check some known
359  // variants.
360 
361  const StringRef InstallDir = GCCInstallation.getInstallPath();
362  const StringRef TripleStr = GCCInstallation.getTriple().str();
364 
365  std::string Path =
366  (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
367  .str();
368 
369  if (getVFS().exists(Path))
370  return Path;
371 
372  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
373 
374  if (getVFS().exists(Path))
375  return Path;
376 
377  return std::string();
378 }
379 
380 std::string Linux::getDynamicLinker(const ArgList &Args) const {
381  const llvm::Triple::ArchType Arch = getArch();
382  const llvm::Triple &Triple = getTriple();
383 
384  const Distro Distro(getDriver().getVFS(), Triple);
385 
386  if (Triple.isAndroid())
387  return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
388 
389  if (Triple.isMusl()) {
390  std::string ArchName;
391  bool IsArm = false;
392 
393  switch (Arch) {
394  case llvm::Triple::arm:
395  case llvm::Triple::thumb:
396  ArchName = "arm";
397  IsArm = true;
398  break;
399  case llvm::Triple::armeb:
400  case llvm::Triple::thumbeb:
401  ArchName = "armeb";
402  IsArm = true;
403  break;
404  case llvm::Triple::x86:
405  ArchName = "i386";
406  break;
407  case llvm::Triple::x86_64:
408  ArchName = Triple.isX32() ? "x32" : Triple.getArchName().str();
409  break;
410  default:
411  ArchName = Triple.getArchName().str();
412  }
413  if (IsArm &&
414  (Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
416  ArchName += "hf";
417 
418  return "/lib/ld-musl-" + ArchName + ".so.1";
419  }
420 
421  std::string LibDir;
422  std::string Loader;
423 
424  switch (Arch) {
425  default:
426  llvm_unreachable("unsupported architecture");
427 
428  case llvm::Triple::aarch64:
429  LibDir = "lib";
430  Loader = "ld-linux-aarch64.so.1";
431  break;
432  case llvm::Triple::aarch64_be:
433  LibDir = "lib";
434  Loader = "ld-linux-aarch64_be.so.1";
435  break;
436  case llvm::Triple::arm:
437  case llvm::Triple::thumb:
438  case llvm::Triple::armeb:
439  case llvm::Triple::thumbeb: {
440  const bool HF =
441  Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
443 
444  LibDir = "lib";
445  Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3";
446  break;
447  }
448  case llvm::Triple::m68k:
449  LibDir = "lib";
450  Loader = "ld.so.1";
451  break;
452  case llvm::Triple::mips:
453  case llvm::Triple::mipsel:
454  case llvm::Triple::mips64:
455  case llvm::Triple::mips64el: {
456  bool IsNaN2008 = tools::mips::isNaN2008(getDriver(), Args, Triple);
457 
458  LibDir = "lib" + tools::mips::getMipsABILibSuffix(Args, Triple);
459 
460  if (tools::mips::isUCLibc(Args))
461  Loader = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0";
462  else if (!Triple.hasEnvironment() &&
463  Triple.getVendor() == llvm::Triple::VendorType::MipsTechnologies)
464  Loader =
465  Triple.isLittleEndian() ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1";
466  else
467  Loader = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1";
468 
469  break;
470  }
471  case llvm::Triple::ppc:
472  LibDir = "lib";
473  Loader = "ld.so.1";
474  break;
475  case llvm::Triple::ppcle:
476  LibDir = "lib";
477  Loader = "ld.so.1";
478  break;
479  case llvm::Triple::ppc64:
480  LibDir = "lib64";
481  Loader =
482  (tools::ppc::hasPPCAbiArg(Args, "elfv2")) ? "ld64.so.2" : "ld64.so.1";
483  break;
484  case llvm::Triple::ppc64le:
485  LibDir = "lib64";
486  Loader =
487  (tools::ppc::hasPPCAbiArg(Args, "elfv1")) ? "ld64.so.1" : "ld64.so.2";
488  break;
489  case llvm::Triple::riscv32: {
490  StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
491  LibDir = "lib";
492  Loader = ("ld-linux-riscv32-" + ABIName + ".so.1").str();
493  break;
494  }
495  case llvm::Triple::riscv64: {
496  StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
497  LibDir = "lib";
498  Loader = ("ld-linux-riscv64-" + ABIName + ".so.1").str();
499  break;
500  }
501  case llvm::Triple::sparc:
502  case llvm::Triple::sparcel:
503  LibDir = "lib";
504  Loader = "ld-linux.so.2";
505  break;
506  case llvm::Triple::sparcv9:
507  LibDir = "lib64";
508  Loader = "ld-linux.so.2";
509  break;
510  case llvm::Triple::systemz:
511  LibDir = "lib";
512  Loader = "ld64.so.1";
513  break;
514  case llvm::Triple::x86:
515  LibDir = "lib";
516  Loader = "ld-linux.so.2";
517  break;
518  case llvm::Triple::x86_64: {
519  bool X32 = Triple.isX32();
520 
521  LibDir = X32 ? "libx32" : "lib64";
522  Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
523  break;
524  }
525  case llvm::Triple::ve:
526  return "/opt/nec/ve/lib/ld-linux-ve.so.1";
527  }
528 
529  if (Distro == Distro::Exherbo &&
530  (Triple.getVendor() == llvm::Triple::UnknownVendor ||
531  Triple.getVendor() == llvm::Triple::PC))
532  return "/usr/" + Triple.str() + "/lib/" + Loader;
533  return "/" + LibDir + "/" + Loader;
534 }
535 
536 void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
537  ArgStringList &CC1Args) const {
538  const Driver &D = getDriver();
539  std::string SysRoot = computeSysRoot();
540 
541  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
542  return;
543 
544  // Add 'include' in the resource directory, which is similar to
545  // GCC_INCLUDE_DIR (private headers) in GCC. Note: the include directory
546  // contains some files conflicting with system /usr/include. musl systems
547  // prefer the /usr/include copies which are more relevant.
548  SmallString<128> ResourceDirInclude(D.ResourceDir);
549  llvm::sys::path::append(ResourceDirInclude, "include");
550  if (!DriverArgs.hasArg(options::OPT_nobuiltininc) &&
551  (!getTriple().isMusl() || DriverArgs.hasArg(options::OPT_nostdlibinc)))
552  addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
553 
554  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
555  return;
556 
557  // LOCAL_INCLUDE_DIR
558  addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
559  // TOOL_INCLUDE_DIR
560  AddMultilibIncludeArgs(DriverArgs, CC1Args);
561 
562  // Check for configure-time C include directories.
563  StringRef CIncludeDirs(C_INCLUDE_DIRS);
564  if (CIncludeDirs != "") {
566  CIncludeDirs.split(dirs, ":");
567  for (StringRef dir : dirs) {
568  StringRef Prefix =
569  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
570  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
571  }
572  return;
573  }
574 
575  // On systems using multiarch and Android, add /usr/include/$triple before
576  // /usr/include.
577  std::string MultiarchIncludeDir = getMultiarchTriple(D, getTriple(), SysRoot);
578  if (!MultiarchIncludeDir.empty() &&
579  D.getVFS().exists(SysRoot + "/usr/include/" + MultiarchIncludeDir))
580  addExternCSystemInclude(DriverArgs, CC1Args,
581  SysRoot + "/usr/include/" + MultiarchIncludeDir);
582 
583  if (getTriple().getOS() == llvm::Triple::RTEMS)
584  return;
585 
586  // Add an include of '/include' directly. This isn't provided by default by
587  // system GCCs, but is often used with cross-compiling GCCs, and harmless to
588  // add even when Clang is acting as-if it were a system compiler.
589  addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
590 
591  addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
592 
593  if (!DriverArgs.hasArg(options::OPT_nobuiltininc) && getTriple().isMusl())
594  addSystemInclude(DriverArgs, CC1Args, ResourceDirInclude);
595 }
596 
597 void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
598  llvm::opt::ArgStringList &CC1Args) const {
599  // We need a detected GCC installation on Linux to provide libstdc++'s
600  // headers in odd Linuxish places.
601  if (!GCCInstallation.isValid())
602  return;
603 
604  // Detect Debian g++-multiarch-incdir.diff.
605  StringRef TripleStr = GCCInstallation.getTriple().str();
606  StringRef DebianMultiarch =
607  GCCInstallation.getTriple().getArch() == llvm::Triple::x86
608  ? "i386-linux-gnu"
609  : TripleStr;
610 
611  // Try generic GCC detection first.
612  if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args,
613  DebianMultiarch))
614  return;
615 
616  StringRef LibDir = GCCInstallation.getParentLibPath();
618  const GCCVersion &Version = GCCInstallation.getVersion();
619 
620  const std::string LibStdCXXIncludePathCandidates[] = {
621  // Android standalone toolchain has C++ headers in yet another place.
622  LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
623  // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
624  // without a subdirectory corresponding to the gcc version.
625  LibDir.str() + "/../include/c++",
626  // Cray's gcc installation puts headers under "g++" without a
627  // version suffix.
628  LibDir.str() + "/../include/g++",
629  };
630 
631  for (const auto &IncludePath : LibStdCXXIncludePathCandidates) {
632  if (addLibStdCXXIncludePaths(IncludePath, TripleStr,
633  Multilib.includeSuffix(), DriverArgs, CC1Args))
634  break;
635  }
636 }
637 
638 void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
639  ArgStringList &CC1Args) const {
640  CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
641 }
642 
643 void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs,
644  ArgStringList &CC1Args) const {
645  RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
646 }
647 
648 void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
649  ArgStringList &CC1Args) const {
650  if (GCCInstallation.isValid()) {
651  CC1Args.push_back("-isystem");
652  CC1Args.push_back(DriverArgs.MakeArgString(
653  GCCInstallation.getParentLibPath() + "/../" +
654  GCCInstallation.getTriple().str() + "/include"));
655  }
656 }
657 
658 bool Linux::isPIEDefault() const {
659  return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) ||
660  getTriple().isMusl() || getSanitizerArgs().requiresPIE();
661 }
662 
663 bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
664  // Outline atomics for AArch64 are supported by compiler-rt
665  // and libgcc since 9.3.1
666  assert(getTriple().isAArch64() && "expected AArch64 target!");
668  if (RtLib == ToolChain::RLT_CompilerRT)
669  return true;
670  assert(RtLib == ToolChain::RLT_Libgcc && "unexpected runtime library type!");
671  if (GCCInstallation.getVersion().isOlderThan(9, 3, 1))
672  return false;
673  return true;
674 }
675 
677  return getTriple().isAndroid();
678 }
679 
681  if (getTriple().isAndroid())
682  return false;
684 }
685 
687  const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
688  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
689  const bool IsMIPS = getTriple().isMIPS32();
690  const bool IsMIPS64 = getTriple().isMIPS64();
691  const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 ||
692  getTriple().getArch() == llvm::Triple::ppc64le;
693  const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
694  getTriple().getArch() == llvm::Triple::aarch64_be;
695  const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
696  getTriple().getArch() == llvm::Triple::thumb ||
697  getTriple().getArch() == llvm::Triple::armeb ||
698  getTriple().getArch() == llvm::Triple::thumbeb;
699  const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
700  const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
701  const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
703  Res |= SanitizerKind::Address;
704  Res |= SanitizerKind::PointerCompare;
705  Res |= SanitizerKind::PointerSubtract;
706  Res |= SanitizerKind::Fuzzer;
707  Res |= SanitizerKind::FuzzerNoLink;
708  Res |= SanitizerKind::KernelAddress;
709  Res |= SanitizerKind::Memory;
710  Res |= SanitizerKind::Vptr;
711  Res |= SanitizerKind::SafeStack;
712  if (IsX86_64 || IsMIPS64 || IsAArch64)
713  Res |= SanitizerKind::DataFlow;
714  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
715  IsRISCV64 || IsSystemZ || IsHexagon)
716  Res |= SanitizerKind::Leak;
717  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ)
718  Res |= SanitizerKind::Thread;
719  if (IsX86_64)
720  Res |= SanitizerKind::KernelMemory;
721  if (IsX86 || IsX86_64)
722  Res |= SanitizerKind::Function;
723  if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
724  IsPowerPC64 || IsHexagon)
725  Res |= SanitizerKind::Scudo;
726  if (IsX86_64 || IsAArch64) {
727  Res |= SanitizerKind::HWAddress;
728  Res |= SanitizerKind::KernelHWAddress;
729  }
730  return Res;
731 }
732 
733 void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
734  llvm::opt::ArgStringList &CmdArgs) const {
735  // Add linker option -u__llvm_profile_runtime to cause runtime
736  // initialization module to be linked in.
737  if (needsProfileRT(Args))
738  CmdArgs.push_back(Args.MakeArgString(
739  Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
740  ToolChain::addProfileRTLibs(Args, CmdArgs);
741 }
742 
743 llvm::DenormalMode
744 Linux::getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs,
745  const JobAction &JA,
746  const llvm::fltSemantics *FPType) const {
747  switch (getTriple().getArch()) {
748  case llvm::Triple::x86:
749  case llvm::Triple::x86_64: {
751  // DAZ and FTZ are turned on in crtfastmath.o
752  if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
753  isFastMathRuntimeAvailable(DriverArgs, Unused))
754  return llvm::DenormalMode::getPreserveSign();
755  return llvm::DenormalMode::getIEEE();
756  }
757  default:
758  return llvm::DenormalMode::getIEEE();
759  }
760 }
761 
762 void Linux::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
763  for (const auto &Opt : ExtraOpts)
764  CmdArgs.push_back(Opt.c_str());
765 }
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::ToolChain::getSanitizerArgs
const SanitizerArgs & getSanitizerArgs() const
Definition: ToolChain.cpp:117
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:479
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< 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:2844
clang::driver::ToolChain::needsProfileRT
static bool needsProfileRT(const llvm::opt::ArgList &Args)
needsProfileRT - returns true if instrumentation profile is on.
Definition: ToolChain.cpp:509
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:221
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:2785
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:1891
RISCV.h
clang::driver::toolchains::Generic_GCC::PushPPaths
void PushPPaths(ToolChain::path_list &PPaths)
Definition: Gnu.cpp:2770
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:663
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:2859
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:643
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:317
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:536
clang::driver::ToolChain::getFilePaths
path_list & getFilePaths()
Definition: ToolChain.h:259
clang::driver::toolchains::Linux::getSupportedSanitizers
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: Linux.cpp:686
clang::driver::SanitizerArgs::requiresPIE
bool requiresPIE() const
Definition: SanitizerArgs.cpp:268
clang::driver::toolchains::Linux::buildStaticLibTool
Tool * buildStaticLibTool() const override
Definition: Linux.cpp:333
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:1783
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:680
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::toolchains::Linux::isPIEDefault
bool isPIEDefault() const override
Test whether this toolchain defaults to PIE.
Definition: Linux.cpp:658
clang::driver::tools::gnutools::Linker
Definition: Gnu.h:53
clang::driver::toolchains::Linux::GetDefaultCXXStdlibType
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: Linux.cpp:323
clang::driver::toolchains::Linux::buildLinker
Tool * buildLinker() const override
Definition: Linux.cpp:331
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:967
clang::driver::ToolChain::getOS
StringRef getOS() const
Definition: ToolChain.h:240
clang::driver::toolchains::Linux::ExtraOpts
std::vector< std::string > ExtraOpts
Definition: Linux.h:58
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:648
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: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::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:135
clang::driver::toolchains::Linux::buildAssembler
Tool * buildAssembler() const override
Definition: Linux.cpp:337
clang::driver::toolchains::Linux::isNoExecStackDefault
bool isNoExecStackDefault() const override
Test whether this toolchaind defaults to non-executable stacks.
Definition: Linux.cpp:676
clang::driver::ToolChain::IsMathErrnoDefault
virtual bool IsMathErrnoDefault() const
IsMathErrnoDefault - Does this tool chain use -fmath-errno by default.
Definition: ToolChain.h:395
clang::driver::toolchains::Generic_GCC::addGCCLibStdCxxIncludePaths
bool addGCCLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, StringRef DebianMultiarch) const
Definition: Gnu.cpp:2965
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:237
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:341
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::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:597
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:998
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:744
clang::driver::ToolChain::GetRuntimeLibType
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:757
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::Distro
Distro - Helper class for detecting and classifying Linux distributions.
Definition: Distro.h:23
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:638
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:282
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:329
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:2931
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:59
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:380
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:181
clang::driver::toolchains::Linux::addExtraOpts
void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override
Definition: Linux.cpp:762
clang::driver::Driver::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:329
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:860
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:845
clang::driver::JobAction
Definition: Action.h:380
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:429
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:348
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:733