1 //===--- BareMetal.h - Bare Metal Tool and ToolChain ------------*- C++-*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
12 #include "clang/Driver/Tool.h"
13 #include "clang/Driver/ToolChain.h"
20 namespace toolchains
{
22 class LLVM_LIBRARY_VISIBILITY BareMetal
: public ToolChain
{
24 BareMetal(const Driver
&D
, const llvm::Triple
&Triple
,
25 const llvm::opt::ArgList
&Args
);
26 ~BareMetal() override
= default;
28 static bool handlesTarget(const llvm::Triple
&Triple
);
30 void findMultilibs(const Driver
&D
, const llvm::Triple
&Triple
,
31 const llvm::opt::ArgList
&Args
);
34 Tool
*buildLinker() const override
;
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
{
44 bool isPICDefaultForced() const override
{ return false; }
45 bool SupportsProfiling() const override
{ return false; }
47 StringRef
getOSLibName() const override
{ return "baremetal"; }
49 RuntimeLibType
GetDefaultRuntimeLibType() const override
{
50 return ToolChain::RLT_CompilerRT
;
52 CXXStdlibType
GetDefaultCXXStdlibType() const override
{
53 return ToolChain::CST_Libcxx
;
56 const char *getDefaultLinker() const override
{ return "ld.lld"; }
59 AddClangSystemIncludeArgs(const llvm::opt::ArgList
&DriverArgs
,
60 llvm::opt::ArgStringList
&CC1Args
) const override
;
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
;
75 } // namespace toolchains
80 class LLVM_LIBRARY_VISIBILITY Linker
: public Tool
{
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
;
91 } // namespace baremetal