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