[C++-sig] Symbol visibility patch for GCC v3.4
Niall Douglas
s_sourceforge at nedprod.com
Mon Apr 5 19:17:33 CEST 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
If people could test this patch and let me know, I'd be most
grateful.
Some might consider this off-topic, so I'll give you a quick run down
of the improvements - with my Boost.Python built bindings, my shared
object went from >200,000 symbols down to just 19,738 resulting in
the six minute load time dropping to a few seconds. If you examine
the dynamic table with nm, the output is vastly cleaner with only
what is actually required being exported - this will beat any linker
version script method hands down. Also, because the compiler now
knows what symbols don't need to run through the relocation table, it
can substantially optimise code output with better inlining, half the
overhead of calling a function, much better ability to totally elide
unnecessary code and many other benefits. See Ulrich Drepper's "How
to Write Shared Libraries" article.
To install, get a GCC v3.4 from CVS. Apply patch. Find the header
file boost/boost/python/detail/config.hpp. Modify the dllexport
section to:
#if defined(BOOST_PYTHON_DYNAMIC_LIB)
# if (defined(_WIN32) || defined(__CYGWIN__))
# if defined(BOOST_PYTHON_SOURCE)
# define BOOST_PYTHON_DECL __declspec(dllexport)
# define BOOST_PYTHON_BUILD_DLL
# else
# define BOOST_PYTHON_DECL __declspec(dllimport)
# endif
# elif (defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >=4)
# if defined(BOOST_PYTHON_SOURCE)
# define BOOST_PYTHON_DECL __attribute__
((visibility("default")))
# define BOOST_PYTHON_BUILD_DLL
# else
# define BOOST_PYTHON_DECL
# endif
# endif
#endif
Adjust the Jamfile to include a <cxxflags>-fvisibility=hidden for the
dll boost_python. Recompile everything using -fvisibility=hidden for
your binding source files too. You should see a substantial
improvement in link times and your shared objects will have reduced
in size, sometimes by tens of megabytes.
Everything should run just as before. If it doesn't, please let me
know - everything on my end runs just as before.
Cheers,
Niall
-----BEGIN PGP SIGNATURE-----
Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2
iQA/AwUBQHGUrcEcvDLFGKbPEQJwfQCeJmlYFO1SaDeq7sO1BBjy2WTlcCcAnAgm
TFiYmU2XblgPt7PsLG0DVkkd
=Jv/S
-----END PGP SIGNATURE-----
More information about the Cplusplus-sig
mailing list