]> git.saurik.com Git - wxWidgets.git/commitdiff
fix visibility problems with libstdc++ on Debian and Ubuntu
authorVáclav Slavík <vslavik@fastmail.fm>
Sun, 22 Jul 2007 09:20:42 +0000 (09:20 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sun, 22 Jul 2007 09:20:42 +0000 (09:20 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

build/aclocal/visibility.m4
configure
include/wx/afterstd.h
include/wx/beforestd.h
include/wx/ioswrap.h
setup.h.in

index 49ae7bb9e24644a6077f9632e39d7696837d2023..35a9ea02414f52ea41741b894cb3227ab40d09b6 100644 (file)
@@ -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 <string>
+          ],
+          [
+            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=""
index de2c0c5e16c083e51d4543ff8b7d5593e48f8c4b..a00bc3b49c74bdad4556be05047b6e21ffe79102 100755 (executable)
--- 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 <string>
+
+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=""
index 6fdbb315b320f905f806798861cfadb800fbd7be..d57412d7e2febd3efece298ebafd03ec3f02c2ed 100644 (file)
@@ -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
index 684b8428c38f018ec73baa842b2b08f2e38fdbce..5bf6377113674fdb03a8bf811a943fa5bb9a8cc6 100644 (file)
     #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
index 6fe41e556bfd20e70a3fe736a9572578349d944b..72dee5bbaaca7107389c101f691049dd83466bed 100644 (file)
 
 #if wxUSE_STD_IOSTREAM
 
+#include "wx/beforestd.h"
+
 #if wxUSE_IOSTREAMH
 #   include <iostream.h>
 #else
 #   include <iostream>
 #endif
 
+#include "wx/afterstd.h"
+
 #ifdef __WXMSW__
 #   include "wx/msw/winundef.h"
 #endif
index 97926023d818f52ce7f0c51650624bce76fe1007..264fc58d6f3eae00d26c90bc7e071418452fac8e 100644 (file)
  */
 #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