[Bug c++/9283] __attribute__((visibility ("hidden"))) not supported for class/struct

s_gccbugzilla at nedprod dot com gcc-bugzilla@gcc.gnu.org
Fri Jan 30 20:51:00 GMT 2004


------- Additional Comments From s_gccbugzilla at nedprod dot com  2004-01-30 20:51 -------
>From bug #13905 which I posted I'd like to add the following:

This idea of Dirk's is good but I think he's coming at it the wrong way. Instead 
of labouriously specifying things as hidden individually and hoping to not 
forget any, the *default* should be hidden and you specify things as exported 
individually - here if you forget you get a link error.

Not uncoincidentally, I'm wishing to leverage the same semantics as Windows so 
that the macros commonly used on cross-platform applications merely need to be 
redefined from __declspec(dllexport) to __attribute__ ((visibility("export")) 
and no further code changes are required.

To allow this to happen, GCC would need an extra command line option to set the 
default visibility of all symbols:

-fvisibility=external
-fvisibility=default
-fvisibility=protected
-fvisibility=hidden
-fvisibility=internal

These are chosen for compatibility with Intel's C++ compiler which already 
offers the ability to mark all symbols as default non-exported in ELF output.

Why this approach is better than Dirk's: much cleaner ELF images output. Faster 
dynamic linking times as less symbols are exported. Much more scope for GCC to 
optimise object files as it now knows what RTTI info it can discard as well as 
improved COMDAT folding etc.

I in particular suffer from this as GCC generates binaries nearly twice as big 
than MSVC for identical code :( (I think it's the RTTI info for all the 
templates plus not being able to COMDAT fold most of the symbols)

References: http://people.redhat.com/drepper/dsohowto.pdf

Cheers,
Niall


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9283



More information about the Gcc-bugs mailing list