xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/Fuchsia.h (revision 924226fba12cc9a228c73b956e1b7fa24c60b055)
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   bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
54     return true;
55   }
56   bool isPICDefault() const override { return false; }
57   bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
58     return true;
59   }
60   bool isPICDefaultForced() const override { return false; }
61   llvm::DebuggerKind getDefaultDebuggerTuning() const override {
62     return llvm::DebuggerKind::GDB;
63   }
64 
65   LangOptions::StackProtectorMode
66   GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
67     return LangOptions::SSPStrong;
68   }
69 
70   std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args,
71                                           types::ID InputType) const override;
72 
73   SanitizerMask getSupportedSanitizers() const override;
74   SanitizerMask getDefaultSanitizers() const override;
75 
76   RuntimeLibType
77   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
78   CXXStdlibType
79   GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
80 
81   void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
82                              llvm::opt::ArgStringList &CC1Args,
83                              Action::OffloadKind DeviceOffloadKind) const override;
84   void
85   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
86                             llvm::opt::ArgStringList &CC1Args) const override;
87   void
88   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
89                                llvm::opt::ArgStringList &CC1Args) const override;
90   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
91                            llvm::opt::ArgStringList &CmdArgs) const override;
92 
93   const char *getDefaultLinker() const override {
94     return "ld.lld";
95   }
96 
97 protected:
98   Tool *buildLinker() const override;
99 };
100 
101 } // end namespace toolchains
102 } // end namespace driver
103 } // end namespace clang
104 
105 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_FUCHSIA_H
106