1 //===- tools/dsymutil/LinkUtils.h - Dwarf linker utilities ------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
10 #define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
12 #include "SymbolMap.h"
14 #include "llvm/ADT/Twine.h"
15 #include "llvm/Remarks/RemarkFormat.h"
16 #include "llvm/Support/VirtualFileSystem.h"
17 #include "llvm/Support/WithColor.h"
19 #include "llvm/DWARFLinker/DWARFLinker.h"
20 #include "llvm/DWARFLinker/DWARFStreamer.h"
26 enum class DsymutilAccelTableKind
: uint8_t {
28 Apple
, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
29 Dwarf
, ///< DWARF v5 .debug_names.
30 Default
, ///< Dwarf for DWARF5 or later, Apple otherwise.
31 Pub
, ///< .debug_pubnames, .debug_pubtypes
34 enum class DsymutilDWARFLinkerType
: uint8_t {
35 Apple
, /// Apple`s implementation of DWARFLinker.
36 LLVM
/// LLVM implementation of DWARFLinker.
44 bool Statistics
= false;
46 /// Verify the input DWARF.
47 bool VerifyInputDWARF
= false;
49 /// Skip emitting output
50 bool NoOutput
= false;
52 /// Do not unique types according to ODR
58 /// Do not check swiftmodule timestamp
59 bool NoTimestamp
= false;
61 /// Whether we want a static variable to force us to keep its enclosing
63 bool KeepFunctionForStatic
= false;
65 /// Type of DWARFLinker to use.
66 DsymutilDWARFLinkerType DWARFLinkerType
= DsymutilDWARFLinkerType::Apple
;
68 /// Use a 64-bit header when emitting universal binaries.
71 /// Number of threads.
75 DWARFLinker::OutputFileType FileType
= DWARFLinker::OutputFileType::Object
;
77 /// The accelerator table kind
78 DsymutilAccelTableKind TheAccelTableKind
;
81 std::string PrependPath
;
83 /// The -object-prefix-map.
84 std::map
<std::string
, std::string
> ObjectPrefixMap
;
86 /// The Resources directory in the .dSYM bundle.
87 std::optional
<std::string
> ResourceDir
;
89 /// Symbol map translator.
90 SymbolMapTranslator Translator
;
92 /// Virtual File System.
93 llvm::IntrusiveRefCntPtr
<llvm::vfs::FileSystem
> VFS
=
94 vfs::getRealFileSystem();
96 /// -build-variant-suffix.
97 std::string BuildVariantSuffix
;
99 /// Paths where to search for the .dSYM files of merged libraries.
100 std::vector
<std::string
> DSYMSearchPaths
;
102 /// Fields used for linking and placing remarks into the .dSYM bundle.
105 /// Number of debug maps processed in total.
106 unsigned NumDebugMaps
= 0;
108 /// -remarks-prepend-path: prepend a path to all the external remark file
109 /// paths found in remark metadata.
110 std::string RemarksPrependPath
;
112 /// The output format of the remarks.
113 remarks::Format RemarksFormat
= remarks::Format::Bitstream
;
115 /// Whether all remarks should be kept or only remarks with valid debug
117 bool RemarksKeepAll
= true;
120 LinkOptions() = default;
123 inline void warn(Twine Warning
, Twine Context
= {}) {
124 WithColor::warning() << Warning
+ "\n";
125 if (!Context
.isTriviallyEmpty())
126 WithColor::note() << Twine("while processing ") + Context
+ "\n";
129 inline bool error(Twine Error
, Twine Context
= {}) {
130 WithColor::error() << Error
+ "\n";
131 if (!Context
.isTriviallyEmpty())
132 WithColor::note() << Twine("while processing ") + Context
+ "\n";
136 } // end namespace dsymutil
137 } // end namespace llvm
139 #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H