clang 17.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
36public:
37 bool useIntegratedAs() const override { return true; }
38 bool isBareMetal() const override { return true; }
39 bool isCrossCompiling() const override { return true; }
40 bool isPICDefault() const override { return false; }
41 bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
42 return false;
43 }
44 bool isPICDefaultForced() const override { return false; }
45 bool SupportsProfiling() const override { return false; }
46
47 StringRef getOSLibName() const override { return "baremetal"; }
48
50 return ToolChain::RLT_CompilerRT;
51 }
53 return ToolChain::CST_Libcxx;
54 }
55
56 const char *getDefaultLinker() const override { return "ld.lld"; }
57
58 void
59 AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
60 llvm::opt::ArgStringList &CC1Args) const override;
61 void
62 addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
63 llvm::opt::ArgStringList &CC1Args,
64 Action::OffloadKind DeviceOffloadKind) const override;
65 void AddClangCXXStdlibIncludeArgs(
66 const llvm::opt::ArgList &DriverArgs,
67 llvm::opt::ArgStringList &CC1Args) const override;
68 void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
69 llvm::opt::ArgStringList &CmdArgs) const override;
70 void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
71 llvm::opt::ArgStringList &CmdArgs) const;
72 std::string computeSysRoot() const override;
73};
74
75} // namespace toolchains
76
77namespace tools {
78namespace baremetal {
79
80class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
81public:
82 Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {}
83 bool isLinkJob() const override { return true; }
84 bool hasIntegratedCPP() const override { return false; }
85 void ConstructJob(Compilation &C, const JobAction &JA,
86 const InputInfo &Output, const InputInfoList &Inputs,
87 const llvm::opt::ArgList &TCArgs,
88 const char *LinkingOutput) const override;
89};
90
91} // namespace baremetal
92} // namespace tools
93
94} // namespace driver
95} // namespace clang
96
97#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:76
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
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:38
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: BareMetal.h:49
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: BareMetal.h:44
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: BareMetal.h:37
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: BareMetal.h:56
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: BareMetal.h:52
StringRef getOSLibName() const override
Definition: BareMetal.h:47
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: BareMetal.h:39
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: BareMetal.h:45
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: BareMetal.h:40
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: BareMetal.h:41
bool hasIntegratedCPP() const override
Definition: BareMetal.h:84
bool isLinkJob() const override
Definition: BareMetal.h:83