I've noticed that some SWIFT binaries show duplicate metadata entries such as:
along with all descending linked metadata.
The Issue is coming from GenClass.cpp#L1396 where, a global is created with internal linkage: GenClass.cpp#L2181. Because of the internal linkage, the linker will not merge identical records in the final output.
The fix is to update the linkage type to WeakAnyLinkage, as in ObjC
I also opened [SR-15376] Duplicate "__PROTOCOL_*" metadata in linked binaries - Swift about this.
I'm thinking about going ahead and submitting a fix to change the internal linkage to WeakAnyLinkage and updating to unit tests to reflect the change.
Is this the right way to go, am I missing anything?