diff options
author | Martin Lucina <mato@kotelna.sk> | 2010-11-25 17:12:31 +0100 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2010-11-25 17:12:31 +0100 |
commit | c9584096e033850c77c4c3d4ee99e8073f7b26da (patch) | |
tree | 1c87497cffc99288743e21798b9ac452917f618d | |
parent | 734624be760b3c7942eb26bea77fca918cb1540d (diff) |
Control symbol exports using -fvisibility
On systems using GCC 4.0 or newer which support symbol visibility in shared
libraries, use -fvisibility=hidden and only export explict API functions
defined in zmq.cpp. We do not enable -fvisibility on MinGW since this uses a
separate mechanism (__declspec).
Signed-off-by: Martin Lucina <mato@kotelna.sk>
-rw-r--r-- | configure.in | 12 | ||||
-rw-r--r-- | include/zmq.h | 8 | ||||
-rw-r--r-- | include/zmq_utils.h | 6 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/zmq.cpp | 8 |
5 files changed, 35 insertions, 2 deletions
diff --git a/configure.in b/configure.in index 27f8bab..b7d524a 100644 --- a/configure.in +++ b/configure.in @@ -223,6 +223,18 @@ case "${host_os}" in ;; esac +# Check if the compiler supports -fvisibility=hidden. If so, use it, but not +# on MinGW32 where we use a separate mechanism (__declspec). +_LT_COMPILER_OPTION([if $compiler supports -fvisibility=hidden], + ac_cv_prog_compiler_visibility, + [-fvisibility=hidden], + [], + [have_dso_visibility=yes]) +if test "x$have_dso_visibility" = "xyes" -a "x$on_mingw32" = "xno"; then + LIBZMQ_EXTRA_CFLAGS="-fvisibility=hidden $LIBZMQ_EXTRA_CFLAGS" + LIBZMQ_EXTRA_CXXFLAGS="-fvisibility=hidden $LIBZMQ_EXTRA_CXXFLAGS" +fi + # CPU-specific optimizations case "${host_cpu}" in *sparc*) diff --git a/include/zmq.h b/include/zmq.h index c2efa07..7a63253 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -39,6 +39,9 @@ extern "C" { # endif #else # define ZMQ_EXPORT +# if defined __GNUC__ && __GNUC__ >= 4 +# pragma GCC visibility push(default) +# endif #endif /******************************************************************************/ @@ -242,6 +245,11 @@ ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout); ZMQ_EXPORT int zmq_device (int device, void * insocket, void* outsocket); +#undef ZMQ_EXPORT +#if defined __GNUC__ && __GNUC__ >= 4 && !defined _WIN32 +# pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/include/zmq_utils.h b/include/zmq_utils.h index 7d8d5fe..6d42bf9 100644 --- a/include/zmq_utils.h +++ b/include/zmq_utils.h @@ -33,6 +33,9 @@ extern "C" { # endif #else # define ZMQ_EXPORT +# if defined __GNUC__ && __GNUC__ >= 4 +# pragma GCC visibility push(default) +# endif #endif /* Helper functions are used by perf tests so that they don't have to care */ @@ -49,6 +52,9 @@ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); ZMQ_EXPORT void zmq_sleep (int seconds_); #undef ZMQ_EXPORT +#if defined __GNUC__ && __GNUC__ >= 4 && !defined _WIN32 +# pragma GCC visibility pop +#endif #ifdef __cplusplus } diff --git a/src/Makefile.am b/src/Makefile.am index 761d8e8..a857ee7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -203,7 +203,6 @@ libpgm_diff_flags = \ -DCONFIG_HAVE_ISO_VARARGS \ -DCONFIG_HAVE_TSC \ -DCONFIG_HAVE_WSACMSGHDR \ - -DCONFIG_HAVE_DSO_VISIBILITY \ -DCONFIG_BIND_INADDR_ANY else @@ -225,7 +224,6 @@ libpgm_diff_flags = \ -DCONFIG_HAVE_IP_MREQN \ -DCONFIG_HAVE_SPRINTF_GROUPING \ -DCONFIG_HAVE_VASPRINTF \ - -DCONFIG_HAVE_DSO_VISIBILITY \ -DCONFIG_BIND_INADDR_ANY \ -DCONFIG_HAVE_GETOPT endif @@ -237,6 +235,7 @@ libpgm_la_CFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/in -DCONFIG_16BIT_CHECKSUM \ -DCONFIG_GALOIS_MUL_LUT \ -DGETTEXT_PACKAGE='"pgm"' \ + -DPGM_GNUC_INTERNAL= \ ${libpgm_diff_flags} libzmq_la_CXXFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/ \ diff --git a/src/zmq.cpp b/src/zmq.cpp index 62e50cd..6a1d396 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -60,6 +60,10 @@ #include <pgm/pgm.h> #endif +#if defined __GNUC__ && __GNUC__ >= 4 && !defined ZMQ_HAVE_WINDOWS +#pragma GCC visibility push(default) +#endif + void zmq_version (int *major_, int *minor_, int *patch_) { *major_ = ZMQ_VERSION_MAJOR; @@ -725,3 +729,7 @@ unsigned long zmq_stopwatch_stop (void *watch_) return (unsigned long) (end - start); } +#if defined __GNUC__ && __GNUC__ >= 4 && !defined ZMQ_HAVE_WINDOWS +#pragma GCC visibility pop +#endif + |