clang 20.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 "clang/Driver/Tool.h"
14
15#include <string>
16
17namespace clang {
18namespace driver {
19
20namespace toolchains {
21
22class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
23public:
24 BareMetal(const Driver &D, const llvm::Triple &Triple,
25 const llvm::opt::ArgList &Args);
26 ~BareMetal() override = default;
27
28 static bool handlesTarget(const llvm::Triple &Triple);
29
30 void findMultilibs(const Driver &D, const llvm::Triple &Triple,
31 const llvm::opt::ArgList &Args);
32
33protected:
34 Tool *buildLinker() const override;
35 Tool *buildStaticLibTool() const override;
36
37public:
38 bool useIntegratedAs() const override { return true; }
39 bool isBareMetal() const override { return true; }
40 bool isCrossCompiling() const override { return true; }
41 bool HasNativeLLVMSupport() const override { return true; }
42 bool isPICDefault() const override { return false; }
43 bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
44 return false;
45 }
46 bool isPICDefaultForced() const override { return false; }
47 bool SupportsProfiling() const override { return false; }
48
49 StringRef getOSLibName() const override { return "baremetal"; }
50
52 return ToolChain::RLT_CompilerRT;
53 }
55 return ToolChain::CST_Libcxx;
56 }
57
58 const char *getDefaultLinker() const override { return "ld.lld"; }
59
60 void
61 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
62 llvm::opt::ArgStringList &CC1Args) const override;
63 void
64 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
65 llvm::opt::ArgStringList &CC1Args,
66 Action::OffloadKind DeviceOffloadKind) const override;
67 void AddClangCXXStdlibIncludeArgs(
68 const llvm::opt::ArgList &DriverArgs,
69 llvm::opt::ArgStringList &CC1Args) const override;
70 std::string computeSysRoot() const override;
71 SanitizerMask getSupportedSanitizers() const override;
72
73private:
74 using OrderedMultilibs =
75 llvm::iterator_range<llvm::SmallVector<Multilib>::const_reverse_iterator>;
76 OrderedMultilibs getOrderedMultilibs() const;
77
78 std::string SysRoot;
79};
80
81} // namespace toolchains
82
83namespace tools {
84namespace baremetal {
85
86class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool {
87public:
89 : Tool("baremetal::StaticLibTool", "llvm-ar", TC) {}
90
91 bool hasIntegratedCPP() const override { return false; }
92 bool isLinkJob() const override { return true; }
93
94 void ConstructJob(Compilation &C, const JobAction &JA,
95 const InputInfo &Output, const InputInfoList &Inputs,
96 const llvm::opt::ArgList &TCArgs,
97 const char *LinkingOutput) const override;
98};
99
100class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
101public:
102 Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {}
103 bool isLinkJob() const override { return true; }
104 bool hasIntegratedCPP() const override { return false; }
105 void ConstructJob(Compilation &C, const JobAction &JA,
106 const InputInfo &Output, const InputInfoList &Inputs,
107 const llvm::opt::ArgList &TCArgs,
108 const char *LinkingOutput) const override;
109};
110
111} // namespace baremetal
112} // namespace tools
113
114} // namespace driver
115} // namespace clang
116
117#endif
const Decl * D
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
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
bool isBareMetal() const override
isBareMetal - Is this a bare metal target.
Definition: BareMetal.h:39
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: BareMetal.h:51
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: BareMetal.h:46
bool HasNativeLLVMSupport() const override
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: BareMetal.h:41
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: BareMetal.h:38
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: BareMetal.h:58
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: BareMetal.h:54
StringRef getOSLibName() const override
Definition: BareMetal.h:49
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: BareMetal.h:40
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: BareMetal.h:47
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: BareMetal.h:42
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: BareMetal.h:43
bool hasIntegratedCPP() const override
Definition: BareMetal.h:104
The JSON file list parser is used to communicate input to InstallAPI.