This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Use source information in duplicate symbol errors
ClosedPublic

Authored by BertalanD on Jun 23 2022, 3:59 AM.

Details

Summary

Similarly to how undefined symbol diagnostics were changed in D128184,
we now show where in the source file duplicate symbols are defined at:

ld64.lld: error: duplicate symbol: _foo
>> defined in bar.c:42
>>            /path/to/bar.o
>> defined in baz.c:1
>>            /path/to/libbaz.a(baz.o)

For objects that don't contain DWARF data, the format is unchanged.

A slight difference to undefined symbol diagnostics is that we don't
print the name of the symbol on the third line, as it's already
contained on the first line.


I've requested commit access, but while I'm waiting for that, please commit this patch with the following author info:
Daniel Bertalan <dani@danielbertalan.dev>

Diff Detail

Event Timeline

BertalanD created this revision.Jun 23 2022, 3:59 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJun 23 2022, 3:59 AM
BertalanD requested review of this revision.Jun 23 2022, 3:59 AM
thakis accepted this revision.Jun 23 2022, 4:44 AM
thakis added a subscriber: thakis.

Nice!

lld/MachO/InputSection.cpp
91

If you use dyn_cast_or_null here, you don't need the 3 new lines above.

This revision is now accepted and ready to land.Jun 23 2022, 4:44 AM
BertalanD updated this revision to Diff 439340.Jun 23 2022, 5:06 AM

use dyn_cast_or_null

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 8:09 AM