Clang Project

clang_source_code/lib/Driver/ToolChains/OpenBSD.h
1//===--- OpenBSD.h - OpenBSD 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_OPENBSD_H
10#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_OPENBSD_H
11
12#include "Gnu.h"
13#include "clang/Driver/Tool.h"
14#include "clang/Driver/ToolChain.h"
15
16namespace clang {
17namespace driver {
18namespace tools {
19
20/// openbsd -- Directly call GNU Binutils assembler and linker
21namespace openbsd {
22class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
23public:
24  Assembler(const ToolChain &TC)
25      : GnuTool("openbsd::Assembler""assembler", TC) {}
26
27  bool hasIntegratedCPP() const override { return false; }
28
29  void ConstructJob(Compilation &C, const JobAction &JA,
30                    const InputInfo &Output, const InputInfoList &Inputs,
31                    const llvm::opt::ArgList &TCArgs,
32                    const char *LinkingOutput) const override;
33};
34
35class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
36public:
37  Linker(const ToolChain &TC) : GnuTool("openbsd::Linker""linker", TC) {}
38
39  bool hasIntegratedCPP() const override { return false; }
40  bool isLinkJob() const override { return true; }
41
42  void ConstructJob(Compilation &C, const JobAction &JA,
43                    const InputInfo &Output, const InputInfoList &Inputs,
44                    const llvm::opt::ArgList &TCArgs,
45                    const char *LinkingOutput) const override;
46};
47// end namespace openbsd
48// end namespace tools
49
50namespace toolchains {
51
52class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
53public:
54  OpenBSD(const Driver &D, const llvm::Triple &Triple,
55          const llvm::opt::ArgList &Args);
56
57  bool IsMathErrnoDefault() const override { return false; }
58  bool IsObjCNonFragileABIDefault() const override { return true; }
59  bool isPIEDefault() const override { return true; }
60
61  RuntimeLibType GetDefaultRuntimeLibType() const override {
62    return ToolChain::RLT_CompilerRT;
63  }
64  CXXStdlibType GetDefaultCXXStdlibType() const override {
65    return ToolChain::CST_Libcxx;
66  }
67
68  void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
69                           llvm::opt::ArgStringList &CmdArgs) const override;
70
71  unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
72    return 2;
73  }
74  unsigned GetDefaultDwarfVersion() const override { return 2; }
75
76  SanitizerMask getSupportedSanitizers() const override;
77
78protected:
79  Tool *buildAssembler() const override;
80  Tool *buildLinker() const override;
81};
82
83// end namespace toolchains
84// end namespace driver
85// end namespace clang
86
87#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_OPENBSD_H
88