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