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