This is an archive of the discontinued LLVM Phabricator instance.

[dsymutil] Skip duplicates files with identical time stamps in the debug map
ClosedPublic

Authored by JDevlieghere on Jun 9 2023, 2:32 PM.

Details

Summary

Static archives can contain multiple files with the same file name, in which case the timestamp is used to disambiguate. Because timestamps are expressed in seconds since epoch timestamp collisions are far from impossible. Furthermore, to facilitate reproducible builds, the static linker can be told to emit no timestamps at all.

dsymutil already detects timestamp mismatches between the debug map and the object files. However, it does not handle timestamp collisions within the debug maps (STABS). Currently, we arbitrarily pick the first debug map entry and ignore the rest. This is incorrect: if a symbol exists in multiple object files, the linker might not have picked the one from the first object file. This also results in missing symbol warnings for all the symbols not defined in the first object file.

Given that in this scenario, dsymutil does not have enough information to disambiguate, it should instead print a single informative warning and skip the ambiguous debug map objects.

rdar://110374836

Diff Detail

Event Timeline

JDevlieghere created this revision.Jun 9 2023, 2:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 2:32 PM
JDevlieghere requested review of this revision.Jun 9 2023, 2:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 2:32 PM
JDevlieghere edited the summary of this revision. (Show Details)

s/time stamp/timestamp/

pete accepted this revision.Jun 9 2023, 3:03 PM

LGTM!

This revision is now accepted and ready to land.Jun 9 2023, 3:03 PM
aprantl added inline comments.Jun 9 2023, 5:10 PM
llvm/tools/dsymutil/MachODebugMapParser.cpp
246

Maybe also use a DenseSet here? Once we're printing the warning the overhead for the memory allocation probably doesn't matter any more.

710

Is it legal that Empty == Tombstone?

aprantl added inline comments.Jun 9 2023, 5:11 PM
llvm/tools/dsymutil/MachODebugMapParser.cpp
48

A hack I used in other places was to use a struct that inherits from std::pair<StringRef, uint64_t> and write accessors, then you don't need to define all the hashing and comparison functions.

Use a std::pair instead of a custom struct to avoid hasing boilerplate.

JDevlieghere marked 3 inline comments as done.Jun 12 2023, 9:15 AM
friss accepted this revision.Jun 12 2023, 9:56 AM
This revision was landed with ongoing or failed builds.Jun 12 2023, 10:01 AM
This revision was automatically updated to reflect the committed changes.

Hi. Looks like the static-archive-collision.test test is failing on our builders at https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8778475674577642785/overview. Would you mind sending out a fix or revert?

Hi. Looks like the static-archive-collision.test test is failing on our builders at https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8778475674577642785/overview. Would you mind sending out a fix or revert?

This should've been fixed by 9cacc22640ef.