Apply patch, then run autoconf and autoheader. diff -ur Python-2.4.1/configure.in Python-2.4.1.visibility/configure.in --- Python-2.4.1/configure.in 2005-03-29 07:23:34.000000000 +0800 +++ Python-2.4.1.visibility/configure.in 2005-04-29 10:33:40.000000000 +0800 @@ -3106,6 +3106,76 @@ #endif ]) +# Check for ELF symbol visibility support + +# GLIB_CHECK_COMPILE_WARNINGS(PROGRAM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])# --------------------------------------------------------------------- +# Try to compile PROGRAM, check for warnings +m4_define([GLIB_CHECK_COMPILE_WARNINGS], +[m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl +rm -f conftest.$ac_objext +glib_ac_compile_save="$ac_compile" +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext' +AS_IF([_AC_EVAL_STDERR($ac_compile) && + AC_TRY_COMMAND([(if test -s conftest.err; then false ; else true; fi)])], + [$2], + [echo "$as_me: failed program was:" >&AS_MESSAGE_LOG_FD +cat conftest.$ac_ext >&AS_MESSAGE_LOG_FD +m4_ifvaln([$3],[$3])dnl])dnl +ac_compile="$glib_ac_compile_save" +rm -f conftest.$ac_objext conftest.err m4_ifval([$1], [conftest.$ac_ext])[]dnl +])# GLIB_CHECK_COMPILE_WARNINGS + +AC_MSG_CHECKING(for GNUC visibility attribute) +GLIB_CHECK_COMPILE_WARNINGS([ +void +__attribute__ ((visibility ("hidden"))) + f_hidden (void) +{ +} +void +__attribute__ ((visibility ("internal"))) + f_internal (void) +{ +} +void +__attribute__ ((visibility ("protected"))) + f_protected (void) +{ +} +void +__attribute__ ((visibility ("default"))) + f_default (void) +{ +} +int main (int argc, char **argv) +{ + f_hidden(); + f_internal(); + f_protected(); + f_default(); + return 0; +} +],g_have_gnuc_visibility=yes,g_have_gnuc_visibility=no) +AC_MSG_RESULT($g_have_gnuc_visibility) +if test x$g_have_gnuc_visibility = xyes; then + AC_DEFINE(HAVE_GNUC_VISIBILITY, 1, [supports GCC visibility attributes]) +fi + +AC_MSG_CHECKING(whether $CC accepts -fvisibility=hidden) +AC_CACHE_VAL(ac_cv_fvisibility_ok, +[ac_save_cc="$CC" +CC="$CC -fvisibility=hidden" +AC_TRY_RUN([int main() { return 0; }], + ac_cv_fvisibility_ok=yes, + ac_cv_fvisibility_ok=no, + ac_cv_fvisibility_ok=no) +CC="$ac_save_cc"]) +AC_MSG_RESULT($ac_cv_fvisibility_ok) +if test $ac_cv_fvisibility_ok = yes; then + BASECFLAGS="$BASECFLAGS -fvisibility=hidden" +fi + + AC_SUBST(THREADHEADERS) for h in `(cd $srcdir;echo Python/thread_*.h)` diff -ur Python-2.4.1/Include/pyport.h Python-2.4.1.visibility/Include/pyport.h --- Python-2.4.1/Include/pyport.h 2004-09-24 03:11:21.000000000 +0800 +++ Python-2.4.1.visibility/Include/pyport.h 2005-04-29 14:33:49.696637736 +0800 @@ -514,6 +514,20 @@ # endif /* HAVE_DECLSPEC */ #endif /* Py_ENABLE_SHARED */ +#ifdef HAVE_GNUC_VISIBILITY +# ifdef Py_BUILD_CORE +# define PyAPI_FUNC(RTYPE) __attribute__((visibility("protected"))) RTYPE +# define PyAPI_DATA(RTYPE) extern __attribute__((visibility("protected"))) RTYPE +# define PyMODINIT_FUNC void +# else /* Py_BUILD_CORE */ +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" void __attribute__((visibility("default"))) +# else /* __cplusplus */ +# define PyMODINIT_FUNC void __attribute__((visibility("default"))) +# endif +# endif +#endif /* HAVE_GNUC_VISIBILITY */ + /* If no external linkage macros defined by now, create defaults */ #ifndef PyAPI_FUNC # define PyAPI_FUNC(RTYPE) RTYPE diff -ur Python-2.4.1/Modules/cjkcodecs/cjkcodecs.h Python-2.4.1.visibility/Modules/cjkcodecs/cjkcodecs.h --- Python-2.4.1/Modules/cjkcodecs/cjkcodecs.h 2004-08-20 01:49:56.000000000 +0800 +++ Python-2.4.1.visibility/Modules/cjkcodecs/cjkcodecs.h 2005-04-29 11:05:51.000000000 +0800 @@ -381,7 +381,7 @@ #endif #define I_AM_A_MODULE_FOR(loc) \ - void \ + PyMODINIT_FUNC \ init_codecs_##loc(void) \ { \ PyObject *m = Py_InitModule("_codecs_" #loc, __methods);\ diff -ur Python-2.4.1/Modules/cjkcodecs/multibytecodec.c Python-2.4.1.visibility/Modules/cjkcodecs/multibytecodec.c --- Python-2.4.1/Modules/cjkcodecs/multibytecodec.c 2004-08-20 01:49:56.000000000 +0800 +++ Python-2.4.1.visibility/Modules/cjkcodecs/multibytecodec.c 2005-04-29 11:07:01.000000000 +0800 @@ -1262,7 +1262,7 @@ {NULL, NULL}, }; -void +PyMODINIT_FUNC init_multibytecodec(void) { Py_InitModule("_multibytecodec", __methods); diff -ur Python-2.4.1/Modules/_hotshot.c Python-2.4.1.visibility/Modules/_hotshot.c --- Python-2.4.1/Modules/_hotshot.c 2004-08-03 16:33:55.000000000 +0800 +++ Python-2.4.1.visibility/Modules/_hotshot.c 2005-04-29 11:04:17.000000000 +0800 @@ -1627,7 +1627,7 @@ }; -void +PyMODINIT_FUNC init_hotshot(void) { PyObject *module; diff -ur Python-2.4.1/Modules/linuxaudiodev.c Python-2.4.1.visibility/Modules/linuxaudiodev.c --- Python-2.4.1/Modules/linuxaudiodev.c 2002-11-28 06:19:15.000000000 +0800 +++ Python-2.4.1.visibility/Modules/linuxaudiodev.c 2005-04-29 11:04:39.000000000 +0800 @@ -485,7 +485,7 @@ { 0, 0 }, }; -void +PyMODINIT_FUNC initlinuxaudiodev(void) { PyObject *m; diff -ur Python-2.4.1/Modules/nismodule.c Python-2.4.1.visibility/Modules/nismodule.c --- Python-2.4.1/Modules/nismodule.c 2004-07-10 08:57:37.000000000 +0800 +++ Python-2.4.1.visibility/Modules/nismodule.c 2005-04-29 11:04:57.000000000 +0800 @@ -374,7 +374,7 @@ {NULL, NULL} /* Sentinel */ }; -void +PyMODINIT_FUNC initnis (void) { PyObject *m, *d; diff -ur Python-2.4.1/Modules/ossaudiodev.c Python-2.4.1.visibility/Modules/ossaudiodev.c --- Python-2.4.1/Modules/ossaudiodev.c 2005-03-09 08:55:18.000000000 +0800 +++ Python-2.4.1.visibility/Modules/ossaudiodev.c 2005-04-29 11:05:11.000000000 +0800 @@ -929,7 +929,7 @@ } -void +PyMODINIT_FUNC initossaudiodev(void) { PyObject *m;