I'm sorry my message is quite long, the TL;DR version is "g++ and clang++ seem to have different opinions on how RTTI, templates, and ELF visibility should interact".
I can't tell whether this is a bug or not: I have found no relevant documentation that could help me decide whether this behavior is meant, or not. All I can say is that the current behavior is not the one I would expect, but maybe you guys have a different opinion, which I'd be happy to hear about. To my eyes it looks like a violation of the One Definition Rule, but since ELF visibility issues are not covered by the standard, this is wishful thinking
I'm reproducing here basically what I had written there:
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.
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.
As I wrote earlier, the GCC change is plainly wrong and libc++ works
exactly as intended.
I ran into this problem when trying to move a big proprietary code base to use libc++ on ubuntu linux. It took me a few days until I found this mail thread. I have not yet found a proper way to work-around this difference in behavior between libstdc++ and libc++.
My code base depends on a lot of third party libraries and patching those with visibility-attributes is beyond the scope of what I can do.
Are there any other options for making libc++ work on linux when using -fvisibility=hidden?