clang  14.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"
13 #include "clang/Driver/ToolChain.h"
14 
15 #include <string>
16 
17 namespace clang {
18 namespace driver {
19 
20 namespace toolchains {
21 
22 class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
23 public:
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 
33 protected:
34  Tool *buildLinker() const override;
35 
36  std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args,
37  StringRef Component,
39  bool AddArch = true) const override;
40 
41 public:
42  bool useIntegratedAs() const override { return true; }
43  bool isCrossCompiling() const override { return true; }
44  bool isPICDefault() const override { return false; }
45  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
46  return false;
47  }
48  bool isPICDefaultForced() const override { return false; }
49  bool SupportsProfiling() const override { return false; }
50 
51  StringRef getOSLibName() const override { return "baremetal"; }
52 
53  std::string getCompilerRTPath() const override;
54 
57  }
59  return ToolChain::CST_Libcxx;
60  }
61 
62  const char *getDefaultLinker() const override { return "ld.lld"; }
63 
64  std::string getRuntimesDir() const;
65  void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
66  llvm::opt::ArgStringList &CC1Args) const override;
67  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
68  llvm::opt::ArgStringList &CC1Args,
69  Action::OffloadKind DeviceOffloadKind) const override;
70  void AddClangCXXStdlibIncludeArgs(
71  const llvm::opt::ArgList &DriverArgs,
72  llvm::opt::ArgStringList &CC1Args) const override;
73  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
74  llvm::opt::ArgStringList &CmdArgs) const override;
75  void AddLinkRuntimeLib(const llvm::opt::ArgList &Args,
76  llvm::opt::ArgStringList &CmdArgs) const;
77  std::string computeSysRoot() const override;
78 };
79 
80 } // namespace toolchains
81 
82 namespace tools {
83 namespace baremetal {
84 
85 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
86 public:
87  Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {}
88  bool isLinkJob() const override { return true; }
89  bool hasIntegratedCPP() const override { return false; }
90  void ConstructJob(Compilation &C, const JobAction &JA,
91  const InputInfo &Output, const InputInfoList &Inputs,
92  const llvm::opt::ArgList &TCArgs,
93  const char *LinkingOutput) const override;
94 };
95 
96 } // namespace baremetal
97 } // namespace tools
98 
99 } // namespace driver
100 } // namespace clang
101 
102 #endif
clang::driver::tools::baremetal::Linker::Linker
Linker(const ToolChain &TC)
Definition: BareMetal.h:87
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::toolchains::BareMetal::isPIEDefault
bool isPIEDefault(const llvm::opt::ArgList &Args) const override
Test whether this toolchain defaults to PIE.
Definition: BareMetal.h:45
clang::driver::toolchains::BareMetal::GetDefaultCXXStdlibType
CXXStdlibType GetDefaultCXXStdlibType() const override
Definition: BareMetal.h:58
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::ToolChain::RuntimeLibType
RuntimeLibType
Definition: ToolChain.h:100
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::driver::tools::baremetal::Linker
Definition: BareMetal.h:85
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
Tool.h
clang::driver::tools::baremetal::Linker::isLinkJob
bool isLinkJob() const override
Definition: BareMetal.h:88
clang::driver::toolchains::BareMetal::GetDefaultRuntimeLibType
RuntimeLibType GetDefaultRuntimeLibType() const override
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: BareMetal.h:55
clang::driver::ToolChain::CST_Libcxx
@ CST_Libcxx
Definition: ToolChain.h:96
ToolChain.h
clang::driver::ToolChain::FT_Static
@ FT_Static
Definition: ToolChain.h:123
clang::driver::toolchains::BareMetal
Definition: BareMetal.h:22
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::ToolChain::RLT_CompilerRT
@ RLT_CompilerRT
Definition: ToolChain.h:101
clang::driver::toolchains::BareMetal::isPICDefaultForced
bool isPICDefaultForced() const override
Tests whether this toolchain forces its default for PIC, PIE or non-PIC.
Definition: BareMetal.h:48
clang::driver::toolchains::BareMetal::isPICDefault
bool isPICDefault() const override
Test whether this toolchain defaults to PIC.
Definition: BareMetal.h:44
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::ToolChain::FileType
FileType
Definition: ToolChain.h:123
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:59
clang::driver::toolchains::BareMetal::getOSLibName
StringRef getOSLibName() const override
Definition: BareMetal.h:51
clang::driver::toolchains::BareMetal::useIntegratedAs
bool useIntegratedAs() const override
Check if the toolchain should use the integrated assembler.
Definition: BareMetal.h:42
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:85
clang::driver::JobAction
Definition: Action.h:380
clang::driver::toolchains::BareMetal::isCrossCompiling
bool isCrossCompiling() const override
Returns true if the toolchain is targeting a non-native architecture.
Definition: BareMetal.h:43
clang::driver::toolchains::BareMetal::SupportsProfiling
bool SupportsProfiling() const override
SupportsProfiling - Does this tool chain support -pg.
Definition: BareMetal.h:49
clang::driver::tools::baremetal::Linker::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: BareMetal.h:89
clang::driver::toolchains::BareMetal::getDefaultLinker
const char * getDefaultLinker() const override
GetDefaultLinker - Get the default linker to use.
Definition: BareMetal.h:62