1//===- tools/dsymutil/LinkUtils.h - Dwarf linker utilities ------*- 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_TOOLS_DSYMUTIL_LINKOPTIONS_H
10#define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
11
12#include "llvm/ADT/Twine.h"
13#include "llvm/Remarks/RemarkFormat.h"
14#include "llvm/Support/VirtualFileSystem.h"
15#include "llvm/Support/WithColor.h"
16
17#include "llvm/DWARFLinker/Classic/DWARFLinker.h"
18#include "llvm/DWARFLinker/Classic/DWARFStreamer.h"
19#include <string>
20
21namespace llvm {
22namespace dsymutil {
23
24enum class DsymutilAccelTableKind : uint8_t {
25 None,
26 Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
27 Dwarf, ///< DWARF v5 .debug_names.
28 Default, ///< Dwarf for DWARF5 or later, Apple otherwise.
29 Pub, ///< .debug_pubnames, .debug_pubtypes
30};
31
32enum class DsymutilDWARFLinkerType : uint8_t {
33 Classic, /// Classic implementation of DWARFLinker.
34 Parallel /// Implementation of DWARFLinker heavily using parallel execution.
35};
36
37struct LinkOptions {
38 /// Verbosity
39 bool Verbose = false;
40
41 /// Statistics
42 bool Statistics = false;
43
44 /// Verify the input DWARF.
45 bool VerifyInputDWARF = false;
46
47 /// Skip emitting output
48 bool NoOutput = false;
49
50 /// Do not unique types according to ODR
51 bool NoODR = false;
52
53 /// Update
54 bool Update = false;
55
56 /// Do not check swiftmodule timestamp
57 bool NoTimestamp = false;
58
59 /// Whether we want a static variable to force us to keep its enclosing
60 /// function.
61 bool KeepFunctionForStatic = false;
62
63 /// Type of DWARFLinker to use.
64 DsymutilDWARFLinkerType DWARFLinkerType = DsymutilDWARFLinkerType::Classic;
65
66 /// Use a 64-bit header when emitting universal binaries.
67 bool Fat64 = false;
68
69 /// Number of threads.
70 unsigned Threads = 1;
71
72 // Output file type.
73 dwarf_linker::DWARFLinkerBase::OutputFileType FileType =
74 dwarf_linker::DWARFLinkerBase::OutputFileType::Object;
75
76 /// The accelerator table kind
77 DsymutilAccelTableKind TheAccelTableKind;
78
79 /// -oso-prepend-path
80 std::string PrependPath;
81
82 /// The -object-prefix-map.
83 std::map<std::string, std::string> ObjectPrefixMap;
84
85 /// The Resources directory in the .dSYM bundle.
86 std::optional<std::string> ResourceDir;
87
88 /// Virtual File System.
89 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
90 vfs::getRealFileSystem();
91
92 /// -build-variant-suffix.
93 std::string BuildVariantSuffix;
94
95 /// Paths where to search for the .dSYM files of merged libraries.
96 std::vector<std::string> DSYMSearchPaths;
97
98 /// Fields used for linking and placing remarks into the .dSYM bundle.
99 /// @{
100
101 /// Number of debug maps processed in total.
102 unsigned NumDebugMaps = 0;
103
104 /// -remarks-prepend-path: prepend a path to all the external remark file
105 /// paths found in remark metadata.
106 std::string RemarksPrependPath;
107
108 /// The output format of the remarks.
109 remarks::Format RemarksFormat = remarks::Format::Bitstream;
110
111 /// Whether all remarks should be kept or only remarks with valid debug
112 /// locations.
113 bool RemarksKeepAll = true;
114 /// @}
115
116 LinkOptions() = default;
117};
118
119inline void warn(Twine Warning, Twine Context = {}) {
120 WithColor::warning() << Warning + "\n";
121 if (!Context.isTriviallyEmpty())
122 WithColor::note() << Twine("while processing ") + Context + "\n";
123}
124
125inline bool error(Twine Error, Twine Context = {}) {
126 WithColor::error() << Error + "\n";
127 if (!Context.isTriviallyEmpty())
128 WithColor::note() << Twine("while processing ") + Context + "\n";
129 return false;
130}
131
132} // end namespace dsymutil
133} // end namespace llvm
134
135#endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
136

source code of llvm/tools/dsymutil/LinkUtils.h