[dsymutil] Skip duplicates files with identical time stamps in the debug map
authorJonas Devlieghere <jonas@devlieghere.com>
Mon, 12 Jun 2023 16:57:01 +0000 (09:57 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Mon, 12 Jun 2023 17:01:12 +0000 (10:01 -0700)
commit65f63739805e2c884364cb5b4b77430f96ecee7c
tree80e5714e1e88c213441309a32505905db772e55e
parent08da9ceb647551d266d34ebdce47e6ca62a31ae0
[dsymutil] Skip duplicates files with identical time stamps in the debug map

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 print a single informative warning and skip
the ambiguous debug map objects.

rdar://110374836

Differential revision: https://reviews.llvm.org/D152585
llvm/test/tools/dsymutil/ARM/static-archive-collision.test [new file with mode: 0644]
llvm/test/tools/dsymutil/Inputs/private/tmp/collision/foo.a [new file with mode: 0644]
llvm/test/tools/dsymutil/Inputs/private/tmp/collision/main.o [new file with mode: 0644]
llvm/test/tools/dsymutil/Inputs/private/tmp/collision/main.out [new file with mode: 0755]
llvm/tools/dsymutil/MachODebugMapParser.cpp