Skip to content

Commit d6dd84d

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 f3296e1 commit d6dd84d

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
@@ -100,7 +100,6 @@ struct DsymutilOptions {
100100
bool DumpStab = false;
101101
bool Flat = false;
102102
bool InputIsYAMLDebugMap = false;
103-
bool PaperTrailWarnings = false;
104103
bool ForceKeepFunctionForStatic = false;
105104
std::string SymbolMap;
106105
std::string OutputFile;
@@ -191,11 +190,6 @@ static Error verifyOptions(const DsymutilOptions &Options) {
191190
"cannot use -o with multiple inputs in flat mode.",
192191
errc::invalid_argument);
193192

194-
if (Options.PaperTrailWarnings && Options.InputIsYAMLDebugMap)
195-
return make_error<StringError>(
196-
"paper trail warnings are not supported for YAML input.",
197-
errc::invalid_argument);
198-
199193
if (!Options.ReproducerPath.empty() &&
200194
Options.ReproMode != ReproducerMode::Use)
201195
return make_error<StringError>(
@@ -279,7 +273,6 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
279273
Options.DumpStab = Args.hasArg(OPT_symtab);
280274
Options.Flat = Args.hasArg(OPT_flat);
281275
Options.InputIsYAMLDebugMap = Args.hasArg(OPT_yaml_input);
282-
Options.PaperTrailWarnings = Args.hasArg(OPT_papertrail);
283276

284277
if (Expected<DWARFVerify> Verify = getVerifyKind(Args)) {
285278
Options.Verify = *Verify;
@@ -358,9 +351,6 @@ static Expected<DsymutilOptions> getOptions(opt::InputArgList &Args) {
358351
if (Options.DumpDebugMap || Options.LinkOpts.Verbose)
359352
Options.LinkOpts.Threads = 1;
360353

361-
if (getenv("RC_DEBUG_OPTIONS"))
362-
Options.PaperTrailWarnings = true;
363-
364354
if (opt::Arg *RemarksPrependPath = Args.getLastArg(OPT_remarks_prepend_path))
365355
Options.LinkOpts.RemarksPrependPath = RemarksPrependPath->getValue();
366356

@@ -623,8 +613,8 @@ int dsymutil_main(int argc, char **argv) {
623613

624614
auto DebugMapPtrsOrErr =
625615
parseDebugMap(Options.LinkOpts.VFS, InputFile, Options.Archs,
626-
Options.LinkOpts.PrependPath, Options.PaperTrailWarnings,
627-
Options.LinkOpts.Verbose, Options.InputIsYAMLDebugMap);
616+
Options.LinkOpts.PrependPath, Options.LinkOpts.Verbose,
617+
Options.InputIsYAMLDebugMap);
628618

629619
if (auto EC = DebugMapPtrsOrErr.getError()) {
630620
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)