[llvm-commits] [pr11697][patch] Implement linking of symbols with different visibilities

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Tue Jan 3 18:56:27 PST 2012


The LLVM IL linker currently refuses to link symbols if the visibilities
are different. This causes problems when using LTO and
-fvisibility-inlines-hidden.

This patch implements the rules of the System V Application Binary
Interface (http://sco.com/developers/gabi/2009-10-26/ch4.symtab.html),
so that we get consistent behavior with and without LTO.

This does mean that when using -fvisibility-inlines-hidden, if we have
an explicit template instantiation definition in a library(.so), then
every use of an inline method of that class must see an explicit
template instantiation declaration or we can end up with a hidden symbol
in the library. I think this is OK because:

* That is already the case when *not* doing LTO and using gold (the gnu
bfd linker is not conformant with the spec).

* -fvisibility-inlines-hidden already breaks the standard a bit (pointer
comparisons), so saying that it requires explicit template instantiation
declaratios when a definition is used is not too bad.

* As Eli pointed out on IRC, LTO supersedes -fvisibility-inlines-hidden.
At the IL level we differentiate weak_odr and linkonce_odr. All that we
need is for the link to still work if someone ends up using both LTO and
-fvisibility-inlines-hidden.

Thanks a lot to Eli and Ian for the comments and pointers.

Cheers,
Rafael
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr11697.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120103/7bf0e9e9/attachment.ksh>


More information about the llvm-commits mailing list