2018-06-27 18:13:40 +02:00
|
|
|
//===- tools/dsymutil/LinkUtils.h - Dwarf linker utilities ------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-06-27 18:13:40 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
|
|
|
|
#define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
|
|
|
|
|
2019-01-08 00:27:25 +01:00
|
|
|
#include "SymbolMap.h"
|
|
|
|
|
2018-06-27 18:13:40 +02:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2019-09-30 18:05:12 +02:00
|
|
|
#include "llvm/Remarks/RemarkFormat.h"
|
2020-05-05 05:19:15 +02:00
|
|
|
#include "llvm/Support/VirtualFileSystem.h"
|
2018-06-27 18:13:40 +02:00
|
|
|
#include "llvm/Support/WithColor.h"
|
2019-01-08 00:27:25 +01:00
|
|
|
|
[Dsymutil][Debuginfo][NFC] #4 Refactor dsymutil to separate DWARF optimizing part.
Summary:
The primary goal of this refactoring is to separate DWARF optimizing part.
So that it could be reused by linker or by any other client.
There was a thread on llvm-dev discussing the necessity of such a refactoring:
http://lists.llvm.org/pipermail/llvm-dev/2019-September/135068.html.
This is a final part from series of patches for dsymutil.
Previous patches : D71068, D71839, D72476. This patch:
1. Creates lib/DWARFLinker interface :
void addObjectFile(DwarfLinkerObjFile &ObjFile);
bool link();
void setOptions;
1. Moves all linking logic from tools/dsymutil/DwarfLinkerForBinary
into lib/DWARFLinker.
2. Renames RelocationManager into AddressesManager.
3. Remarks creation logic moved from separate parallel execution
into object file loading routine.
Testing: it passes "check-all" lit testing. MD5 checksum for clang .dSYM bundle
matches for the dsymutil with/without that patch.
Reviewers: JDevlieghere, friss, dblaikie, aprantl, jdoerfert
Reviewed By: JDevlieghere
Subscribers: merge_guards_bot, hiraditya, jfb, llvm-commits, probinson, thegameg
Tags: #llvm, #debug-info
Differential Revision: https://reviews.llvm.org/D72915
2020-01-12 21:15:57 +01:00
|
|
|
#include "llvm/DWARFLinker/DWARFLinker.h"
|
2020-04-06 23:42:40 +02:00
|
|
|
#include "llvm/DWARFLinker/DWARFStreamer.h"
|
2018-06-27 18:13:40 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace dsymutil {
|
|
|
|
|
|
|
|
struct LinkOptions {
|
|
|
|
/// Verbosity
|
|
|
|
bool Verbose = false;
|
|
|
|
|
2020-05-07 04:38:30 +02:00
|
|
|
/// Statistics
|
|
|
|
bool Statistics = false;
|
|
|
|
|
2018-06-27 18:13:40 +02:00
|
|
|
/// Skip emitting output
|
|
|
|
bool NoOutput = false;
|
|
|
|
|
|
|
|
/// Do not unique types according to ODR
|
|
|
|
bool NoODR = false;
|
|
|
|
|
|
|
|
/// Update
|
|
|
|
bool Update = false;
|
|
|
|
|
|
|
|
/// Do not check swiftmodule timestamp
|
|
|
|
bool NoTimestamp = false;
|
|
|
|
|
2021-04-27 03:20:49 +02:00
|
|
|
/// Whether we want a static variable to force us to keep its enclosing
|
|
|
|
/// function.
|
|
|
|
bool KeepFunctionForStatic = false;
|
|
|
|
|
2018-06-27 18:13:40 +02:00
|
|
|
/// Number of threads.
|
|
|
|
unsigned Threads = 1;
|
|
|
|
|
2018-07-09 18:58:48 +02:00
|
|
|
// Output file type.
|
|
|
|
OutputFileType FileType = OutputFileType::Object;
|
|
|
|
|
2018-07-26 01:01:38 +02:00
|
|
|
/// The accelerator table kind
|
|
|
|
AccelTableKind TheAccelTableKind;
|
|
|
|
|
2018-06-27 18:13:40 +02:00
|
|
|
/// -oso-prepend-path
|
|
|
|
std::string PrependPath;
|
|
|
|
|
2020-03-18 23:31:39 +01:00
|
|
|
/// The -object-prefix-map.
|
|
|
|
std::map<std::string, std::string> ObjectPrefixMap;
|
|
|
|
|
2019-04-22 23:33:22 +02:00
|
|
|
/// The Resources directory in the .dSYM bundle.
|
|
|
|
Optional<std::string> ResourceDir;
|
|
|
|
|
2019-01-08 00:27:25 +01:00
|
|
|
/// Symbol map translator.
|
|
|
|
SymbolMapTranslator Translator;
|
|
|
|
|
2020-05-05 05:19:15 +02:00
|
|
|
/// Virtual File System.
|
|
|
|
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
|
|
|
|
vfs::getRealFileSystem();
|
|
|
|
|
2019-09-30 18:05:12 +02:00
|
|
|
/// Fields used for linking and placing remarks into the .dSYM bundle.
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// Number of debug maps processed in total.
|
|
|
|
unsigned NumDebugMaps = 0;
|
|
|
|
|
|
|
|
/// -remarks-prepend-path: prepend a path to all the external remark file
|
|
|
|
/// paths found in remark metadata.
|
|
|
|
std::string RemarksPrependPath;
|
|
|
|
|
|
|
|
/// The output format of the remarks.
|
|
|
|
remarks::Format RemarksFormat = remarks::Format::Bitstream;
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
2018-06-27 18:13:40 +02:00
|
|
|
LinkOptions() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline void warn(Twine Warning, Twine Context = {}) {
|
|
|
|
WithColor::warning() << Warning + "\n";
|
|
|
|
if (!Context.isTriviallyEmpty())
|
|
|
|
WithColor::note() << Twine("while processing ") + Context + "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool error(Twine Error, Twine Context = {}) {
|
|
|
|
WithColor::error() << Error + "\n";
|
|
|
|
if (!Context.isTriviallyEmpty())
|
|
|
|
WithColor::note() << Twine("while processing ") + Context + "\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // end namespace dsymutil
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
|