https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86490

--- Comment #12 from zenith432 at users dot sourceforge.net ---
Fair enough, it's a gold bug in the sense that gold's algorithm for selecting a
prevailing def among multiple defs has an error.
If an IR symbol has multiple definitions as
LDPK_COMMON
and a single definition as
LDPK_DEF
then the one marked as LDPK_DEF should be resolved as
LDPR_PREVAILING_DEF_IRNONLY and the other defintions as PREEMPTED_IR.

However, the limitation of a single prevailing def is documented...
http://gcc.gnu.org/wiki/whopr/driver
In the subsection
The "All Symbols Read" Event
"In the case of a symbol that is defined in more than one IR file, WPA will
need to know which definition to use and which definitions to ignore."

Logically, it is the linker's job to make this decision, because the prevailing
def depends on the order that object files are given on the command line, on
whether the object file has to be included in the link (i.e. it's on the
command line) - or it's in a library and is optional.  And also on whether it's
a common def or not.  lto1 cannot make this decision by itself.

It is not possible to leave multiple prevailing defs for lto1 just because the
linker doesn't need the symbol and considers it discardable - because an IR
symbol may be referenced from inside the IR by another part needed in the link.
 In that case lto1 will need to generate the multiply defined symbol, and can't
decide which one to use - for example because it doesn't know the order of the
object files in the libraries given on the linker command line.

Reply via email to