[cfe-dev] GCC and Clang produce undefined references to functions with vague linkage
Jan Hubicka
jh at suse.cz
Mon Jul 2 00:57:57 PDT 2012
Quoting John McCall <rjmccall at apple.com>:
> On Jun 29, 2012, at 2:23 PM, Rafael Espíndola wrote:
>>> 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.
>
> By "breaking the ABI", I mean changing the required output of
> compilers that conform to it. It is understood that compilers will
> occasionally have bugs that cause them to not conform; as a
> somewhat trivial example, both gcc and clang have mis-mangled
> symbols in the past. Typically, compiler implementers choose to fix
> those bugs, rather than trying to codify them by modifying the ABI.
>
> Again, the ABI clearly expects that every object file that references
> an inline function will define it, and do so with coalescing linkage.
> That is an invaluable invariant. Our proposed visibility-modifying
> optimization is hardly the only reasonable consumer of it.
>
> As with most compatibility problems, it would be better if no compiler
> had ever strayed from the One True Path, and yet it's happened.
> Given that the chance of actual incompatibility in practice is low —
> as I believe I've argued several times — I continue to believe that
> the proper response is to just fix the bug, rather than imposing a
> novel and permanent constraint on ourselves out of unmotivated worry.
Yes, this indeed looks like (most probably my) bug in the constant
folding code that now uses extern vtables. I will fix it. So we can
not take comdat linkage decl from external vtable when we no longer
have its body around, right?
Honza
More information about the cfe-dev
mailing list