clang 19.0.0git
BareMetal.cpp
Go to the documentation of this file.
1//===-- BareMetal.cpp - Bare Metal ToolChain --------------------*- 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 "BareMetal.h"
10
11#include "CommonArgs.h"
12#include "Gnu.h"
14
15#include "Arch/ARM.h"
16#include "Arch/RISCV.h"
18#include "clang/Driver/Driver.h"
22#include "llvm/ADT/StringExtras.h"
23#include "llvm/Option/ArgList.h"
24#include "llvm/Support/Path.h"
25#include "llvm/Support/VirtualFileSystem.h"
26#include "llvm/Support/raw_ostream.h"
27
28#include <sstream>
29
30using namespace llvm::opt;
31using namespace clang;
32using namespace clang::driver;
33using namespace clang::driver::tools;
34using namespace clang::driver::toolchains;
35
36static bool findRISCVMultilibs(const Driver &D,
37 const llvm::Triple &TargetTriple,
38 const ArgList &Args, DetectedMultilibs &Result) {
40 StringRef Arch = riscv::getRISCVArch(Args, TargetTriple);
41 StringRef Abi = tools::riscv::getRISCVABI(Args, TargetTriple);
42
43 if (TargetTriple.isRISCV64()) {
44 MultilibBuilder Imac =
45 MultilibBuilder().flag("-march=rv64imac").flag("-mabi=lp64");
46 MultilibBuilder Imafdc = MultilibBuilder("/rv64imafdc/lp64d")
47 .flag("-march=rv64imafdc")
48 .flag("-mabi=lp64d");
49
50 // Multilib reuse
51 bool UseImafdc =
52 (Arch == "rv64imafdc") || (Arch == "rv64gc"); // gc => imafdc
53
54 addMultilibFlag((Arch == "rv64imac"), "-march=rv64imac", Flags);
55 addMultilibFlag(UseImafdc, "-march=rv64imafdc", Flags);
56 addMultilibFlag(Abi == "lp64", "-mabi=lp64", Flags);
57 addMultilibFlag(Abi == "lp64d", "-mabi=lp64d", Flags);
58
59 Result.Multilibs =
61 return Result.Multilibs.select(Flags, Result.SelectedMultilibs);
62 }
63 if (TargetTriple.isRISCV32()) {
64 MultilibBuilder Imac =
65 MultilibBuilder().flag("-march=rv32imac").flag("-mabi=ilp32");
66 MultilibBuilder I = MultilibBuilder("/rv32i/ilp32")
67 .flag("-march=rv32i")
68 .flag("-mabi=ilp32");
69 MultilibBuilder Im = MultilibBuilder("/rv32im/ilp32")
70 .flag("-march=rv32im")
71 .flag("-mabi=ilp32");
72 MultilibBuilder Iac = MultilibBuilder("/rv32iac/ilp32")
73 .flag("-march=rv32iac")
74 .flag("-mabi=ilp32");
75 MultilibBuilder Imafc = MultilibBuilder("/rv32imafc/ilp32f")
76 .flag("-march=rv32imafc")
77 .flag("-mabi=ilp32f");
78
79 // Multilib reuse
80 bool UseI = (Arch == "rv32i") || (Arch == "rv32ic"); // ic => i
81 bool UseIm = (Arch == "rv32im") || (Arch == "rv32imc"); // imc => im
82 bool UseImafc = (Arch == "rv32imafc") || (Arch == "rv32imafdc") ||
83 (Arch == "rv32gc"); // imafdc,gc => imafc
84
85 addMultilibFlag(UseI, "-march=rv32i", Flags);
86 addMultilibFlag(UseIm, "-march=rv32im", Flags);
87 addMultilibFlag((Arch == "rv32iac"), "-march=rv32iac", Flags);
88 addMultilibFlag((Arch == "rv32imac"), "-march=rv32imac", Flags);
89 addMultilibFlag(UseImafc, "-march=rv32imafc", Flags);
90 addMultilibFlag(Abi == "ilp32", "-mabi=ilp32", Flags);
91 addMultilibFlag(Abi == "ilp32f", "-mabi=ilp32f", Flags);
92
93 Result.Multilibs =
94 MultilibSetBuilder().Either(I, Im, Iac, Imac, Imafc).makeMultilibSet();
95 return Result.Multilibs.select(Flags, Result.SelectedMultilibs);
96 }
97 return false;
98}
99
100BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
101 const ArgList &Args)
102 : ToolChain(D, Triple, Args) {
103 getProgramPaths().push_back(getDriver().Dir);
104
105 findMultilibs(D, Triple, Args);
107 if (!SysRoot.empty()) {
108 for (const Multilib &M : getOrderedMultilibs()) {
109 SmallString<128> Dir(SysRoot);
110 llvm::sys::path::append(Dir, M.osSuffix(), "lib");
111 getFilePaths().push_back(std::string(Dir));
112 getLibraryPaths().push_back(std::string(Dir));
113 }
114 }
115}
116
117/// Is the triple {arm,armeb,thumb,thumbeb}-none-none-{eabi,eabihf} ?
118static bool isARMBareMetal(const llvm::Triple &Triple) {
119 if (Triple.getArch() != llvm::Triple::arm &&
120 Triple.getArch() != llvm::Triple::thumb &&
121 Triple.getArch() != llvm::Triple::armeb &&
122 Triple.getArch() != llvm::Triple::thumbeb)
123 return false;
124
125 if (Triple.getVendor() != llvm::Triple::UnknownVendor)
126 return false;
127
128 if (Triple.getOS() != llvm::Triple::UnknownOS)
129 return false;
130
131 if (Triple.getEnvironment() != llvm::Triple::EABI &&
132 Triple.getEnvironment() != llvm::Triple::EABIHF)
133 return false;
134
135 return true;
136}
137
138/// Is the triple {aarch64.aarch64_be}-none-elf?
139static bool isAArch64BareMetal(const llvm::Triple &Triple) {
140 if (Triple.getArch() != llvm::Triple::aarch64 &&
141 Triple.getArch() != llvm::Triple::aarch64_be)
142 return false;
143
144 if (Triple.getVendor() != llvm::Triple::UnknownVendor)
145 return false;
146
147 if (Triple.getOS() != llvm::Triple::UnknownOS)
148 return false;
149
150 return Triple.getEnvironmentName() == "elf";
151}
152
153static bool isRISCVBareMetal(const llvm::Triple &Triple) {
154 if (!Triple.isRISCV())
155 return false;
156
157 if (Triple.getVendor() != llvm::Triple::UnknownVendor)
158 return false;
159
160 if (Triple.getOS() != llvm::Triple::UnknownOS)
161 return false;
162
163 return Triple.getEnvironmentName() == "elf";
164}
165
166/// Is the triple powerpc[64][le]-*-none-eabi?
167static bool isPPCBareMetal(const llvm::Triple &Triple) {
168 return Triple.isPPC() && Triple.getOS() == llvm::Triple::UnknownOS &&
169 Triple.getEnvironment() == llvm::Triple::EABI;
170}
171
172static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D,
173 StringRef MultilibPath, const ArgList &Args,
175 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MB =
176 D.getVFS().getBufferForFile(MultilibPath);
177 if (!MB)
178 return;
179 Multilib::flags_list Flags = TC.getMultilibFlags(Args);
180 llvm::ErrorOr<MultilibSet> ErrorOrMultilibSet =
181 MultilibSet::parseYaml(*MB.get());
182 if (ErrorOrMultilibSet.getError())
183 return;
184 Result.Multilibs = ErrorOrMultilibSet.get();
185 if (Result.Multilibs.select(Flags, Result.SelectedMultilibs))
186 return;
187 D.Diag(clang::diag::warn_drv_missing_multilib) << llvm::join(Flags, " ");
188 std::stringstream ss;
189 for (const Multilib &Multilib : Result.Multilibs)
190 ss << "\n" << llvm::join(Multilib.flags(), " ");
191 D.Diag(clang::diag::note_drv_available_multilibs) << ss.str();
192}
193
194static constexpr llvm::StringLiteral MultilibFilename = "multilib.yaml";
195
196// Get the sysroot, before multilib takes effect.
197static std::string computeBaseSysRoot(const Driver &D,
198 const llvm::Triple &Triple) {
199 if (!D.SysRoot.empty())
200 return D.SysRoot;
201
202 SmallString<128> SysRootDir(D.Dir);
203 llvm::sys::path::append(SysRootDir, "..", "lib", "clang-runtimes");
204
205 SmallString<128> MultilibPath(SysRootDir);
206 llvm::sys::path::append(MultilibPath, MultilibFilename);
207
208 // New behaviour: if multilib.yaml is found then use clang-runtimes as the
209 // sysroot.
210 if (D.getVFS().exists(MultilibPath))
211 return std::string(SysRootDir);
212
213 // Otherwise fall back to the old behaviour of appending the target triple.
214 llvm::sys::path::append(SysRootDir, D.getTargetTriple());
215 return std::string(SysRootDir);
216}
217
218void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple,
219 const ArgList &Args) {
221 if (isRISCVBareMetal(Triple)) {
222 if (findRISCVMultilibs(D, Triple, Args, Result)) {
223 SelectedMultilibs = Result.SelectedMultilibs;
224 Multilibs = Result.Multilibs;
225 }
226 } else {
227 llvm::SmallString<128> MultilibPath(computeBaseSysRoot(D, Triple));
228 llvm::sys::path::append(MultilibPath, MultilibFilename);
229 findMultilibsFromYAML(*this, D, MultilibPath, Args, Result);
230 SelectedMultilibs = Result.SelectedMultilibs;
231 Multilibs = Result.Multilibs;
232 }
233}
234
235bool BareMetal::handlesTarget(const llvm::Triple &Triple) {
236 return isARMBareMetal(Triple) || isAArch64BareMetal(Triple) ||
237 isRISCVBareMetal(Triple) || isPPCBareMetal(Triple);
238}
239
241 return new tools::baremetal::Linker(*this);
242}
243
245 return new tools::baremetal::StaticLibTool(*this);
246}
247
248std::string BareMetal::computeSysRoot() const {
250}
251
252BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const {
253 // Get multilibs in reverse order because they're ordered most-specific last.
254 if (!SelectedMultilibs.empty())
255 return llvm::reverse(SelectedMultilibs);
256
257 // No multilibs selected so return a single default multilib.
259 return llvm::reverse(Default);
260}
261
262void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
263 ArgStringList &CC1Args) const {
264 if (DriverArgs.hasArg(options::OPT_nostdinc))
265 return;
266
267 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
268 SmallString<128> Dir(getDriver().ResourceDir);
269 llvm::sys::path::append(Dir, "include");
270 addSystemInclude(DriverArgs, CC1Args, Dir.str());
271 }
272
273 if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
274 const SmallString<128> SysRoot(computeSysRoot());
275 if (!SysRoot.empty()) {
276 for (const Multilib &M : getOrderedMultilibs()) {
277 SmallString<128> Dir(SysRoot);
278 llvm::sys::path::append(Dir, M.includeSuffix());
279 llvm::sys::path::append(Dir, "include");
280 addSystemInclude(DriverArgs, CC1Args, Dir.str());
281 }
282 }
283 }
284}
285
286void BareMetal::addClangTargetOptions(const ArgList &DriverArgs,
287 ArgStringList &CC1Args,
288 Action::OffloadKind) const {
289 CC1Args.push_back("-nostdsysteminc");
290}
291
292void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
293 ArgStringList &CC1Args) const {
294 if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
295 options::OPT_nostdincxx))
296 return;
297
298 const Driver &D = getDriver();
299 std::string SysRoot(computeSysRoot());
300 if (SysRoot.empty())
301 return;
302
303 for (const Multilib &M : getOrderedMultilibs()) {
304 SmallString<128> Dir(SysRoot);
305 llvm::sys::path::append(Dir, M.gccSuffix());
306 switch (GetCXXStdlibType(DriverArgs)) {
308 // First check sysroot/usr/include/c++/v1 if it exists.
309 SmallString<128> TargetDir(Dir);
310 llvm::sys::path::append(TargetDir, "usr", "include", "c++", "v1");
311 if (D.getVFS().exists(TargetDir)) {
312 addSystemInclude(DriverArgs, CC1Args, TargetDir.str());
313 break;
314 }
315 // Add generic path if nothing else succeeded so far.
316 llvm::sys::path::append(Dir, "include", "c++", "v1");
317 addSystemInclude(DriverArgs, CC1Args, Dir.str());
318 break;
319 }
321 llvm::sys::path::append(Dir, "include", "c++");
322 std::error_code EC;
323 Generic_GCC::GCCVersion Version = {"", -1, -1, -1, "", "", ""};
324 // Walk the subdirs, and find the one with the newest gcc version:
325 for (llvm::vfs::directory_iterator
326 LI = D.getVFS().dir_begin(Dir.str(), EC),
327 LE;
328 !EC && LI != LE; LI = LI.increment(EC)) {
329 StringRef VersionText = llvm::sys::path::filename(LI->path());
330 auto CandidateVersion = Generic_GCC::GCCVersion::Parse(VersionText);
331 if (CandidateVersion.Major == -1)
332 continue;
333 if (CandidateVersion <= Version)
334 continue;
335 Version = CandidateVersion;
336 }
337 if (Version.Major != -1) {
338 llvm::sys::path::append(Dir, Version.Text);
339 addSystemInclude(DriverArgs, CC1Args, Dir.str());
340 }
341 break;
342 }
343 }
344 }
345}
346
347void BareMetal::AddCXXStdlibLibArgs(const ArgList &Args,
348 ArgStringList &CmdArgs) const {
349 switch (GetCXXStdlibType(Args)) {
351 CmdArgs.push_back("-lc++");
352 if (Args.hasArg(options::OPT_fexperimental_library))
353 CmdArgs.push_back("-lc++experimental");
354 CmdArgs.push_back("-lc++abi");
355 break;
357 CmdArgs.push_back("-lstdc++");
358 CmdArgs.push_back("-lsupc++");
359 break;
360 }
361 CmdArgs.push_back("-lunwind");
362}
363
364void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
365 ArgStringList &CmdArgs) const {
367 switch (RLT) {
369 CmdArgs.push_back(getCompilerRTArgString(Args, "builtins"));
370 return;
371 }
373 CmdArgs.push_back("-lgcc");
374 return;
375 }
376 llvm_unreachable("Unhandled RuntimeLibType.");
377}
378
380 const InputInfo &Output,
381 const InputInfoList &Inputs,
382 const ArgList &Args,
383 const char *LinkingOutput) const {
384 const Driver &D = getToolChain().getDriver();
385
386 // Silence warning for "clang -g foo.o -o foo"
387 Args.ClaimAllArgs(options::OPT_g_Group);
388 // and "clang -emit-llvm foo.o -o foo"
389 Args.ClaimAllArgs(options::OPT_emit_llvm);
390 // and for "clang -w foo.o -o foo". Other warning options are already
391 // handled somewhere else.
392 Args.ClaimAllArgs(options::OPT_w);
393 // Silence warnings when linking C code with a C++ '-stdlib' argument.
394 Args.ClaimAllArgs(options::OPT_stdlib_EQ);
395
396 // ar tool command "llvm-ar <options> <output_file> <input_files>".
397 ArgStringList CmdArgs;
398 // Create and insert file members with a deterministic index.
399 CmdArgs.push_back("rcsD");
400 CmdArgs.push_back(Output.getFilename());
401
402 for (const auto &II : Inputs) {
403 if (II.isFilename()) {
404 CmdArgs.push_back(II.getFilename());
405 }
406 }
407
408 // Delete old output archive file if it already exists before generating a new
409 // archive file.
410 const char *OutputFileName = Output.getFilename();
411 if (Output.isFilename() && llvm::sys::fs::exists(OutputFileName)) {
412 if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
413 D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
414 return;
415 }
416 }
417
418 const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath());
419 C.addCommand(std::make_unique<Command>(JA, *this,
421 Exec, CmdArgs, Inputs, Output));
422}
423
425 const InputInfo &Output,
426 const InputInfoList &Inputs,
427 const ArgList &Args,
428 const char *LinkingOutput) const {
429 ArgStringList CmdArgs;
430
431 auto &TC = static_cast<const toolchains::BareMetal &>(getToolChain());
432 const llvm::Triple::ArchType Arch = TC.getArch();
433 const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
434
435 AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
436
437 CmdArgs.push_back("-Bstatic");
438
439 if (TC.getTriple().isRISCV() && Args.hasArg(options::OPT_mno_relax))
440 CmdArgs.push_back("--no-relax");
441
442 if (Triple.isARM() || Triple.isThumb()) {
443 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
444 if (IsBigEndian)
445 arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
446 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
447 } else if (Triple.isAArch64()) {
448 CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
449 }
450
451 Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
452 options::OPT_s, options::OPT_t, options::OPT_r});
453
454 TC.AddFilePathLibArgs(Args, CmdArgs);
455
456 for (const auto &LibPath : TC.getLibraryPaths())
457 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));
458
459 if (TC.ShouldLinkCXXStdlib(Args))
460 TC.AddCXXStdlibLibArgs(Args, CmdArgs);
461
462 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
463 CmdArgs.push_back("-lc");
464 CmdArgs.push_back("-lm");
465
466 TC.AddLinkRuntimeLib(Args, CmdArgs);
467 }
468
469 if (TC.getTriple().isRISCV())
470 CmdArgs.push_back("-X");
471
472 // The R_ARM_TARGET2 relocation must be treated as R_ARM_REL32 on arm*-*-elf
473 // and arm*-*-eabi (the default is R_ARM_GOT_PREL, used on arm*-*-linux and
474 // arm*-*-*bsd).
475 if (isARMBareMetal(TC.getTriple()))
476 CmdArgs.push_back("--target2=rel");
477
478 CmdArgs.push_back("-o");
479 CmdArgs.push_back(Output.getFilename());
480
481 C.addCommand(std::make_unique<Command>(
483 Args.MakeArgString(TC.GetLinkerPath()), CmdArgs, Inputs, Output));
484}
485
486// BareMetal toolchain allows all sanitizers where the compiler generates valid
487// code, ignoring all runtime library support issues on the assumption that
488// baremetal targets typically implement their own runtime support.
490 const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
491 const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64 ||
492 getTriple().getArch() == llvm::Triple::aarch64_be;
493 const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
495 Res |= SanitizerKind::Address;
496 Res |= SanitizerKind::KernelAddress;
497 Res |= SanitizerKind::PointerCompare;
498 Res |= SanitizerKind::PointerSubtract;
499 Res |= SanitizerKind::Fuzzer;
500 Res |= SanitizerKind::FuzzerNoLink;
501 Res |= SanitizerKind::Vptr;
502 Res |= SanitizerKind::SafeStack;
503 Res |= SanitizerKind::Thread;
504 Res |= SanitizerKind::Scudo;
505 if (IsX86_64 || IsAArch64 || IsRISCV64) {
506 Res |= SanitizerKind::HWAddress;
507 Res |= SanitizerKind::KernelHWAddress;
508 }
509 return Res;
510}
static std::string computeBaseSysRoot(const Driver &D, const llvm::Triple &Triple)
Definition: BareMetal.cpp:197
static bool isRISCVBareMetal(const llvm::Triple &Triple)
Definition: BareMetal.cpp:153
static constexpr llvm::StringLiteral MultilibFilename
Definition: BareMetal.cpp:194
static bool isPPCBareMetal(const llvm::Triple &Triple)
Is the triple powerpc[64][le]-*-none-eabi?
Definition: BareMetal.cpp:167
static bool isARMBareMetal(const llvm::Triple &Triple)
Is the triple {arm,armeb,thumb,thumbeb}-none-none-{eabi,eabihf} ?
Definition: BareMetal.cpp:118
static void findMultilibsFromYAML(const ToolChain &TC, const Driver &D, StringRef MultilibPath, const ArgList &Args, DetectedMultilibs &Result)
Definition: BareMetal.cpp:172
static bool findRISCVMultilibs(const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args, DetectedMultilibs &Result)
Definition: BareMetal.cpp:36
static bool isAArch64BareMetal(const llvm::Triple &Triple)
Is the triple {aarch64.aarch64_be}-none-elf?
Definition: BareMetal.cpp:139
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:77
std::string SysRoot
sysroot, if present
Definition: Driver.h:180
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:144
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:403
std::string Dir
The path the driver executable was in, as invoked from the command line.
Definition: Driver.h:155
std::string getTargetTriple() const
Definition: Driver.h:420
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
const char * getFilename() const
Definition: InputInfo.h:83
bool isFilename() const
Definition: InputInfo.h:75
This corresponds to a single GCC multilib, or a segment of one controlled by a command line flag.
MultilibBuilder & flag(StringRef Flag, bool Disallow=false)
Add a flag to the flags list Flag must be a flag accepted by the driver.
This class can be used to create a MultilibSet, and contains helper functions to add combinations of ...
MultilibSetBuilder & Either(const MultilibBuilder &M1, const MultilibBuilder &M2)
Add a set of mutually incompatible Multilib segments.
static llvm::ErrorOr< MultilibSet > parseYaml(llvm::MemoryBufferRef, llvm::SourceMgr::DiagHandlerTy=nullptr, void *DiagHandlerCtxt=nullptr)
Definition: Multilib.cpp:286
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag.
Definition: Multilib.h:32
const flags_list & flags() const
Get the flags that indicate or contraindicate this multilib's use All elements begin with either '-' ...
Definition: Multilib.h:73
std::vector< std::string > flags_list
Definition: Multilib.h:34
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
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:1169
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1081
const char * getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:704
path_list & getFilePaths()
Definition: ToolChain.h:294
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:268
const Driver & getDriver() const
Definition: ToolChain.h:252
Multilib::flags_list getMultilibFlags(const llvm::opt::ArgList &) const
Get flags suitable for multilib selection, based on the provided clang command line arguments.
Definition: ToolChain.cpp:258
path_list & getProgramPaths()
Definition: ToolChain.h:297
const llvm::Triple & getTriple() const
Definition: ToolChain.h:254
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:1143
llvm::SmallVector< Multilib > SelectedMultilibs
Definition: ToolChain.h:201
path_list & getLibraryPaths()
Definition: ToolChain.h:291
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1360
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
std::string computeSysRoot() const override
Return the sysroot, possibly searching for a default sysroot using target-specific logic.
Definition: BareMetal.cpp:248
BareMetal(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition: BareMetal.cpp:100
SanitizerMask getSupportedSanitizers() const override
Return sanitizers which are available in this toolchain.
Definition: BareMetal.cpp:489
void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: BareMetal.cpp:292
static bool handlesTarget(const llvm::Triple &Triple)
Definition: BareMetal.cpp:235
void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const override
Add the clang cc1 arguments for system include paths.
Definition: BareMetal.cpp:262
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const override
Add options that need to be passed to cc1 for this target.
Definition: BareMetal.cpp:286
Tool * buildStaticLibTool() const override
Definition: BareMetal.cpp:244
void findMultilibs(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition: BareMetal.cpp:218
void AddLinkRuntimeLib(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
Definition: BareMetal.cpp:364
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const override
AddCXXStdlibLibArgs - Add the system specific linker arguments to use for the given C++ standard libr...
Definition: BareMetal.cpp:347
Tool * buildLinker() const override
Definition: BareMetal.cpp:240
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
Definition: BareMetal.cpp:424
void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const override
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
Definition: BareMetal.cpp:379
void appendBE8LinkFlag(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const llvm::Triple &Triple)
bool isARMBigEndian(const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
StringRef getRISCVABI(const llvm::opt::ArgList &Args, const llvm::Triple &Triple)
StringRef getRISCVArch(const llvm::opt::ArgList &Args, const llvm::Triple &Triple)
Definition: RISCV.cpp:251
void addMultilibFlag(bool Enabled, const StringRef Flag, Multilib::flags_list &Flags)
Flag must be a flag accepted by the driver.
void AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, const JobAction &JA)
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
static constexpr ResponseFileSupport AtFileCurCP()
Definition: Job.h:92
Struct to store and manipulate GCC versions.
Definition: Gnu.h:162
int Major
The parsed major, minor, and patch numbers.
Definition: Gnu.h:167
std::string Text
The unparsed text of the version.
Definition: Gnu.h:164
static GCCVersion Parse(StringRef VersionText)
Parse a GCCVersion object out of a string of text.
Definition: Gnu.cpp:2120