LinkUtils.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. /// Minimize
  32. bool Minimize = false;
  33. /// Do not check swiftmodule timestamp
  34. bool NoTimestamp = false;
  35. /// Number of threads.
  36. unsigned Threads = 1;
  37. // Output file type.
  38. OutputFileType FileType = OutputFileType::Object;
  39. /// The accelerator table kind
  40. AccelTableKind TheAccelTableKind;
  41. /// -oso-prepend-path
  42. std::string PrependPath;
  43. /// The -object-prefix-map.
  44. std::map<std::string, std::string> ObjectPrefixMap;
  45. /// The Resources directory in the .dSYM bundle.
  46. Optional<std::string> ResourceDir;
  47. /// Symbol map translator.
  48. SymbolMapTranslator Translator;
  49. /// Virtual File System.
  50. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
  51. vfs::getRealFileSystem();
  52. /// Fields used for linking and placing remarks into the .dSYM bundle.
  53. /// @{
  54. /// Number of debug maps processed in total.
  55. unsigned NumDebugMaps = 0;
  56. /// -remarks-prepend-path: prepend a path to all the external remark file
  57. /// paths found in remark metadata.
  58. std::string RemarksPrependPath;
  59. /// The output format of the remarks.
  60. remarks::Format RemarksFormat = remarks::Format::Bitstream;
  61. /// @}
  62. LinkOptions() = default;
  63. };
  64. inline void warn(Twine Warning, Twine Context = {}) {
  65. WithColor::warning() << Warning + "\n";
  66. if (!Context.isTriviallyEmpty())
  67. WithColor::note() << Twine("while processing ") + Context + "\n";
  68. }
  69. inline bool error(Twine Error, Twine Context = {}) {
  70. WithColor::error() << Error + "\n";
  71. if (!Context.isTriviallyEmpty())
  72. WithColor::note() << Twine("while processing ") + Context + "\n";
  73. return false;
  74. }
  75. } // end namespace dsymutil
  76. } // end namespace llvm
  77. #endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H