From 0d9f7c7b8ad21044adff8ea296d44e151cfce657 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 23 Mar 2006 06:49:01 +0000 Subject: [PATCH] Added -fvisibility=hidden support, for builds by gcc4 and later. All the sordid reasons for this are laid out here: http://gcc.gnu.org/wiki/Visibility --- CHANGELOG | 1 + configure.in | 27 ++++++++++++++++++++++++--- physfs.h | 2 ++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4e8a42a..8657486 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -4,6 +4,7 @@ -- stuff in the stable-1.0 branch, backported from 2.0.0 dev branch, etc --- +03232006 - Added -fvisibility for gcc4 (http://gcc.gnu.org/wiki/Visibility) 01012006 - Added physfs.rc (thanks, Dennis!). Changed my email address. 11282005 - Whitespace fix, and corrected docs on PHYSFS_setWriteDir(). 09062005 - Happy September. Minor MingW fixes (but it's still broken, I think). diff --git a/configure.in b/configure.in index c082e60..adbc610 100644 --- a/configure.in +++ b/configure.in @@ -68,18 +68,39 @@ AC_ARG_ENABLE(debug, , enable_debug=no) if test x$enable_debug = xyes; then if test x$ac_cv_prog_cc_g = xyes; then - PHYSFSCFLAGS="-g -O0" + PHYSFSCFLAGS="$PHYSFSCFLAGS -g -O0" else - PHYSFSCFLAGS="-O0" + PHYSFSCFLAGS="$PHYSFSCFLAGS -O0" fi PHYSFSCFLAGS="$PHYSFSCFLAGS -Werror -Wall" AC_DEFINE([DEBUG], 1, [define if debug build is enabled]) AC_DEFINE([DEBUG_CHATTER], 1, [define if debug chatter is enabled]) else - PHYSFSCFLAGS="-O2" + PHYSFSCFLAGS="$PHYSFSCFLAGS -O2" AC_DEFINE([NDEBUG], 1, [define if debug build is disabled]) fi +dnl --------------------------------------------------------------------- +dnl Have GCC's -fvisibility option? +dnl --------------------------------------------------------------------- +AC_MSG_CHECKING(for GCC -fvisibility=hidden option) +have_gcc_fvisibility=no +visibility_CFLAGS="-fvisibility=hidden" +save_CFLAGS="$CFLAGS" +CFLAGS="$save_CFLAGS $visibility_CFLAGS" +AC_TRY_COMPILE([ +int placeholder = 1; +],[ +],[ +have_gcc_fvisibility=yes +]) +AC_MSG_RESULT($have_gcc_fvisibility) +CFLAGS="$save_CFLAGS" + +if test x$have_gcc_fvisibility = xyes; then + PHYSFSCFLAGS="$PHYSFSCFLAGS $visibility_CFLAGS" +fi + dnl --------------------------------------------------------------------- dnl Profile sorts, etc? diff --git a/physfs.h b/physfs.h index 12bb2e9..17ea4bb 100644 --- a/physfs.h +++ b/physfs.h @@ -153,6 +153,8 @@ extern "C" { #ifndef DOXYGEN_SHOULD_IGNORE_THIS #if (defined _MSC_VER) #define __EXPORT__ __declspec(dllexport) +#elif (defined __GNUC__) +#define __EXPORT__ __attribute__((visibility("default"))) #else #define __EXPORT__ #endif