[cfe-dev] GCC and Clang produce undefined references to functions with vague linkage

Rafael Espíndola rafael.espindola at gmail.com
Fri Jun 29 14:23:07 PDT 2012


> There's no "for a long time" here.  The ABI does not allow us to emit these
> symbols with non-coalescing linkage.  We're not going to break ABI
> just because people didn't consider a particular code pattern when they
> hacked in devirtualization through external v-tables.

If we take "the ABI" to mean compatibility with released versions of
the compilers, then it *is* broken, as released compilers assume
behavior that is not guaranteed by the ABI (the document). It is not
possible to avoid all incompatibilities. To avoid most we would have
to

* Say that the symbol must be exported by the file that exports the
vtable. Not doing so causes incompatibilities with files compiled by
gcc version 4.6 and 4.7, open source clang versions 2.9, 3.0, 3.1
and Apple's releases 318.0.58 and 421-10.48 (those are the ones I have
on my laptop).
* Say that the symbol must remain mergeable so that current files
still work, which on OS X requires it to be weak.

In other words, we have to take the worse of both options. The only
thing that would still be broken (in released versions) are libraries
built with gcc's LTO, but hopefully changing that is the option with
the least impact on the users.

> John.

Cheers,
Rafael




More information about the cfe-dev mailing list