]> git.saurik.com Git - wxWidgets.git/blobdiff - build/aclocal/visibility.m4
remove unneeded includes and forward declaration
[wxWidgets.git] / build / aclocal / visibility.m4
index 9ee33576dcceb16774aa9576e7928e1f672b0329..05f9b80dece0957dcc582245299ab444e2880c2d 100644 (file)
@@ -49,6 +49,11 @@ AC_DEFUN([WX_VISIBILITY],
          error this platform has no visibility;
          #endif
 
          error this platform has no visibility;
          #endif
 
+         /* at the time of Xcode 4.1 / Clang 3, Clang++ still didn't have the bugs sorted out: */
+         #if defined(__clang__)
+         clang compiler is still broken w.r.t. visibility;
+         #endif
+
          extern __attribute__((__visibility__("hidden"))) int hiddenvar;
          extern __attribute__((__visibility__("default"))) int exportedvar;
          extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
          extern __attribute__((__visibility__("hidden"))) int hiddenvar;
          extern __attribute__((__visibility__("default"))) int exportedvar;
          extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
@@ -64,8 +69,8 @@ AC_DEFUN([WX_VISIBILITY],
       CXXFLAGS="$wx_save_CXXFLAGS"])
     AC_MSG_RESULT([$wx_cv_cc_visibility])
     if test $wx_cv_cc_visibility = yes; then
       CXXFLAGS="$wx_save_CXXFLAGS"])
     AC_MSG_RESULT([$wx_cv_cc_visibility])
     if test $wx_cv_cc_visibility = yes; then
-      AC_DEFINE([HAVE_VISIBILITY])
-
+      dnl we do have basic visibility support, now check if we can use it:
+      dnl
       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])
       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])
@@ -89,10 +94,39 @@ AC_DEFUN([WX_VISIBILITY],
         CXXFLAGS="$wx_save_CXXFLAGS"
         LDFLAGS="$wx_save_LDFLAGS"])
       AC_MSG_RESULT([$wx_cv_cc_broken_libstdcxx_visibility])
         CXXFLAGS="$wx_save_CXXFLAGS"
         LDFLAGS="$wx_save_LDFLAGS"])
       AC_MSG_RESULT([$wx_cv_cc_broken_libstdcxx_visibility])
+
       if test $wx_cv_cc_broken_libstdcxx_visibility = yes; then
       if test $wx_cv_cc_broken_libstdcxx_visibility = yes; then
-        AC_DEFINE([HAVE_BROKEN_LIBSTDCXX_VISIBILITY])
+        AC_MSG_CHECKING([whether we can work around it])
+        AC_CACHE_VAL(wx_cv_cc_visibility_workaround, [
+          AC_LANG_PUSH(C++)
+          AC_TRY_LINK(
+            [
+              #pragma GCC visibility push(default)
+              #include <string>
+              #pragma GCC visibility pop
+            ],
+            [
+              std::string s("hello");
+              return s.length();
+            ],
+            wx_cv_cc_visibility_workaround=no,
+            wx_cv_cc_visibility_workaround=yes)
+          AC_LANG_POP()
+        ])
+        AC_MSG_RESULT([$wx_cv_cc_visibility_workaround])
+
+        if test $wx_cv_cc_visibility_workaround = no; then
+          dnl we can't use visibility at all then
+          wx_cv_cc_visibility=no
+        fi
       fi
       fi
+    fi
 
 
+    if test $wx_cv_cc_visibility = yes; then
+      AC_DEFINE([HAVE_VISIBILITY])
+      if test $wx_cv_cc_broken_libstdcxx_visibility = yes; then
+        AC_DEFINE([HAVE_BROKEN_LIBSTDCXX_VISIBILITY])
+      fi
     else
       CFLAGS_VISIBILITY=""
       CXXFLAGS_VISIBILITY=""
     else
       CFLAGS_VISIBILITY=""
       CXXFLAGS_VISIBILITY=""