This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/9283] __attribute__((visibility ("hidden"))) not supported for class/struct
- From: "s_gccbugzilla at nedprod dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Jan 2004 20:51:21 -0000
- Subject: [Bug c++/9283] __attribute__((visibility ("hidden"))) not supported for class/struct
- References: <20030112104600.9283.mueller@kde.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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