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 "llvm/ADT/Twine.h"
13 #include "llvm/Remarks/RemarkFormat.h"
14 #include "llvm/Support/VirtualFileSystem.h"
15 #include "llvm/Support/WithColor.h"
17 #include "llvm/DWARFLinker/Classic/DWARFLinker.h"
18 #include "llvm/DWARFLinker/Classic/DWARFStreamer.h"
24 enum class DsymutilAccelTableKind
: uint8_t {
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
32 enum class DsymutilDWARFLinkerType
: uint8_t {
33 Classic
, /// Classic implementation of DWARFLinker.
34 Parallel
/// Implementation of DWARFLinker heavily using parallel execution.
45 bool Statistics
= false;
47 /// Verify the input DWARF.
48 bool VerifyInputDWARF
= false;
50 /// Skip emitting output
51 bool NoOutput
= false;
53 /// Do not unique types according to ODR
59 /// Do not check swiftmodule timestamp
60 bool NoTimestamp
= false;
62 /// Whether we want a static variable to force us to keep its enclosing
64 bool KeepFunctionForStatic
= false;
66 /// Type of DWARFLinker to use.
67 DsymutilDWARFLinkerType DWARFLinkerType
= DsymutilDWARFLinkerType::Classic
;
69 /// Use a 64-bit header when emitting universal binaries.
72 /// Number of threads.
76 dwarf_linker::DWARFLinkerBase::OutputFileType FileType
=
77 dwarf_linker::DWARFLinkerBase::OutputFileType::Object
;
79 /// The accelerator table kind
80 DsymutilAccelTableKind TheAccelTableKind
;
83 std::string PrependPath
;
85 /// The -object-prefix-map.
86 std::map
<std::string
, std::string
> ObjectPrefixMap
;
88 /// The Resources directory in the .dSYM bundle.
89 std::optional
<std::string
> ResourceDir
;
91 /// Virtual File System.
92 llvm::IntrusiveRefCntPtr
<llvm::vfs::FileSystem
> VFS
=
93 vfs::getRealFileSystem();
95 /// -build-variant-suffix.
96 std::string BuildVariantSuffix
;
98 /// Paths where to search for the .dSYM files of merged libraries.
99 std::vector
<std::string
> DSYMSearchPaths
;
101 /// Fields used for linking and placing remarks into the .dSYM bundle.
104 /// Number of debug maps processed in total.
105 unsigned NumDebugMaps
= 0;
107 /// -remarks-prepend-path: prepend a path to all the external remark file
108 /// paths found in remark metadata.
109 std::string RemarksPrependPath
;
111 /// The output format of the remarks.
112 remarks::Format RemarksFormat
= remarks::Format::Bitstream
;
114 /// Whether all remarks should be kept or only remarks with valid debug
116 bool RemarksKeepAll
= true;
119 LinkOptions() = default;
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";
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";
135 } // end namespace dsymutil
136 } // end namespace llvm
138 #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H