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/LoongArch.h"
12#include "Arch/Mips.h"
13#include "Arch/PPC.h"
14#include "Arch/RISCV.h"
15#include "clang/Config/config.h"
16#include "clang/Driver/CommonArgs.h"
17#include "clang/Driver/Distro.h"
18#include "clang/Driver/Driver.h"
19#include "clang/Driver/SanitizerArgs.h"
20#include "clang/Options/Options.h"
21#include "llvm/Option/ArgList.h"
22#include "llvm/ProfileData/InstrProf.h"
23#include "llvm/Support/Path.h"
24#include "llvm/Support/ScopedPrinter.h"
25#include "llvm/Support/VirtualFileSystem.h"
26
27using namespace clang::driver;
28using namespace clang::driver::toolchains;
29using namespace clang;
30using namespace llvm::opt;
31
32using tools::addPathIfExists;
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.
40std::string Linux::getMultiarchTriple(const Driver &D,
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 TargetEnvironment == llvm::Triple::MuslEABIHF ||
65 TargetEnvironment == llvm::Triple::EABIHF)
66 return "arm-linux-gnueabihf";
67 return "arm-linux-gnueabi";
68 case llvm::Triple::armeb:
69 case llvm::Triple::thumbeb:
70 if (TargetEnvironment == llvm::Triple::GNUEABIHF ||
71 TargetEnvironment == llvm::Triple::MuslEABIHF ||
72 TargetEnvironment == llvm::Triple::EABIHF)
73 return "armeb-linux-gnueabihf";
74 return "armeb-linux-gnueabi";
75 case llvm::Triple::x86:
76 if (IsAndroid)
77 return "i686-linux-android";
78 return "i386-linux-gnu";
79 case llvm::Triple::x86_64:
80 if (IsAndroid)
81 return "x86_64-linux-android";
82 if (TargetEnvironment == llvm::Triple::GNUX32)
83 return "x86_64-linux-gnux32";
84 return "x86_64-linux-gnu";
85 case llvm::Triple::aarch64:
86 if (IsAndroid)
87 return "aarch64-linux-android";
88 if (hasEffectiveTriple() &&
89 getEffectiveTriple().getEnvironment() == llvm::Triple::PAuthTest)
90 return "aarch64-linux-pauthtest";
91 return "aarch64-linux-gnu";
92 case llvm::Triple::aarch64_be:
93 return "aarch64_be-linux-gnu";
94
95 case llvm::Triple::loongarch64: {
96 const char *Libc;
97 const char *FPFlavor;
98
99 if (TargetTriple.isGNUEnvironment()) {
100 Libc = "gnu";
101 } else if (TargetTriple.isMusl()) {
102 Libc = "musl";
103 } else {
104 return TargetTriple.str();
105 }
106
107 switch (TargetEnvironment) {
108 default:
109 return TargetTriple.str();
110 case llvm::Triple::GNUSF:
111 case llvm::Triple::MuslSF:
112 FPFlavor = "sf";
113 break;
114 case llvm::Triple::GNUF32:
115 case llvm::Triple::MuslF32:
116 FPFlavor = "f32";
117 break;
118 case llvm::Triple::GNU:
119 case llvm::Triple::GNUF64:
120 case llvm::Triple::Musl:
121 // This was going to be "f64" in an earlier Toolchain Conventions
122 // revision, but starting from Feb 2023 the F64 ABI variants are
123 // unmarked in their canonical forms.
124 FPFlavor = "";
125 break;
126 }
127
128 return (Twine("loongarch64-linux-") + Libc + FPFlavor).str();
129 }
130
131 case llvm::Triple::m68k:
132 return "m68k-linux-gnu";
133
134 case llvm::Triple::mips:
135 return IsMipsR6 ? "mipsisa32r6-linux-gnu" : "mips-linux-gnu";
136 case llvm::Triple::mipsel:
137 return IsMipsR6 ? "mipsisa32r6el-linux-gnu" : "mipsel-linux-gnu";
138 case llvm::Triple::mips64: {
139 std::string MT = std::string(IsMipsR6 ? "mipsisa64r6" : "mips64") +
140 "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
141 if (D.getVFS().exists(Path: concat(Path: SysRoot, A: "/lib", B: MT)))
142 return MT;
143 if (D.getVFS().exists(Path: concat(Path: SysRoot, A: "/lib/mips64-linux-gnu")))
144 return "mips64-linux-gnu";
145 break;
146 }
147 case llvm::Triple::mips64el: {
148 std::string MT = std::string(IsMipsR6 ? "mipsisa64r6el" : "mips64el") +
149 "-linux-" + (IsMipsN32Abi ? "gnuabin32" : "gnuabi64");
150 if (D.getVFS().exists(Path: concat(Path: SysRoot, A: "/lib", B: MT)))
151 return MT;
152 if (D.getVFS().exists(Path: concat(Path: SysRoot, A: "/lib/mips64el-linux-gnu")))
153 return "mips64el-linux-gnu";
154 break;
155 }
156 case llvm::Triple::ppc:
157 if (D.getVFS().exists(Path: concat(Path: SysRoot, A: "/lib/powerpc-linux-gnuspe")))
158 return "powerpc-linux-gnuspe";
159 return "powerpc-linux-gnu";
160 case llvm::Triple::ppcle:
161 return "powerpcle-linux-gnu";
162 case llvm::Triple::ppc64:
163 return "powerpc64-linux-gnu";
164 case llvm::Triple::ppc64le:
165 return "powerpc64le-linux-gnu";
166 case llvm::Triple::riscv64:
167 if (IsAndroid)
168 return "riscv64-linux-android";
169 return "riscv64-linux-gnu";
170 case llvm::Triple::sparc:
171 return "sparc-linux-gnu";
172 case llvm::Triple::sparcv9:
173 return "sparc64-linux-gnu";
174 case llvm::Triple::systemz:
175 return "s390x-linux-gnu";
176 }
177 return TargetTriple.str();
178}
179
180static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
181 if (Triple.isMIPS()) {
182 // lib32 directory has a special meaning on MIPS targets.
183 // It contains N32 ABI binaries. Use this folder if produce
184 // code for N32 ABI only.
185 if (tools::mips::hasMipsAbiArg(Args, Value: "n32"))
186 return "lib32";
187 return Triple.isArch32Bit() ? "lib" : "lib64";
188 }
189
190 // It happens that only x86, PPC and SPARC use the 'lib32' variant of
191 // oslibdir, and using that variant while targeting other architectures causes
192 // problems because the libraries are laid out in shared system roots that
193 // can't cope with a 'lib32' library search path being considered. So we only
194 // enable them when we know we may need it.
195 //
196 // FIXME: This is a bit of a hack. We should really unify this code for
197 // reasoning about oslibdir spellings with the lib dir spellings in the
198 // GCCInstallationDetector, but that is a more significant refactoring.
199 if (Triple.getArch() == llvm::Triple::x86 || Triple.isPPC32() ||
200 Triple.getArch() == llvm::Triple::sparc)
201 return "lib32";
202
203 if (Triple.getArch() == llvm::Triple::x86_64 && Triple.isX32())
204 return "libx32";
205
206 if (Triple.isRISCV32())
207 return "lib32";
208
209 if (Triple.getArch() == llvm::Triple::loongarch32) {
210 switch (Triple.getEnvironment()) {
211 default:
212 return "lib32";
213 case llvm::Triple::GNUSF:
214 case llvm::Triple::MuslSF:
215 return "lib32/sf";
216 case llvm::Triple::GNUF32:
217 case llvm::Triple::MuslF32:
218 return "lib32/f32";
219 }
220 }
221
222 return Triple.isArch32Bit() ? "lib" : "lib64";
223}
224
225Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
226 : Generic_ELF(D, Triple, Args) {
227 GCCInstallation.TripleToDebianMultiarch = [](const llvm::Triple &T) {
228 StringRef TripleStr = T.str();
229 StringRef DebianMultiarch =
230 T.getArch() == llvm::Triple::x86 ? "i386-linux-gnu" : TripleStr;
231 return DebianMultiarch;
232 };
233
234 GCCInstallation.init(TargetTriple: Triple, Args);
235 Multilibs = GCCInstallation.getMultilibs();
236 SelectedMultilibs.assign(IL: {GCCInstallation.getMultilib()});
237
238 loadMultilibsFromYAML(Args, D);
239
240 llvm::Triple::ArchType Arch = Triple.getArch();
241 std::string SysRoot = computeSysRoot();
242 ToolChain::path_list &PPaths = getProgramPaths();
243
244 Generic_GCC::PushPPaths(PPaths);
245
246 Distro Distro(D.getVFS(), Triple);
247
248 if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
249 ExtraOpts.push_back(x: "-z");
250 ExtraOpts.push_back(x: "now");
251 }
252
253 if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
254 Triple.isAndroid()) {
255 ExtraOpts.push_back(x: "-z");
256 ExtraOpts.push_back(x: "relro");
257 }
258
259 // Note, lld from 11 onwards default max-page-size to 65536 for both ARM and
260 // AArch64.
261 if (Triple.isAndroid()) {
262 if (Triple.isARM()) {
263 // Android ARM uses max-page-size=4096 to reduce VMA usage.
264 ExtraOpts.push_back(x: "-z");
265 ExtraOpts.push_back(x: "max-page-size=4096");
266 } else if (Triple.isAArch64() || Triple.getArch() == llvm::Triple::x86_64) {
267 // Android AArch64 uses max-page-size=16384 to support 4k/16k page sizes.
268 // Android emulates a 16k page size for app testing on x86_64 machines.
269 ExtraOpts.push_back(x: "-z");
270 ExtraOpts.push_back(x: "max-page-size=16384");
271 }
272 if (Triple.isAndroidVersionLT(Major: 29)) {
273 // https://github.com/android/ndk/issues/1196
274 // The unwinder used by the crash handler on versions of Android prior to
275 // API 29 did not correctly handle binaries built with rosegment, which is
276 // enabled by default for LLD. Android only supports LLD, so it's not an
277 // issue that this flag is not accepted by other linkers.
278 ExtraOpts.push_back(x: "--no-rosegment");
279 }
280 // SHT_RELR relocations are only supported at API level >= 30.
281 // ANDROID_RELR relocations were supported at API level >= 28.
282 if (!Triple.isAndroidVersionLT(Major: 30)) {
283 ExtraOpts.push_back(x: "--pack-dyn-relocs=android+relr");
284 } else if (!Triple.isAndroidVersionLT(Major: 28)) {
285 ExtraOpts.push_back(x: "--pack-dyn-relocs=android+relr");
286 ExtraOpts.push_back(x: "--use-android-relr-tags");
287 } else {
288 ExtraOpts.push_back(x: "--pack-dyn-relocs=android");
289 }
290 }
291
292 if (GCCInstallation.getParentLibPath().contains(Other: "opt/rh/"))
293 // With devtoolset on RHEL, we want to add a bin directory that is relative
294 // to the detected gcc install, because if we are using devtoolset gcc then
295 // we want to use other tools from devtoolset (e.g. ld) instead of the
296 // standard system tools.
297 PPaths.push_back(Elt: Twine(GCCInstallation.getParentLibPath() +
298 "/../bin").str());
299
300 if (Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)
301 ExtraOpts.push_back(x: "-X");
302
303 const bool IsAndroid = Triple.isAndroid();
304 const bool IsMips = Triple.isMIPS();
305 const bool IsHexagon = Arch == llvm::Triple::hexagon;
306 const bool IsRISCV = Triple.isRISCV();
307 const bool IsCSKY = Triple.isCSKY();
308
309 if (IsCSKY && !SelectedMultilibs.empty())
310 SysRoot = SysRoot + SelectedMultilibs.back().osSuffix();
311
312 if ((IsMips || IsCSKY) && !SysRoot.empty())
313 ExtraOpts.push_back(x: "--sysroot=" + SysRoot);
314
315 // Do not use 'gnu' hash style for Mips targets because .gnu.hash
316 // and the MIPS ABI require .dynsym to be sorted in different ways.
317 // .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
318 // ABI requires a mapping between the GOT and the symbol table.
319 // Hexagon linker/loader does not support .gnu.hash.
320 if (!IsMips && !IsHexagon)
321 ExtraOpts.push_back(x: "--hash-style=gnu");
322
323#ifdef ENABLE_LINKER_BUILD_ID
324 ExtraOpts.push_back("--build-id");
325#endif
326
327 // The selection of paths to try here is designed to match the patterns which
328 // the GCC driver itself uses, as this is part of the GCC-compatible driver.
329 // This was determined by running GCC in a fake filesystem, creating all
330 // possible permutations of these directories, and seeing which ones it added
331 // to the link paths.
332 path_list &Paths = getFilePaths();
333
334 const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
335 const std::string MultiarchTriple = getMultiarchTriple(D, TargetTriple: Triple, SysRoot);
336
337 // mips32: Debian multilib, we use /libo32, while in other case, /lib is
338 // used. We need add both libo32 and /lib.
339 if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
340 Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir: "libo32", MultiarchTriple, Paths);
341 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/libo32"), Paths);
342 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/usr/libo32"), Paths);
343 }
344 Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
345
346 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/lib", B: MultiarchTriple), Paths);
347 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/lib/..", B: OSLibDir), Paths);
348
349 if (IsAndroid) {
350 // Android sysroots contain a library directory for each supported OS
351 // version as well as some unversioned libraries in the usual multiarch
352 // directory.
353 addPathIfExists(
354 D,
355 Path: concat(Path: SysRoot, A: "/usr/lib", B: MultiarchTriple,
356 C: llvm::to_string(Value: Triple.getEnvironmentVersion().getMajor())),
357 Paths);
358 }
359
360 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/usr/lib", B: MultiarchTriple), Paths);
361 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/usr", B: OSLibDir), Paths);
362 if (IsRISCV) {
363 StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
364 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/", B: OSLibDir, C: ABIName), Paths);
365 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/usr", B: OSLibDir, C: ABIName), Paths);
366 }
367
368 Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
369
370 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/lib"), Paths);
371 addPathIfExists(D, Path: concat(Path: SysRoot, A: "/usr/lib"), Paths);
372}
373
374ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
375 if (getTriple().isAndroid())
376 return ToolChain::RLT_CompilerRT;
377 return Generic_ELF::GetDefaultRuntimeLibType();
378}
379
380unsigned Linux::GetDefaultDwarfVersion() const {
381 if (getTriple().isAndroid())
382 return 4;
383 return ToolChain::GetDefaultDwarfVersion();
384}
385
386ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const {
387 if (getTriple().isAndroid())
388 return ToolChain::CST_Libcxx;
389 return ToolChain::CST_Libstdcxx;
390}
391
392bool Linux::HasNativeLLVMSupport() const { return true; }
393
394Tool *Linux::buildLinker() const { return new tools::gnutools::Linker(*this); }
395
396Tool *Linux::buildStaticLibTool() const {
397 return new tools::gnutools::StaticLibTool(*this);
398}
399
400Tool *Linux::buildAssembler() const {
401 return new tools::gnutools::Assembler(*this);
402}
403
404std::string Linux::computeSysRoot() const {
405 if (!getDriver().SysRoot.empty())
406 return getDriver().SysRoot;
407
408 if (getTriple().isAndroid()) {
409 // Android toolchains typically include a sysroot at ../sysroot relative to
410 // the clang binary.
411 const StringRef ClangDir = getDriver().Dir;
412 std::string AndroidSysRootPath = (ClangDir + "/../sysroot").str();
413 if (getVFS().exists(Path: AndroidSysRootPath))
414 return AndroidSysRootPath;
415 }
416
417 if (getTriple().isCSKY()) {
418 // CSKY toolchains use different names for sysroot folder.
419 if (!GCCInstallation.isValid())
420 return std::string();
421 // GCCInstallation.getInstallPath() =
422 // $GCCToolchainPath/lib/gcc/csky-linux-gnuabiv2/6.3.0
423 // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
424 std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" +
425 GCCInstallation.getTriple().str() + "/libc")
426 .str();
427 if (getVFS().exists(Path))
428 return Path;
429 return std::string();
430 }
431
432 if (!GCCInstallation.isValid() || !getTriple().isMIPS())
433 return std::string();
434
435 // Standalone MIPS toolchains use different names for sysroot folder
436 // and put it into different places. Here we try to check some known
437 // variants.
438
439 const StringRef InstallDir = GCCInstallation.getInstallPath();
440 const StringRef TripleStr = GCCInstallation.getTriple().str();
441 const Multilib &Multilib = GCCInstallation.getMultilib();
442
443 std::string Path =
444 (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
445 .str();
446
447 if (getVFS().exists(Path))
448 return Path;
449
450 Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
451
452 if (getVFS().exists(Path))
453 return Path;
454
455 return std::string();
456}
457
458static void setPAuthABIInTriple(const Driver &D, const ArgList &Args,
459 llvm::Triple &Triple) {
460 Arg *ABIArg = Args.getLastArg(Ids: options::OPT_mabi_EQ);
461 bool HasPAuthABI =
462 ABIArg ? (StringRef(ABIArg->getValue()) == "pauthtest") : false;
463
464 switch (Triple.getEnvironment()) {
465 case llvm::Triple::UnknownEnvironment:
466 if (HasPAuthABI)
467 Triple.setEnvironment(llvm::Triple::PAuthTest);
468 break;
469 case llvm::Triple::PAuthTest:
470 break;
471 default:
472 if (HasPAuthABI)
473 D.Diag(DiagID: diag::err_drv_unsupported_opt_for_target)
474 << ABIArg->getAsString(Args) << Triple.getTriple();
475 break;
476 }
477}
478
479std::string Linux::ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
480 BoundArch BA,
481 types::ID InputType) const {
482 std::string TripleString =
483 Generic_ELF::ComputeEffectiveClangTriple(Args, BA, InputType);
484 if (getTriple().isAArch64()) {
485 llvm::Triple Triple(TripleString);
486 setPAuthABIInTriple(D: getDriver(), Args, Triple);
487 return Triple.getTriple();
488 }
489 return TripleString;
490}
491
492// Each combination of options here forms a signing schema, and in most cases
493// each signing schema is its own incompatible ABI. The default values of the
494// options represent the default signing schema.
495static void handlePAuthABI(const Driver &D, const ArgList &DriverArgs,
496 ArgStringList &CC1Args) {
497 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_intrinsics,
498 Ids: options::OPT_fno_ptrauth_intrinsics))
499 CC1Args.push_back(Elt: "-fptrauth-intrinsics");
500
501 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_calls,
502 Ids: options::OPT_fno_ptrauth_calls))
503 CC1Args.push_back(Elt: "-fptrauth-calls");
504
505 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_returns,
506 Ids: options::OPT_fno_ptrauth_returns))
507 CC1Args.push_back(Elt: "-fptrauth-returns");
508
509 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_auth_traps,
510 Ids: options::OPT_fno_ptrauth_auth_traps))
511 CC1Args.push_back(Elt: "-fptrauth-auth-traps");
512
513 if (!DriverArgs.hasArg(
514 Ids: options::OPT_fptrauth_vtable_pointer_address_discrimination,
515 Ids: options::OPT_fno_ptrauth_vtable_pointer_address_discrimination))
516 CC1Args.push_back(Elt: "-fptrauth-vtable-pointer-address-discrimination");
517
518 if (!DriverArgs.hasArg(
519 Ids: options::OPT_fptrauth_vtable_pointer_type_discrimination,
520 Ids: options::OPT_fno_ptrauth_vtable_pointer_type_discrimination))
521 CC1Args.push_back(Elt: "-fptrauth-vtable-pointer-type-discrimination");
522
523 if (!DriverArgs.hasArg(
524 Ids: options::OPT_fptrauth_vtt_vtable_pointer_discrimination,
525 Ids: options::OPT_fno_ptrauth_vtt_vtable_pointer_discrimination))
526 CC1Args.push_back(Elt: "-fptrauth-vtt-vtable-pointer-discrimination");
527
528 if (!DriverArgs.hasArg(
529 Ids: options::OPT_fptrauth_type_info_vtable_pointer_discrimination,
530 Ids: options::OPT_fno_ptrauth_type_info_vtable_pointer_discrimination))
531 CC1Args.push_back(Elt: "-fptrauth-type-info-vtable-pointer-discrimination");
532
533 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_indirect_gotos,
534 Ids: options::OPT_fno_ptrauth_indirect_gotos))
535 CC1Args.push_back(Elt: "-fptrauth-indirect-gotos");
536
537 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_init_fini,
538 Ids: options::OPT_fno_ptrauth_init_fini))
539 CC1Args.push_back(Elt: "-fptrauth-init-fini");
540
541 if (!DriverArgs.hasArg(
542 Ids: options::OPT_fptrauth_init_fini_address_discrimination,
543 Ids: options::OPT_fno_ptrauth_init_fini_address_discrimination))
544 CC1Args.push_back(Elt: "-fptrauth-init-fini-address-discrimination");
545
546 if (!DriverArgs.hasArg(Ids: options::OPT_fptrauth_elf_got,
547 Ids: options::OPT_fno_ptrauth_elf_got))
548 CC1Args.push_back(Elt: "-fptrauth-elf-got");
549
550 if (!DriverArgs.hasArg(Ids: options::OPT_faarch64_jump_table_hardening,
551 Ids: options::OPT_fno_aarch64_jump_table_hardening))
552 CC1Args.push_back(Elt: "-faarch64-jump-table-hardening");
553}
554
555void Linux::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
556 llvm::opt::ArgStringList &CC1Args,
557 BoundArch BA,
558 Action::OffloadKind DeviceOffloadKind) const {
559 llvm::Triple Triple(ComputeEffectiveClangTriple(Args: DriverArgs));
560 if (Triple.isAArch64() && Triple.getEnvironment() == llvm::Triple::PAuthTest)
561 handlePAuthABI(D: getDriver(), DriverArgs, CC1Args);
562 Generic_ELF::addClangTargetOptions(DriverArgs, CC1Args, BA,
563 DeviceOffloadKind);
564}
565
566std::string Linux::getDynamicLinker(const ArgList &Args) const {
567 const llvm::Triple::ArchType Arch = getArch();
568 const llvm::Triple &Triple = getTriple();
569
570 const Distro Distro(getDriver().getVFS(), Triple);
571
572 if (Triple.isAndroid()) {
573 if (getSanitizerArgs(JobArgs: Args).needsHwasanRt() &&
574 !Triple.isAndroidVersionLT(Major: 34) && Triple.isArch64Bit()) {
575 // On Android 14 and newer, there is a special linker_hwasan64 that
576 // allows to run HWASan binaries on non-HWASan system images. This
577 // is also available on HWASan system images, so we can just always
578 // use that instead.
579 return "/system/bin/linker_hwasan64";
580 }
581 return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
582 }
583 if (Triple.isMusl()) {
584 std::string ArchName;
585 bool IsArm = false;
586
587 switch (Arch) {
588 case llvm::Triple::arm:
589 case llvm::Triple::thumb:
590 ArchName = "arm";
591 IsArm = true;
592 break;
593 case llvm::Triple::armeb:
594 case llvm::Triple::thumbeb:
595 ArchName = "armeb";
596 IsArm = true;
597 break;
598 case llvm::Triple::x86:
599 ArchName = "i386";
600 break;
601 case llvm::Triple::x86_64:
602 ArchName = Triple.isX32() ? "x32" : Triple.getArchName().str();
603 break;
604 default:
605 ArchName = Triple.getArchName().str();
606 }
607 if (IsArm &&
608 (Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
609 tools::arm::getARMFloatABI(TC: *this, Args) == tools::arm::FloatABI::Hard))
610 ArchName += "hf";
611 if (Arch == llvm::Triple::ppc &&
612 Triple.getSubArch() == llvm::Triple::PPCSubArch_spe)
613 ArchName = "powerpc-sf";
614 if (Triple.isRISCV()) {
615 StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
616 if (ABIName == "ilp32" || ABIName == "lp64") {
617 ArchName += "-sf";
618 } else if (ABIName == "ilp32f" || ABIName == "lp64f") {
619 ArchName += "-sp";
620 }
621 }
622
623 return "/lib/ld-musl-" + ArchName + ".so.1";
624 }
625
626 std::string LibDir;
627 std::string Loader;
628
629 switch (Arch) {
630 default:
631 llvm_unreachable("unsupported architecture");
632
633 case llvm::Triple::aarch64:
634 LibDir = "lib";
635 Loader = "ld-linux-aarch64.so.1";
636 break;
637 case llvm::Triple::aarch64_be:
638 LibDir = "lib";
639 Loader = "ld-linux-aarch64_be.so.1";
640 break;
641 case llvm::Triple::arm:
642 case llvm::Triple::thumb:
643 case llvm::Triple::armeb:
644 case llvm::Triple::thumbeb: {
645 const bool HF =
646 Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
647 Triple.getEnvironment() == llvm::Triple::GNUEABIHFT64 ||
648 tools::arm::getARMFloatABI(TC: *this, Args) == tools::arm::FloatABI::Hard;
649
650 LibDir = "lib";
651 Loader = HF ? "ld-linux-armhf.so.3" : "ld-linux.so.3";
652 break;
653 }
654 case llvm::Triple::loongarch32: {
655 LibDir = "lib32";
656 Loader =
657 ("ld-linux-loongarch-" +
658 tools::loongarch::getLoongArchABI(D: getDriver(), Args, Triple) + ".so.1")
659 .str();
660 break;
661 }
662 case llvm::Triple::loongarch64: {
663 LibDir = "lib64";
664 Loader =
665 ("ld-linux-loongarch-" +
666 tools::loongarch::getLoongArchABI(D: getDriver(), Args, Triple) + ".so.1")
667 .str();
668 break;
669 }
670 case llvm::Triple::m68k:
671 LibDir = "lib";
672 Loader = "ld.so.1";
673 break;
674 case llvm::Triple::mips:
675 case llvm::Triple::mipsel:
676 case llvm::Triple::mips64:
677 case llvm::Triple::mips64el: {
678 bool IsNaN2008 = tools::mips::isNaN2008(D: getDriver(), Args, Triple);
679
680 LibDir = "lib" + tools::mips::getMipsABILibSuffix(Args, Triple);
681
682 if (tools::mips::isUCLibc(Args))
683 Loader = IsNaN2008 ? "ld-uClibc-mipsn8.so.0" : "ld-uClibc.so.0";
684 else if (!Triple.hasEnvironment() &&
685 Triple.getVendor() == llvm::Triple::VendorType::MipsTechnologies)
686 Loader =
687 Triple.isLittleEndian() ? "ld-musl-mipsel.so.1" : "ld-musl-mips.so.1";
688 else
689 Loader = IsNaN2008 ? "ld-linux-mipsn8.so.1" : "ld.so.1";
690
691 break;
692 }
693 case llvm::Triple::ppc:
694 LibDir = "lib";
695 Loader = "ld.so.1";
696 break;
697 case llvm::Triple::ppcle:
698 LibDir = "lib";
699 Loader = "ld.so.1";
700 break;
701 case llvm::Triple::ppc64:
702 LibDir = "lib64";
703 Loader =
704 (tools::ppc::hasPPCAbiArg(Args, Value: "elfv2")) ? "ld64.so.2" : "ld64.so.1";
705 break;
706 case llvm::Triple::ppc64le:
707 LibDir = "lib64";
708 Loader =
709 (tools::ppc::hasPPCAbiArg(Args, Value: "elfv1")) ? "ld64.so.1" : "ld64.so.2";
710 break;
711 case llvm::Triple::riscv32:
712 case llvm::Triple::riscv64:
713 case llvm::Triple::riscv32be:
714 case llvm::Triple::riscv64be: {
715 StringRef ArchName = llvm::Triple::getArchTypeName(Kind: Arch);
716 StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
717 LibDir = "lib";
718 Loader = ("ld-linux-" + ArchName + "-" + ABIName + ".so.1").str();
719 break;
720 }
721 case llvm::Triple::sparc:
722 case llvm::Triple::sparcel:
723 LibDir = "lib";
724 Loader = "ld-linux.so.2";
725 break;
726 case llvm::Triple::sparcv9:
727 LibDir = "lib64";
728 Loader = "ld-linux.so.2";
729 break;
730 case llvm::Triple::systemz:
731 LibDir = "lib";
732 Loader = "ld64.so.1";
733 break;
734 case llvm::Triple::x86:
735 LibDir = "lib";
736 Loader = "ld-linux.so.2";
737 break;
738 case llvm::Triple::x86_64: {
739 bool X32 = Triple.isX32();
740
741 LibDir = X32 ? "libx32" : "lib64";
742 Loader = X32 ? "ld-linux-x32.so.2" : "ld-linux-x86-64.so.2";
743 break;
744 }
745 case llvm::Triple::ve:
746 return "/opt/nec/ve/lib/ld-linux-ve.so.1";
747 case llvm::Triple::csky: {
748 LibDir = "lib";
749 Loader = "ld.so.1";
750 break;
751 }
752 }
753
754 if (Distro == Distro::Exherbo &&
755 (Triple.getVendor() == llvm::Triple::UnknownVendor ||
756 Triple.getVendor() == llvm::Triple::PC))
757 return "/usr/" + Triple.str() + "/lib/" + Loader;
758 return "/" + LibDir + "/" + Loader;
759}
760
761void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
762 ArgStringList &CC1Args) const {
763 const Driver &D = getDriver();
764 std::string SysRoot = computeSysRoot();
765
766 if (DriverArgs.hasArg(Ids: options::OPT_nostdinc))
767 return;
768
769 // Add 'include' in the resource directory, which is similar to
770 // GCC_INCLUDE_DIR (private headers) in GCC. Note: the include directory
771 // contains some files conflicting with system /usr/include. musl systems
772 // prefer the /usr/include copies which are more relevant.
773 SmallString<128> ResourceDirInclude(D.ResourceDir);
774 llvm::sys::path::append(path&: ResourceDirInclude, a: "include");
775 if (!DriverArgs.hasArg(Ids: options::OPT_nobuiltininc) &&
776 (!getTriple().isMusl() || DriverArgs.hasArg(Ids: options::OPT_nostdlibinc)))
777 addSystemInclude(DriverArgs, CC1Args, Path: ResourceDirInclude);
778
779 if (DriverArgs.hasArg(Ids: options::OPT_nostdlibinc))
780 return;
781
782 // Add multilib variant include paths in priority order.
783 for (const Multilib &M : getOrderedMultilibs()) {
784 if (M.isDefault())
785 continue;
786 if (std::optional<std::string> StdlibIncDir = getStdlibIncludePath()) {
787 SmallString<128> Dir(*StdlibIncDir);
788 llvm::sys::path::append(path&: Dir, a: M.includeSuffix());
789 if (D.getVFS().exists(Path: Dir))
790 addSystemInclude(DriverArgs, CC1Args, Path: Dir);
791 }
792 }
793
794 // After the resource directory, we prioritize the standard clang include
795 // directory.
796 if (std::optional<std::string> Path = getStdlibIncludePath())
797 addSystemInclude(DriverArgs, CC1Args, Path: *Path);
798
799 // LOCAL_INCLUDE_DIR
800 addSystemInclude(DriverArgs, CC1Args, Path: concat(Path: SysRoot, A: "/usr/local/include"));
801 // TOOL_INCLUDE_DIR
802 AddMultilibIncludeArgs(DriverArgs, CC1Args);
803
804 // Check for configure-time C include directories.
805 StringRef CIncludeDirs(C_INCLUDE_DIRS);
806 if (CIncludeDirs != "") {
807 SmallVector<StringRef, 5> dirs;
808 CIncludeDirs.split(A&: dirs, Separator: ":");
809 for (StringRef dir : dirs) {
810 StringRef Prefix =
811 llvm::sys::path::is_absolute(path: dir) ? "" : StringRef(SysRoot);
812 addExternCSystemInclude(DriverArgs, CC1Args, Path: Prefix + dir);
813 }
814 return;
815 }
816
817 // On systems using multiarch and Android, add /usr/include/$triple before
818 // /usr/include.
819 std::string MultiarchIncludeDir = getMultiarchTriple(D, TargetTriple: getTriple(), SysRoot);
820 if (!MultiarchIncludeDir.empty() &&
821 D.getVFS().exists(Path: concat(Path: SysRoot, A: "/usr/include", B: MultiarchIncludeDir)))
822 addExternCSystemInclude(
823 DriverArgs, CC1Args,
824 Path: concat(Path: SysRoot, A: "/usr/include", B: MultiarchIncludeDir));
825
826 if (getTriple().getOS() == llvm::Triple::RTEMS)
827 return;
828
829 // Add an include of '/include' directly. This isn't provided by default by
830 // system GCCs, but is often used with cross-compiling GCCs, and harmless to
831 // add even when Clang is acting as-if it were a system compiler.
832 addExternCSystemInclude(DriverArgs, CC1Args, Path: concat(Path: SysRoot, A: "/include"));
833
834 addExternCSystemInclude(DriverArgs, CC1Args, Path: concat(Path: SysRoot, A: "/usr/include"));
835
836 if (!DriverArgs.hasArg(Ids: options::OPT_nobuiltininc) && getTriple().isMusl())
837 addSystemInclude(DriverArgs, CC1Args, Path: ResourceDirInclude);
838}
839
840void Linux::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
841 llvm::opt::ArgStringList &CC1Args) const {
842 // We need a detected GCC installation on Linux to provide libstdc++'s
843 // headers in odd Linuxish places.
844 if (!GCCInstallation.isValid())
845 return;
846
847 // Try generic GCC detection first.
848 if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC&: CC1Args))
849 return;
850
851 StringRef LibDir = GCCInstallation.getParentLibPath();
852 const Multilib &Multilib = GCCInstallation.getMultilib();
853 const GCCVersion &Version = GCCInstallation.getVersion();
854
855 StringRef TripleStr = GCCInstallation.getTriple().str();
856 const std::string LibStdCXXIncludePathCandidates[] = {
857 // Android standalone toolchain has C++ headers in yet another place.
858 LibDir.str() + "/../" + TripleStr.str() + "/include/c++/" + Version.Text,
859 // Freescale SDK C++ headers are directly in <sysroot>/usr/include/c++,
860 // without a subdirectory corresponding to the gcc version.
861 LibDir.str() + "/../include/c++",
862 // Cray's gcc installation puts headers under "g++" without a
863 // version suffix.
864 LibDir.str() + "/../include/g++",
865 };
866
867 for (const auto &IncludePath : LibStdCXXIncludePathCandidates) {
868 if (addLibStdCXXIncludePaths(IncludeDir: IncludePath, Triple: TripleStr,
869 IncludeSuffix: Multilib.includeSuffix(), DriverArgs, CC1Args))
870 break;
871 }
872}
873
874void Linux::AddCudaIncludeArgs(const ArgList &DriverArgs,
875 ArgStringList &CC1Args) const {
876 CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
877}
878
879void Linux::AddHIPIncludeArgs(const ArgList &DriverArgs,
880 ArgStringList &CC1Args) const {
881 RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
882}
883
884void Linux::addOffloadRTLibs(unsigned ActiveKinds, const ArgList &Args,
885 ArgStringList &CmdArgs) const {
886 if (!Args.hasFlag(Pos: options::OPT_offloadlib, Neg: options::OPT_no_offloadlib,
887 Default: true) ||
888 Args.hasArg(Ids: options::OPT_nostdlib) ||
889 Args.hasArg(Ids: options::OPT_no_hip_rt) || Args.hasArg(Ids: options::OPT_r) ||
890 Args.hasFlag(Pos: options::OPT_foffload_via_llvm,
891 Neg: options::OPT_fno_offload_via_llvm, Default: false))
892 return;
893
894 llvm::SmallVector<std::pair<StringRef, StringRef>> Libraries;
895 if (ActiveKinds & Action::OFK_HIP)
896 Libraries.emplace_back(Args: RocmInstallation->getLibPath(), Args: "libamdhip64.so");
897 else if ((ActiveKinds & Action::OFK_SYCL) &&
898 !Args.hasArg(Ids: options::OPT_nolibsycl))
899 Libraries.emplace_back(Args: SYCLInstallation->getSYCLRTLibPath(),
900 Args: "libLLVMSYCL.so");
901
902 for (auto [Path, Library] : Libraries) {
903 if (Args.hasFlag(Pos: options::OPT_frtlib_add_rpath,
904 Neg: options::OPT_fno_rtlib_add_rpath, Default: false)) {
905 SmallString<0> p = Path;
906 llvm::sys::path::remove_dots(path&: p, remove_dot_dot: true);
907 CmdArgs.append(IL: {"-rpath", Args.MakeArgString(Str: p)});
908 }
909
910 SmallString<0> p = Path;
911 llvm::sys::path::append(path&: p, a: Library);
912 CmdArgs.push_back(Elt: Args.MakeArgString(Str: p));
913 }
914
915 // FIXME: The ROCm builds implicitly depends on this being present.
916 if (ActiveKinds & Action::OFK_HIP)
917 CmdArgs.push_back(
918 Elt: Args.MakeArgString(Str: StringRef("-L") + RocmInstallation->getLibPath()));
919
920 // For HIP device PGO, link clang_rt.profile_rocm when available. It is a
921 // self-contained superset of clang_rt.profile, emitted first so the base
922 // archive stays inert.
923 if ((ActiveKinds & Action::OFK_HIP) && needsProfileRT(Args) &&
924 getVFS().exists(Path: getCompilerRT(Args, Component: "profile_rocm", Type: FT_Static))) {
925 CmdArgs.push_back(Elt: getCompilerRTArgString(Args, Component: "profile_rocm"));
926 // Force-retain the constructor-only hipModuleLoad* interceptor object; its
927 // constructor self-skips when the program does not use hipModuleLoad.
928 CmdArgs.push_back(Elt: "-u");
929 CmdArgs.push_back(Elt: "__llvm_profile_offload_register_dynamic_module");
930 }
931}
932
933void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
934 ArgStringList &CC1Args) const {
935 if (GCCInstallation.isValid()) {
936 CC1Args.push_back(Elt: "-isystem");
937 CC1Args.push_back(Elt: DriverArgs.MakeArgString(
938 Str: GCCInstallation.getParentLibPath() + "/../" +
939 GCCInstallation.getTriple().str() + "/include"));
940 }
941}
942
943void Linux::addSYCLIncludeArgs(const ArgList &DriverArgs,
944 ArgStringList &CC1Args) const {
945 SYCLInstallation->addSYCLIncludeArgs(DriverArgs, CC1Args);
946}
947
948bool Linux::isPIEDefault(const llvm::opt::ArgList &Args) const {
949 return CLANG_DEFAULT_PIE_ON_LINUX || getTriple().isAndroid() ||
950 getTriple().isMusl() || getSanitizerArgs(JobArgs: Args).requiresPIE();
951}
952
953bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
954 // Outline atomics for AArch64 are supported by compiler-rt
955 // and libgcc since 9.3.1
956 assert(getTriple().isAArch64() && "expected AArch64 target!");
957 ToolChain::RuntimeLibType RtLib = GetRuntimeLibType(Args);
958 if (RtLib == ToolChain::RLT_CompilerRT)
959 return true;
960 assert(RtLib == ToolChain::RLT_Libgcc && "unexpected runtime library type!");
961 if (GCCInstallation.getVersion().isOlderThan(RHSMajor: 9, RHSMinor: 3, RHSPatch: 1))
962 return false;
963 return true;
964}
965
966bool Linux::IsMathErrnoDefault() const {
967 if (getTriple().isAndroid() || getTriple().isMusl())
968 return false;
969 return Generic_ELF::IsMathErrnoDefault();
970}
971
972SanitizerMask
973Linux::getSupportedSanitizers(BoundArch BA,
974 Action::OffloadKind DeviceOffloadKind) const {
975 const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
976 const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
977 const bool IsMIPS = getTriple().isMIPS32();
978 const bool IsMIPS64 = getTriple().isMIPS64();
979 const bool IsPowerPC64 = getTriple().getArch() == llvm::Triple::ppc64 ||
980 getTriple().getArch() == llvm::Triple::ppc64le;
981 const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
982 getTriple().getArch() == llvm::Triple::aarch64_be;
983 const bool IsArmArch = getTriple().getArch() == llvm::Triple::arm ||
984 getTriple().getArch() == llvm::Triple::thumb ||
985 getTriple().getArch() == llvm::Triple::armeb ||
986 getTriple().getArch() == llvm::Triple::thumbeb;
987 const bool IsLoongArch64 = getTriple().getArch() == llvm::Triple::loongarch64;
988 const bool IsRISCV64 = getTriple().isRISCV64();
989 const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
990 const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
991 const bool IsAndroid = getTriple().isAndroid();
992 SanitizerMask Res = ToolChain::getSupportedSanitizers(BA, DeviceOffloadKind);
993 Res |= SanitizerKind::Address;
994 Res |= SanitizerKind::PointerCompare;
995 Res |= SanitizerKind::PointerSubtract;
996 Res |= SanitizerKind::Realtime;
997 Res |= SanitizerKind::Fuzzer;
998 Res |= SanitizerKind::FuzzerNoLink;
999 Res |= SanitizerKind::KernelAddress;
1000 Res |= SanitizerKind::Vptr;
1001 Res |= SanitizerKind::SafeStack;
1002 if (IsX86_64 || IsMIPS64 || IsAArch64 || IsLoongArch64 || IsSystemZ)
1003 Res |= SanitizerKind::DataFlow;
1004 if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsArmArch || IsPowerPC64 ||
1005 IsRISCV64 || IsSystemZ || IsHexagon || IsLoongArch64)
1006 Res |= SanitizerKind::Leak;
1007 if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ ||
1008 IsLoongArch64 || IsRISCV64)
1009 Res |= SanitizerKind::Thread;
1010 if (IsX86_64 || IsAArch64 || IsSystemZ || IsHexagon)
1011 Res |= SanitizerKind::Type;
1012 if (IsX86_64 || IsSystemZ || IsPowerPC64)
1013 Res |= SanitizerKind::KernelMemory;
1014 if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch ||
1015 IsPowerPC64 || IsHexagon || IsLoongArch64 || IsRISCV64 || IsSystemZ)
1016 Res |= SanitizerKind::Scudo;
1017 if (IsX86_64 || IsAArch64 || IsRISCV64) {
1018 Res |= SanitizerKind::HWAddress;
1019 }
1020 if (IsHexagon)
1021 Res |= SanitizerKind::ShadowCallStack;
1022 if (IsX86_64 || IsAArch64) {
1023 Res |= SanitizerKind::KernelHWAddress;
1024 }
1025 if (IsX86_64)
1026 Res |= SanitizerKind::NumericalStability;
1027 if (!IsAndroid)
1028 Res |= SanitizerKind::Memory;
1029
1030 // Work around "Cannot represent a difference across sections".
1031 if (getTriple().getArch() == llvm::Triple::ppc64)
1032 Res &= ~SanitizerKind::Function;
1033 return Res;
1034}
1035
1036void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
1037 llvm::opt::ArgStringList &CmdArgs) const {
1038 // Add linker option -u__llvm_profile_runtime to cause runtime
1039 // initialization module to be linked in.
1040 if (needsProfileRT(Args))
1041 CmdArgs.push_back(Elt: Args.MakeArgString(
1042 Str: Twine("-u", llvm::getInstrProfRuntimeHookVarName())));
1043 ToolChain::addProfileRTLibs(Args, CmdArgs);
1044}
1045
1046void Linux::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
1047 for (const auto &Opt : ExtraOpts)
1048 CmdArgs.push_back(Elt: Opt.c_str());
1049}
1050
1051const char *Linux::getDefaultLinker() const {
1052 if (getTriple().isAndroid())
1053 return "ld.lld";
1054 return Generic_ELF::getDefaultLinker();
1055}
1056