Joerg Sonnenberger
2014-Jun-04 23:08 UTC
[LLVMdev] -fvisibility=hidden, and typeinfo, and type-erasure
On Wed, Jun 04, 2014 at 06:32:35PM -0400, Rafael Espíndola wrote:> I think the difference is actually in the c++ library. It looks like > libstdc++ changed to always use strcmp of the typeinfo names: > > https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=149964 > > Should we do the same with libc++?No. It pessimizes correctly behaving code to work around code that violates the ELF ABI. Consider an application that loads plugins with RTLD_LOCAL. Two plugins implement a (hidden) type called "Plugin". The GCC change now makes this completely separate types identical for all RTTI purposes. That makes no sense at all. Joerg
Rafael Avila de Espindola
2014-Jun-04 23:43 UTC
[LLVMdev] -fvisibility=hidden, and typeinfo, and type-erasure
Sent from my iPhone> On Jun 4, 2014, at 19:08, Joerg Sonnenberger <joerg at britannica.bec.de> wrote: > >> On Wed, Jun 04, 2014 at 06:32:35PM -0400, Rafael Espíndola wrote: >> I think the difference is actually in the c++ library. It looks like >> libstdc++ changed to always use strcmp of the typeinfo names: >> >> https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=149964 >> >> Should we do the same with libc++? > > No. It pessimizes correctly behaving code to work around code that > violates the ELF ABI. Consider an application that loads plugins with > RTLD_LOCAL. Two plugins implement a (hidden) type called "Plugin". The > GCC change now makes this completely separate types identical for all > RTTI purposes. That makes no sense at all. >That is an interesting argument, in particular because RTLD_LOCAL seems to be the reason why libstdc++ switched :-)> Joerg > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Joerg Sonnenberger
2014-Jun-06 10:24 UTC
[LLVMdev] -fvisibility=hidden, and typeinfo, and type-erasure
On Wed, Jun 04, 2014 at 07:43:35PM -0400, Rafael Avila de Espindola wrote:> > > Sent from my iPhone > > > On Jun 4, 2014, at 19:08, Joerg Sonnenberger <joerg at britannica.bec.de> wrote: > > > >> On Wed, Jun 04, 2014 at 06:32:35PM -0400, Rafael Espíndola wrote: > >> I think the difference is actually in the c++ library. It looks like > >> libstdc++ changed to always use strcmp of the typeinfo names: > >> > >> https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=149964 > >> > >> Should we do the same with libc++? > > > > No. It pessimizes correctly behaving code to work around code that > > violates the ELF ABI. Consider an application that loads plugins with > > RTLD_LOCAL. Two plugins implement a (hidden) type called "Plugin". The > > GCC change now makes this completely separate types identical for all > > RTTI purposes. That makes no sense at all. > > > > That is an interesting argument, in particular because RTLD_LOCAL seems > to be the reason why libstdc++ switched :-)I think the most common cause was lack of -rdynamic when linking the main program. Let's say you have a type defined in your main program. It is not used by any of the shared libraries, so it doesn't get exported with a copy relocation. Now you have a plugin that also uses this type. The dynamic loader can't unify the types, even if the instance in the plugin is public, because the instance in the main program is hidden from it. Joerg