xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/Fuchsia.h (revision 85868e8a1daeaae7a0e48effb2ea2310ae3b02c6)
1 //===--- Fuchsia.h - Fuchsia ToolChain Implementations ----------*- 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_FUCHSIA_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FUCHSIA_H
11 
12 #include "Gnu.h"
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.h"
15 
16 namespace clang {
17 namespace driver {
18 namespace tools {
19 namespace fuchsia {
20 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
21 public:
22   Linker(const ToolChain &TC) : Tool("fuchsia::Linker", "ld.lld", TC) {}
23 
24   bool hasIntegratedCPP() const override { return false; }
25   bool isLinkJob() const override { return true; }
26 
27   void ConstructJob(Compilation &C, const JobAction &JA,
28                     const InputInfo &Output, const InputInfoList &Inputs,
29                     const llvm::opt::ArgList &TCArgs,
30                     const char *LinkingOutput) const override;
31 };
32 } // end namespace fuchsia
33 } // end namespace tools
34 
35 namespace toolchains {
36 
37 class LLVM_LIBRARY_VISIBILITY Fuchsia : public ToolChain {
38 public:
39   Fuchsia(const Driver &D, const llvm::Triple &Triple,
40           const llvm::opt::ArgList &Args);
41 
42   bool HasNativeLLVMSupport() const override { return true; }
43   bool IsIntegratedAssemblerDefault() const override { return true; }
44   bool IsMathErrnoDefault() const override { return false; }
45   bool useRelaxRelocations() const override { return true; };
46   RuntimeLibType GetDefaultRuntimeLibType() const override {
47     return ToolChain::RLT_CompilerRT;
48   }
49   CXXStdlibType GetDefaultCXXStdlibType() const override {
50     return ToolChain::CST_Libcxx;
51   }
52   bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
53     return true;
54   }
55   bool isPICDefault() const override { return false; }
56   bool isPIEDefault() const override { return true; }
57   bool isPICDefaultForced() const override { return false; }
58   llvm::DebuggerKind getDefaultDebuggerTuning() const override {
59     return llvm::DebuggerKind::GDB;
60   }
61 
62   unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
63     return 2; // SSPStrong
64   }
65 
66   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
67                                           types::ID InputType) const override;
68 
69   SanitizerMask getSupportedSanitizers() const override;
70   SanitizerMask getDefaultSanitizers() const override;
71 
72   RuntimeLibType
73   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
74   CXXStdlibType
75   GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
76 
77   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
78                              llvm::opt::ArgStringList &CC1Args,
79                              Action::OffloadKind DeviceOffloadKind) const override;
80   void
81   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
82                             llvm::opt::ArgStringList &CC1Args) const override;
83   void
84   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
85                                llvm::opt::ArgStringList &CC1Args) const override;
86   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
87                            llvm::opt::ArgStringList &CmdArgs) const override;
88 
89   const char *getDefaultLinker() const override {
90     return "ld.lld";
91   }
92 
93 protected:
94   Tool *buildLinker() const override;
95 };
96 
97 } // end namespace toolchains
98 } // end namespace driver
99 } // end namespace clang
100 
101 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FUCHSIA_H
102