• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SymbolMap.h"
13 
14 #include "llvm/ADT/Twine.h"
15 #include "llvm/Remarks/RemarkFormat.h"
16 #include "llvm/Support/VirtualFileSystem.h"
17 #include "llvm/Support/WithColor.h"
18 
19 #include "llvm/DWARFLinker/DWARFLinker.h"
20 #include "llvm/DWARFLinker/DWARFStreamer.h"
21 #include <string>
22 
23 namespace llvm {
24 namespace dsymutil {
25 
26 struct LinkOptions {
27   /// Verbosity
28   bool Verbose = false;
29 
30   /// Statistics
31   bool Statistics = false;
32 
33   /// Skip emitting output
34   bool NoOutput = false;
35 
36   /// Do not unique types according to ODR
37   bool NoODR = false;
38 
39   /// Update
40   bool Update = false;
41 
42   /// Minimize
43   bool Minimize = false;
44 
45   /// Do not check swiftmodule timestamp
46   bool NoTimestamp = false;
47 
48   /// Number of threads.
49   unsigned Threads = 1;
50 
51   // Output file type.
52   OutputFileType FileType = OutputFileType::Object;
53 
54   /// The accelerator table kind
55   AccelTableKind TheAccelTableKind;
56 
57   /// -oso-prepend-path
58   std::string PrependPath;
59 
60   /// The -object-prefix-map.
61   std::map<std::string, std::string> ObjectPrefixMap;
62 
63   /// The Resources directory in the .dSYM bundle.
64   Optional<std::string> ResourceDir;
65 
66   /// Symbol map translator.
67   SymbolMapTranslator Translator;
68 
69   /// Virtual File System.
70   llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
71       vfs::getRealFileSystem();
72 
73   /// Fields used for linking and placing remarks into the .dSYM bundle.
74   /// @{
75 
76   /// Number of debug maps processed in total.
77   unsigned NumDebugMaps = 0;
78 
79   /// -remarks-prepend-path: prepend a path to all the external remark file
80   /// paths found in remark metadata.
81   std::string RemarksPrependPath;
82 
83   /// The output format of the remarks.
84   remarks::Format RemarksFormat = remarks::Format::Bitstream;
85 
86   /// @}
87 
88   LinkOptions() = default;
89 };
90 
91 inline void warn(Twine Warning, Twine Context = {}) {
92   WithColor::warning() << Warning + "\n";
93   if (!Context.isTriviallyEmpty())
94     WithColor::note() << Twine("while processing ") + Context + "\n";
95 }
96 
97 inline bool error(Twine Error, Twine Context = {}) {
98   WithColor::error() << Error + "\n";
99   if (!Context.isTriviallyEmpty())
100     WithColor::note() << Twine("while processing ") + Context + "\n";
101   return false;
102 }
103 
104 } // end namespace dsymutil
105 } // end namespace llvm
106 
107 #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
108