From d6f513f829d7060a7f4adada4e023b3f1ac3d29c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 22 Jul 2007 09:20:42 +0000 Subject: [PATCH 1/1] fix visibility problems with libstdc++ on Debian and Ubuntu git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/aclocal/visibility.m4 | 24 +++++++++++ configure | 80 +++++++++++++++++++++++++++++++++++++ include/wx/afterstd.h | 4 ++ include/wx/beforestd.h | 10 +++++ include/wx/ioswrap.h | 4 ++ setup.h.in | 5 +++ 6 files changed, 127 insertions(+) diff --git a/build/aclocal/visibility.m4 b/build/aclocal/visibility.m4 index 49ae7bb9e2..35a9ea0241 100644 --- a/build/aclocal/visibility.m4 +++ b/build/aclocal/visibility.m4 @@ -60,6 +60,30 @@ AC_DEFUN([WX_VISIBILITY], AC_MSG_RESULT([$wx_cv_cc_visibility]) if test $wx_cv_cc_visibility = yes; then AC_DEFINE([HAVE_VISIBILITY]) + + dnl Debian/Ubuntu's gcc 4.1 is affected: + dnl https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/109262 + AC_MSG_CHECKING([for broken libstdc++ visibility]) + AC_CACHE_VAL(wx_cv_cc_broken_libstdcxx_visibility, [ + wx_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY" + AC_LANG_PUSH(C++) + AC_TRY_LINK( + [ + #include + ], + [ + std::string x; + ], + wx_cv_cc_broken_libstdcxx_visibility=no, + wx_cv_cc_broken_libstdcxx_visibility=yes) + AC_LANG_POP() + CXXFLAGS="$wx_save_CXXFLAGS"]) + AC_MSG_RESULT([$wx_cv_cc_broken_libstdcxx_visibility]) + if test $wx_cv_cc_broken_libstdcxx_visibility = yes; then + AC_DEFINE([HAVE_BROKEN_LIBSTDCXX_VISIBILITY]) + fi + else CFLAGS_VISIBILITY="" CXXFLAGS_VISIBILITY="" diff --git a/configure b/configure index de2c0c5e16..a00bc3b49c 100755 --- a/configure +++ b/configure @@ -35919,6 +35919,86 @@ echo "${ECHO_T}$wx_cv_cc_visibility" >&6; } #define HAVE_VISIBILITY 1 _ACEOF + + { echo "$as_me:$LINENO: checking for broken libstdc++ visibility" >&5 +echo $ECHO_N "checking for broken libstdc++ visibility... $ECHO_C" >&6; } + if test "${wx_cv_cc_broken_libstdcxx_visibility+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + wx_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY" + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + +int +main () +{ + + std::string x; + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + wx_cv_cc_broken_libstdcxx_visibility=no +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + wx_cv_cc_broken_libstdcxx_visibility=yes +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + CXXFLAGS="$wx_save_CXXFLAGS" +fi + + { echo "$as_me:$LINENO: result: $wx_cv_cc_broken_libstdcxx_visibility" >&5 +echo "${ECHO_T}$wx_cv_cc_broken_libstdcxx_visibility" >&6; } + if test $wx_cv_cc_broken_libstdcxx_visibility = yes; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_BROKEN_LIBSTDCXX_VISIBILITY 1 +_ACEOF + + fi + else CFLAGS_VISIBILITY="" CXXFLAGS_VISIBILITY="" diff --git a/include/wx/afterstd.h b/include/wx/afterstd.h index 6fdbb315b3..d57412d7e2 100644 --- a/include/wx/afterstd.h +++ b/include/wx/afterstd.h @@ -46,3 +46,7 @@ #endif #endif +// see beforestd.h for explanation +#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY) + #pragma GCC visibility pop +#endif diff --git a/include/wx/beforestd.h b/include/wx/beforestd.h index 684b8428c3..5bf6377113 100644 --- a/include/wx/beforestd.h +++ b/include/wx/beforestd.h @@ -63,3 +63,13 @@ #pragma warning(disable:4786) #endif // VC++ < 7 +/** + GCC's visibility support is broken for libstdc++ in some older versions + (namely Debian/Ubuntu's GCC 4.1, see + https://bugs.launchpad.net/ubuntu/+source/gcc-4.1/+bug/109262). We fix it + here by mimicking newer versions' behaviour of using default visibility + for libstdc++ code. + */ +#if defined(HAVE_VISIBILITY) && defined(HAVE_BROKEN_LIBSTDCXX_VISIBILITY) + #pragma GCC visibility push(default) +#endif diff --git a/include/wx/ioswrap.h b/include/wx/ioswrap.h index 6fe41e556b..72dee5bbaa 100644 --- a/include/wx/ioswrap.h +++ b/include/wx/ioswrap.h @@ -11,12 +11,16 @@ #if wxUSE_STD_IOSTREAM +#include "wx/beforestd.h" + #if wxUSE_IOSTREAMH # include #else # include #endif +#include "wx/afterstd.h" + #ifdef __WXMSW__ # include "wx/msw/winundef.h" #endif diff --git a/setup.h.in b/setup.h.in index 97926023d8..264fc58d6f 100644 --- a/setup.h.in +++ b/setup.h.in @@ -673,6 +673,11 @@ */ #undef HAVE_VISIBILITY +/* + * Define if compiler's visibility support in libstdc++ is broken + */ +#undef HAVE_BROKEN_LIBSTDCXX_VISIBILITY + /* * The built-in regex supports advanced REs in additional to POSIX's basic * and extended. Your system regex probably won't support this, and in this -- 2.45.2