[llvm-dev] Dropping COMDAT with LTO

Stephen Crane via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 20 14:59:42 PST 2017


I've been digging into COMDAT with regular LTO, specifically in the
context of the LLVM gold plugin. The GCC WHOPR documentation specifies
that the linker will resolve all COMDAT groups to the IR-provided
definitions, if available. Additionally it specifies that "When the
WPA phase produces the definition of the COMDAT symbol in a new object
file, that definition should not be in a COMDAT group."
(https://gcc.gnu.org/wiki/whopr/driver#COMDAT_Sections)

The gold LTO plugin does not currently remove COMDAT groups from
symbols emitted to the new object file. This doesn't actually seem to
matter, as the linker ignores the COMDAT groups. However, it might be
nice to strip the COMDAT group early in module linking since we know
we won't need them.

Do other linkers that use the LTO api also resolve COMDAT symbols to
the LTO definition? Would it be possible to drop COMDAT groups for
prevailing symbols, at least when linking with the gold plugin?

- stephen


More information about the llvm-dev mailing list