xref: /freebsd/contrib/llvm-project/clang/lib/Driver/ToolChains/OHOS.h (revision 02e9120893770924227138ba49df1edb3896112a)
1 //===--- OHOS.h - OHOS 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_OHOS_H
10 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_OHOS_H
11 
12 #include "Linux.h"
13 #include "clang/Driver/Tool.h"
14 #include "clang/Driver/ToolChain.h"
15 
16 namespace clang {
17 namespace driver {
18 namespace toolchains {
19 
20 class LLVM_LIBRARY_VISIBILITY OHOS : public Generic_ELF {
21 public:
22   OHOS(const Driver &D, const llvm::Triple &Triple,
23           const llvm::opt::ArgList &Args);
24 
25   bool HasNativeLLVMSupport() const override { return true; }
26 
27   bool IsMathErrnoDefault() const override { return false; }
28 
29   RuntimeLibType GetDefaultRuntimeLibType() const override {
30     return ToolChain::RLT_CompilerRT;
31   }
32   CXXStdlibType GetDefaultCXXStdlibType() const override {
33     return ToolChain::CST_Libcxx;
34   }
35   // Not add -funwind-tables by default
36   bool isPICDefault() const override { return false; }
37   bool isPIEDefault(const llvm::opt::ArgList &Args) const override { return true; }
38   bool isPICDefaultForced() const override { return false; }
39   UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const override;
40   UnwindLibType GetDefaultUnwindLibType() const override { return UNW_CompilerRT; }
41 
42   RuntimeLibType
43   GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
44   CXXStdlibType
45   GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
46 
47   void
48   AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
49                             llvm::opt::ArgStringList &CC1Args) const override;
50   void
51   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
52                                llvm::opt::ArgStringList &CC1Args) const override;
53   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
54                            llvm::opt::ArgStringList &CmdArgs) const override;
55 
56   std::string computeSysRoot() const override;
57   std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override;
58 
59   std::string
60   getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
61                 FileType Type = ToolChain::FT_Static) const override;
62 
63   const char *getDefaultLinker() const override {
64     return "ld.lld";
65   }
66 
67   Tool *buildLinker() const override {
68     return new tools::gnutools::Linker(*this);
69   }
70   Tool *buildAssembler() const override {
71     return new tools::gnutools::Assembler(*this);
72   }
73 
74   path_list getRuntimePaths() const;
75 
76 protected:
77   std::string getMultiarchTriple(const llvm::Triple &T) const;
78   std::string getMultiarchTriple(const Driver &D,
79                                  const llvm::Triple &TargetTriple,
80                                  StringRef SysRoot) const override;
81   void addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const override;
82   SanitizerMask getSupportedSanitizers() const override;
83   void addProfileRTLibs(const llvm::opt::ArgList &Args,
84                              llvm::opt::ArgStringList &CmdArgs) const override;
85   path_list getArchSpecificLibPaths() const override;
86 
87 private:
88   Multilib SelectedMultilib;
89 };
90 
91 } // end namespace toolchains
92 } // end namespace driver
93 } // end namespace clang
94 
95 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_OHOS_H
96