This is an archive of the discontinued LLVM Phabricator instance.

[DwarfDebug] Prioritise DWARF filename in debuginfo over MC Target Options
AbandonedPublic

Authored by cbeuw on Dec 9 2021, 5:22 PM.

Details

Reviewers
dblaikie
Summary

The value of splitDebugFilename in DICompileUnit is currently ignored when
emitting the dwo name into an object file. The path supplied in
MCOptions.SplitDwarfFile is used both as a real path to write the split
dwo content, and as the value of DW_AT_[GNU_]dwo_name emitted into the object
file.

Instead, the filename specified in DICompileUnit should be the one emitted so
long as it has been specified. Additionally, since MCOptions.SplitDwarfFile
points to a real path, this may lead to inconsistent compilation results when
doing remote/distributed builds.

MCOptions.SplitDwarfFile remains to be used as the real path to write the
dwo file, but splitDebugFilename in DICompileUnit is emitted when specified,
and otherwise falls back to emit MCOptions.SplitDwarfFile as-is

Diff Detail

Event Timeline

cbeuw created this revision.Dec 9 2021, 5:22 PM
cbeuw requested review of this revision.Dec 9 2021, 5:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2021, 5:22 PM
cbeuw updated this revision to Diff 393429.Dec 10 2021, 3:20 AM

Fix an llvm-dwp test

cbeuw updated this revision to Diff 393439.Dec 10 2021, 3:50 AM

Fix line endings

I /think/ this is the wrong direction.

"split dwarf file" is meant to be the name that goes in the dwo_name
"split dwarf output" is the name of the actual output file, and doesn't have to be the same as the "split dwarf file".

I guess currently this is only exposed in -cc1/llc/etc, and not in the clang driver (the only thing that causes split dwarf file/output to differ.

At the LLVM level in this patch, if you want the physical file to be something other than SplitDwarfFile, then that can be achieved by creating a different/non-null raw_pwrite_stream for the DwoOS parameter here: https://github.com/llvm/llvm-project/blob/bebfbfd4a82573e27171b4adf239c9804fa6d656/clang/lib/CodeGen/BackendUtil.cpp#L1075

cbeuw abandoned this revision.EditedDec 11 2021, 3:16 AM

Indeed I was mistaken about the effect of SplitDwarfFile in MCOptions. It does not dictate the actual output path if DwoOS is specified. The thing I was working on was rustc and it does open DwoOS separately and passes it in like clang.