Skip to content

Commit d98753c

Browse files
committed
[dsymutil] Remove paper trail warnings
Remove the paper trail warning from dsymutil and the DWARF linker. The original purpose of this functionality was to leave a paper trail in the output artifact about missing object files. The current implementation however has diverged and is the source of a pretty serious bug: - In the debug map parser, missing object files are not the only warnings we emit. When paper trail warnings are enabled, all of them end up in the dSYM which wasn't the goal. - When warnings are associated with a object file in the debug map, it is skipped by the DWARF linker. This only makes sense if the object file is missing and is obviously incorrect for any other type of warning (such as a missing symbol). The combination of the two means that we can generate broken DWARF when the feature is enabled. AFAIK it was only used by Apple and nobody I spoke to has relied on it, so rather than fixing the broken behavior I propose we remove it.
1 parent 8f355fd commit d98753c

File tree

4 files changed

+7
-60
lines changed

4 files changed

+7
-60
lines changed

llvm/test/tools/dsymutil/X86/papertrail-warnings.test

Lines changed: 0 additions & 30 deletions
This file was deleted.

llvm/tools/dsymutil/MachODebugMapParser.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ class MachODebugMapParser {
2727
public:
2828
MachODebugMapParser(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
2929
StringRef BinaryPath, ArrayRef<std::string> Archs,
30-
StringRef PathPrefix = "",
31-
bool PaperTrailWarnings = false, bool Verbose = false)
30+
StringRef PathPrefix = "", bool Verbose = false)
3231
: BinaryPath(std::string(BinaryPath)), Archs(Archs.begin(), Archs.end()),
33-
PathPrefix(std::string(PathPrefix)),
34-
PaperTrailWarnings(PaperTrailWarnings), BinHolder(VFS, Verbose),
32+
PathPrefix(std::string(PathPrefix)), BinHolder(VFS, Verbose),
3533
CurrentDebugMapObject(nullptr), SkipDebugMapObject(false) {}
3634

3735
/// Parses and returns the DebugMaps of the input binary. The binary contains
@@ -49,7 +47,6 @@ class MachODebugMapParser {
4947
std::string BinaryPath;
5048
SmallVector<StringRef, 1> Archs;
5149
std::string PathPrefix;
52-
bool PaperTrailWarnings;
5350

5451
/// Owns the MemoryBuffer for the main binary.
5552
BinaryHolder BinHolder;
@@ -136,13 +133,6 @@ class MachODebugMapParser {
136133
<< MachOUtils::getArchName(
137134
Result->getTriple().getArchName())
138135
<< ") " << File << " " << Msg << "\n";
139-
140-
if (PaperTrailWarnings) {
141-
if (!File.empty())
142-
Result->addDebugMapObject(File, sys::TimePoint<std::chrono::seconds>());
143-
if (Result->end() != Result->begin())
144-
(*--Result->end())->addWarning(Msg.str());
145-
}
146136
}
147137
};
148138

@@ -702,13 +692,11 @@ namespace dsymutil {
702692
llvm::ErrorOr<std::vector<std::unique_ptr<DebugMap>>>
703693
parseDebugMap(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
704694
StringRef InputFile, ArrayRef<std::string> Archs,
705-
StringRef PrependPath, bool PaperTrailWarnings, bool Verbose,
706-
bool InputIsYAML) {
695+
StringRef PrependPath, bool Verbose, bool InputIsYAML) {
707696
if (InputIsYAML)
708697
return DebugMap::parseYAMLDebugMap(InputFile, PrependPath, Verbose);
709698

710-
MachODebugMapParser Parser(VFS, InputFile, Archs, PrependPath,
711-
PaperTrailWarnings, Verbose);
699+
MachODebugMapParser Parser(VFS, InputFile, Archs, PrependPath, Verbose);
712700
return Parser.parse();
713701
}
714702

llvm/tools/dsymutil/dsymutil.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ struct DsymutilOptions {
102102
bool DumpStab = false;
103103
bool Flat = false;
104104
bool InputIsYAMLDebugMap = false;
105-
bool PaperTrailWarnings = false;
106105
bool ForceKeepFunctionForStatic = false;
107106
std::string SymbolMap;
108107
std::string OutputFile;
@@ -193,11 +192,6 @@ static Error verifyOptions(const DsymutilOptions &Options) {
193192
"cannot use -o with multiple inputs in flat mode.",
194193
errc::invalid_argument);
195194

196-
if (Options.PaperTrailWarnings && Options.InputIsYAMLDebugMap)
197-
return make_error<StringError>(
198-
"paper trail warnings are not supported for YAML input.",
199-
errc::invalid_argument);
200-
201195
if (!Options.ReproducerPath.empty() &&
202196
Options.ReproMode != ReproducerMode::Use)
203197
return make_error<StringError>(
@@ -281,7 +275,6 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
281275
Options.DumpStab = Args.hasArg(OPT_symtab);
282276
Options.Flat = Args.hasArg(OPT_flat);
283277
Options.InputIsYAMLDebugMap = Args.hasArg(OPT_yaml_input);
284-
Options.PaperTrailWarnings = Args.hasArg(OPT_papertrail);
285278

286279
if (Expected<DWARFVerify> Verify = getVerifyKind(Args)) {
287280
Options.Verify = *Verify;
@@ -360,9 +353,6 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
360353
if (Options.DumpDebugMap || Options.LinkOpts.Verbose)
361354
Options.LinkOpts.Threads = 1;
362355

363-
if (getenv("RC_DEBUG_OPTIONS"))
364-
Options.PaperTrailWarnings = true;
365-
366356
if (opt::Arg *RemarksPrependPath = Args.getLastArg(OPT_remarks_prepend_path))
367357
Options.LinkOpts.RemarksPrependPath = RemarksPrependPath->getValue();
368358

@@ -625,8 +615,8 @@ int dsymutil_main(int argc, char **argv) {
625615

626616
auto DebugMapPtrsOrErr =
627617
parseDebugMap(Options.LinkOpts.VFS, InputFile, Options.Archs,
628-
Options.LinkOpts.PrependPath, Options.PaperTrailWarnings,
629-
Options.LinkOpts.Verbose, Options.InputIsYAMLDebugMap);
618+
Options.LinkOpts.PrependPath, Options.LinkOpts.Verbose,
619+
Options.InputIsYAMLDebugMap);
630620

631621
if (auto EC = DebugMapPtrsOrErr.getError()) {
632622
WithColor::error() << "cannot parse the debug map for '" << InputFile

llvm/tools/dsymutil/dsymutil.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class BinaryHolder;
3737
ErrorOr<std::vector<std::unique_ptr<DebugMap>>>
3838
parseDebugMap(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
3939
StringRef InputFile, ArrayRef<std::string> Archs,
40-
StringRef PrependPath, bool PaperTrailWarnings, bool Verbose,
41-
bool InputIsYAML);
40+
StringRef PrependPath, bool Verbose, bool InputIsYAML);
4241

4342
/// Dump the symbol table.
4443
bool dumpStab(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,

0 commit comments

Comments
 (0)