clang 22.0.0git
BareMetal.h
Go to the documentation of this file.
1//===--- BareMetal.h - Bare Metal Tool and 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#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
11
12#include "ToolChains/Gnu.h"
13#include "clang/Driver/Tool.h"
15
16#include <string>
17
18namespace clang {
19namespace driver {
20
21namespace toolchains {
22
23class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
24public:
25 BareMetal(const Driver &D, const llvm::Triple &Triple,
26 const llvm::opt::ArgList &Args);
27 ~BareMetal() override = default;
28
29 static bool handlesTarget(const llvm::Triple &Triple);
30
31 void findMultilibs(const Driver &D, const llvm::Triple &Triple,
32 const llvm::opt::ArgList &Args);
33
34protected:
35 Tool *buildLinker() const override;
36 Tool *buildStaticLibTool() const override;
37
38public:
39 bool initGCCInstallation(const llvm::Triple &Triple,
40 const llvm::opt::ArgList &Args);
41 bool hasValidGCCInstallation() const { return IsGCCInstallationValid; }
42 bool isBareMetal() const override { return true; }
43 bool isCrossCompiling() const override { return true; }
44 bool HasNativeLLVMSupport() const override { return true; }
45 bool isPICDefault() const override { return false; }
46 bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
47 return false;
48 }
49 bool isPICDefaultForced() const override { return false; }
50 bool SupportsProfiling() const override { return false; }
51
52 StringRef getOSLibName() const override { return "baremetal"; }
53
54 UnwindTableLevel
55 getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
57 }
58
59 CXXStdlibType GetDefaultCXXStdlibType() const override;
60
61 RuntimeLibType GetDefaultRuntimeLibType() const override;
62
63 UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
64
65 void
66 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
67 llvm::opt::ArgStringList &CC1Args) const override;
68 void
69 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
70 llvm::opt::ArgStringList &CC1Args,
71 Action::OffloadKind DeviceOffloadKind) const override;
72 void AddClangCXXStdlibIncludeArgs(
73 const llvm::opt::ArgList &DriverArgs,
74 llvm::opt::ArgStringList &CC1Args) const override;
75 void
76 addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
77 llvm::opt::ArgStringList &CC1Args) const override;
78 std::string computeSysRoot() const override;
79 std::string getCompilerRTPath() const override;
80 SanitizerMask getSupportedSanitizers() const override;
81
83 getMultilibMacroDefinesStr(llvm::opt::ArgList &Args) const override;
84
85private:
86 using OrderedMultilibs =
87 llvm::iterator_range<llvm::SmallVector<Multilib>::const_reverse_iterator>;
88 OrderedMultilibs getOrderedMultilibs() const;
89
90 std::string SysRoot;
91
92 bool IsGCCInstallationValid;
93
94 SmallVector<std::string> MultilibMacroDefines;
95};
96
97} // namespace toolchains
98
99namespace tools {
100namespace baremetal {
101
102class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool {
103public:
105 : Tool("baremetal::StaticLibTool", "llvm-ar", TC) {}
106
107 bool hasIntegratedCPP() const override { return false; }
108 bool isLinkJob() const override { return true; }
109
110 void ConstructJob(Compilation &C, const JobAction &JA,
111 const InputInfo &Output, const InputInfoList &Inputs,
112 const llvm::opt::ArgList &TCArgs,
113 const char *LinkingOutput) const override;
114};
115
116class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
117public:
118 Linker(const ToolChain &TC) : Tool("baremetal::Linker", "linker", TC) {}
119 bool isLinkJob() const override { return true; }
120 bool hasIntegratedCPP() const override { return false; }
121 void ConstructJob(Compilation &C, const JobAction &JA,
122 const InputInfo &Output, const InputInfoList &Inputs,
123 const llvm::opt::ArgList &TCArgs,
124 const char *LinkingOutput) const override;
125};
126
127} // namespace baremetal
128} // namespace tools
129
130} // namespace driver
131} // namespace clang
132
133#endif
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:99
InputInfo - Wrapper for information about an input source.
Definition InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition ToolChain.h:92
Tool - Information on a specific compilation tool.
Definition Tool.h:32
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition Tool.cpp:14
bool isBareMetal() const override
isBareMetal - Is this a bare metal target.
Definition BareMetal.h:42
BareMetal(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
static bool handlesTarget(const llvm::Triple &Triple)
Tool * buildStaticLibTool() const override
UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override
How detailed should the unwind tables be by default.
Definition BareMetal.h:55
void findMultilibs(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition BareMetal.h:49
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition BareMetal.h:44
bool initGCCInstallation(const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Tool * buildLinker() const override
StringRef getOSLibName() const override
Definition BareMetal.h:52
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition BareMetal.h:43
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition BareMetal.h:50
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition BareMetal.h:45
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition BareMetal.h:46
Generic_ELF(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args)
Definition Gnu.h:439
bool hasIntegratedCPP() const override
Definition BareMetal.h:120
SmallVector< InputInfo, 4 > InputInfoList
Definition Driver.h:50
The JSON file list parser is used to communicate input to InstallAPI.