LinkUtils.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #ifndef LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
  9. #define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
  10. #include "SymbolMap.h"
  11. #include "llvm/ADT/Twine.h"
  12. #include "llvm/Remarks/RemarkFormat.h"
  13. #include "llvm/Support/VirtualFileSystem.h"
  14. #include "llvm/Support/WithColor.h"
  15. #include "llvm/DWARFLinker/DWARFLinker.h"
  16. #include "llvm/DWARFLinker/DWARFStreamer.h"
  17. #include <string>
  18. namespace llvm {
  19. namespace dsymutil {
  20. struct LinkOptions {
  21. /// Verbosity
  22. bool Verbose = false;
  23. /// Statistics
  24. bool Statistics = false;
  25. /// Skip emitting output
  26. bool NoOutput = false;
  27. /// Do not unique types according to ODR
  28. bool NoODR = false;
  29. /// Update
  30. bool Update = false;
  31. /// Do not check swiftmodule timestamp
  32. bool NoTimestamp = false;
  33. /// Whether we want a static variable to force us to keep its enclosing
  34. /// function.
  35. bool KeepFunctionForStatic = false;
  36. /// Number of threads.
  37. unsigned Threads = 1;
  38. // Output file type.
  39. OutputFileType FileType = OutputFileType::Object;
  40. /// The accelerator table kind
  41. AccelTableKind TheAccelTableKind;
  42. /// -oso-prepend-path
  43. std::string PrependPath;
  44. /// The -object-prefix-map.
  45. std::map<std::string, std::string> ObjectPrefixMap;
  46. /// The Resources directory in the .dSYM bundle.
  47. Optional<std::string> ResourceDir;
  48. /// Symbol map translator.
  49. SymbolMapTranslator Translator;
  50. /// Virtual File System.
  51. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
  52. vfs::getRealFileSystem();
  53. /// Fields used for linking and placing remarks into the .dSYM bundle.
  54. /// @{
  55. /// Number of debug maps processed in total.
  56. unsigned NumDebugMaps = 0;
  57. /// -remarks-prepend-path: prepend a path to all the external remark file
  58. /// paths found in remark metadata.
  59. std::string RemarksPrependPath;
  60. /// The output format of the remarks.
  61. remarks::Format RemarksFormat = remarks::Format::Bitstream;
  62. /// @}
  63. LinkOptions() = default;
  64. };
  65. inline void warn(Twine Warning, Twine Context = {}) {
  66. WithColor::warning() << Warning + "\n";
  67. if (!Context.isTriviallyEmpty())
  68. WithColor::note() << Twine("while processing ") + Context + "\n";
  69. }
  70. inline bool error(Twine Error, Twine Context = {}) {
  71. WithColor::error() << Error + "\n";
  72. if (!Context.isTriviallyEmpty())
  73. WithColor::note() << Twine("while processing ") + Context + "\n";
  74. return false;
  75. }
  76. } // end namespace dsymutil
  77. } // end namespace llvm
  78. #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H