This is an archive of the discontinued LLVM Phabricator instance.

lld-link: Allow mixing 'discard' and 'largest' comdat selections
ClosedPublic

Authored by thakis on Jan 31 2019, 8:03 AM.

Details

Summary

cl.exe and clang-cl.exe put vftables in a 'discard' comdat when building with RTTI disabled (/GR-) but in a 'largest' comdat when building with RTTI enabled. To be able to link /GR- code with /GR code, lld-link needs to accept comdats that have this type of comdat selection conflict.

For example, static libraries in the Visual Studio standard library are built with /GR, and without this it's impossible to build client code with /GR- and still link to the standard library.

link.exe also accepts merging 'discard' with 'largest', and it accepts merging 'largest' with any other selection type. lld-link is still a bit stricter since it only allows merging 'largest' with 'discard' for symmetry.

Diff Detail

Event Timeline

thakis created this revision.Jan 31 2019, 8:03 AM
hans accepted this revision.Jan 31 2019, 8:07 AM

lgtm

Maybe also make it clear in the commit message that link.exe allows this.

lld/COFF/InputFiles.cpp
488

ultra nit: maybe s/picks/uses/

This revision is now accepted and ready to land.Jan 31 2019, 8:07 AM
thakis edited the summary of this revision. (Show Details)Jan 31 2019, 8:12 AM
thakis edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.