added GCC visibility support

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47255 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-07-09 10:12:51 +00:00
parent b5dbe15d0b
commit 0ff20b9f00
9 changed files with 249 additions and 33 deletions

9
aclocal.m4 vendored
View File

@@ -1,7 +1,7 @@
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# generated automatically by aclocal 1.10 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# 2005, 2006 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -11,6 +11,8 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_include([build/aclocal/ac_raf_func_which_getservbyname_r.m4])
m4_include([build/aclocal/ax_func_which_gethostbyname_r.m4])
m4_include([build/aclocal/bakefile-dllar.m4])
m4_include([build/aclocal/bakefile-lang.m4])
m4_include([build/aclocal/bakefile.m4])
@@ -19,6 +21,5 @@ m4_include([build/aclocal/gtk-2.0.m4])
m4_include([build/aclocal/gtk.m4])
m4_include([build/aclocal/pkg.m4])
m4_include([build/aclocal/sdl.m4])
m4_include([build/aclocal/ax_func_which_gethostbyname_r.m4])
m4_include([build/aclocal/ac_raf_func_which_getservbyname_r.m4])
m4_include([build/aclocal/visibility.m4])
m4_include([acinclude.m4])

View File

@@ -0,0 +1,70 @@
dnl visibility.m4 serial 1 (gettext-0.15)
dnl Copyright (C) 2005 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl Modified for use in wxWidgets by Vaclav Slavik:
dnl - don't define HAVE_VISIBILITY (=0) if not supported
dnl - use -fvisibility-inlines-hidden too
dnl - test in C++ mode
dnl Tests whether the compiler supports the command-line option
dnl -fvisibility=hidden and the function and variable attributes
dnl __attribute__((__visibility__("hidden"))) and
dnl __attribute__((__visibility__("default"))).
dnl Does *not* test for __visibility__("protected") - which has tricky
dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
dnl MacOS X.
dnl Does *not* test for __visibility__("internal") - which has processor
dnl dependent semantics.
dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
dnl "really only recommended for legacy code".
dnl Set the variable CFLAG_VISIBILITY.
dnl Defines and sets the variable HAVE_VISIBILITY.
AC_DEFUN([WX_VISIBILITY],
[
AC_REQUIRE([AC_PROG_CC])
if test -n "$GCC"; then
CFLAGS_VISIBILITY="-fvisibility=hidden"
CXXFLAGS_VISIBILITY="-fvisibility=hidden -fvisibility-inlines-hidden"
AC_MSG_CHECKING([for symbols visibility support])
AC_CACHE_VAL(wx_cv_cc_visibility, [
wx_save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY"
AC_LANG_PUSH(C++)
AC_TRY_COMPILE(
[
/* we need gcc >= 4.0, older versions with visibility support
didn't have class visibility: */
#if defined(__GNUC__) && __GNUC__ < 4
error this gcc is too old;
#endif
extern __attribute__((__visibility__("hidden"))) int hiddenvar;
extern __attribute__((__visibility__("default"))) int exportedvar;
extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
extern __attribute__((__visibility__("default"))) int exportedfunc (void);
class __attribute__((__visibility__("default"))) Foo {
Foo() {}
};
],
[],
wx_cv_cc_visibility=yes,
wx_cv_cc_visibility=no)
AC_LANG_POP()
CXXFLAGS="$wx_save_CXXFLAGS"])
AC_MSG_RESULT([$wx_cv_cc_visibility])
if test $wx_cv_cc_visibility = yes; then
AC_DEFINE([HAVE_VISIBILITY])
else
CFLAGS_VISIBILITY=""
CXXFLAGS_VISIBILITY=""
fi
AC_SUBST([CFLAGS_VISIBILITY])
AC_SUBST([CXXFLAGS_VISIBILITY])
fi
])

View File

@@ -58,7 +58,8 @@ ACLOCAL_SOURCES = \
build/aclocal/gtk-2.0.m4 \
build/aclocal/gtk.m4 \
build/aclocal/pkg.m4 \
build/aclocal/sdl.m4
build/aclocal/sdl.m4 \
build/aclocal/visibility.m4
# Run aclocal whenever acinclude or one of our local m4s is updated.
aclocal.m4: configure.in acinclude.m4 $(ACLOCAL_SOURCES)

126
configure vendored
View File

@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Id: configure.in 46713 2007-06-26 20:44:58Z VS .
# From configure.in Id: configure.in 47230 2007-07-08 07:04:38Z VS .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for wxWidgets 2.9.0.
#
@@ -707,6 +707,8 @@ PANGOFT2_CFLAGS
PANGOFT2_LIBS
PANGOXFT_CFLAGS
PANGOXFT_LIBS
CFLAGS_VISIBILITY
CXXFLAGS_VISIBILITY
REZ
DEREZ
SETFILE
@@ -33096,6 +33098,105 @@ echo "${ECHO_T}$wx_cv_version_script" >&6; }
esac
if test -n "$GCC"; then
CFLAGS_VISIBILITY="-fvisibility=hidden"
CXXFLAGS_VISIBILITY="-fvisibility=hidden -fvisibility-inlines-hidden"
{ echo "$as_me:$LINENO: checking for symbols visibility support" >&5
echo $ECHO_N "checking for symbols visibility support... $ECHO_C" >&6; }
if test "${wx_cv_cc_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. */
/* we need gcc >= 4.0, older versions with visibility support
didn't have class visibility: */
#if defined(__GNUC__) && __GNUC__ < 4
error this gcc is too old;
#endif
extern __attribute__((__visibility__("hidden"))) int hiddenvar;
extern __attribute__((__visibility__("default"))) int exportedvar;
extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
extern __attribute__((__visibility__("default"))) int exportedfunc (void);
class __attribute__((__visibility__("default"))) Foo {
Foo() {}
};
int
main ()
{
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (ac_try="$ac_compile"
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_compile") 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_objext; then
wx_cv_cc_visibility=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
wx_cv_cc_visibility=no
fi
rm -f core conftest.err conftest.$ac_objext 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_visibility" >&5
echo "${ECHO_T}$wx_cv_cc_visibility" >&6; }
if test $wx_cv_cc_visibility = yes; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_VISIBILITY 1
_ACEOF
else
CFLAGS_VISIBILITY=""
CXXFLAGS_VISIBILITY=""
fi
fi
if test "x$SUNCXX" = xyes; then
SAMPLES_RPATH_FLAG="-R\$(wx_top_builddir)/lib"
WXCONFIG_RPATH="-R\$libdir"
@@ -49482,6 +49583,9 @@ case "${host}" in
;;
esac
CFLAGS="$CFLAGS $CFLAGS_VISIBILITY"
CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY"
SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq | tr '\n' ' '| tr -d '\r'`"
@@ -50511,12 +50615,12 @@ PANGOFT2_CFLAGS!$PANGOFT2_CFLAGS$ac_delim
PANGOFT2_LIBS!$PANGOFT2_LIBS$ac_delim
PANGOXFT_CFLAGS!$PANGOXFT_CFLAGS$ac_delim
PANGOXFT_LIBS!$PANGOXFT_LIBS$ac_delim
CFLAGS_VISIBILITY!$CFLAGS_VISIBILITY$ac_delim
CXXFLAGS_VISIBILITY!$CXXFLAGS_VISIBILITY$ac_delim
REZ!$REZ$ac_delim
DEREZ!$DEREZ$ac_delim
SETFILE!$SETFILE$ac_delim
LIBICONV!$LIBICONV$ac_delim
SDL_CONFIG!$SDL_CONFIG$ac_delim
SDL_CFLAGS!$SDL_CFLAGS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -50558,6 +50662,8 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
SDL_CONFIG!$SDL_CONFIG$ac_delim
SDL_CFLAGS!$SDL_CFLAGS$ac_delim
SDL_LIBS!$SDL_LIBS$ac_delim
LIBGNOMEPRINTUI_CFLAGS!$LIBGNOMEPRINTUI_CFLAGS$ac_delim
LIBGNOMEPRINTUI_LIBS!$LIBGNOMEPRINTUI_LIBS$ac_delim
@@ -50653,8 +50759,6 @@ COND_BUILD_DEBUG!$COND_BUILD_DEBUG$ac_delim
COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT!$COND_BUILD_DEBUG_DEBUG_FLAG_DEFAULT$ac_delim
COND_BUILD_DEBUG_DEBUG_INFO_DEFAULT!$COND_BUILD_DEBUG_DEBUG_INFO_DEFAULT$ac_delim
COND_BUILD_DEBUG_UNICODE_0!$COND_BUILD_DEBUG_UNICODE_0$ac_delim
COND_BUILD_DEBUG_UNICODE_1!$COND_BUILD_DEBUG_UNICODE_1$ac_delim
COND_BUILD_RELEASE!$COND_BUILD_RELEASE$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -50696,6 +50800,8 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
COND_BUILD_DEBUG_UNICODE_1!$COND_BUILD_DEBUG_UNICODE_1$ac_delim
COND_BUILD_RELEASE!$COND_BUILD_RELEASE$ac_delim
COND_BUILD_RELEASE_DEBUG_INFO_DEFAULT!$COND_BUILD_RELEASE_DEBUG_INFO_DEFAULT$ac_delim
COND_BUILD_RELEASE_UNICODE_0!$COND_BUILD_RELEASE_UNICODE_0$ac_delim
COND_BUILD_RELEASE_UNICODE_1!$COND_BUILD_RELEASE_UNICODE_1$ac_delim
@@ -50791,8 +50897,6 @@ COND_TOOLKIT_!$COND_TOOLKIT_$ac_delim
COND_TOOLKIT_COCOA!$COND_TOOLKIT_COCOA$ac_delim
COND_TOOLKIT_COCOA_USE_GUI_1!$COND_TOOLKIT_COCOA_USE_GUI_1$ac_delim
COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0!$COND_TOOLKIT_COCOA_USE_GUI_1_WXUNIV_0$ac_delim
COND_TOOLKIT_DFB!$COND_TOOLKIT_DFB$ac_delim
COND_TOOLKIT_DFB_USE_GUI_1!$COND_TOOLKIT_DFB_USE_GUI_1$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -50834,6 +50938,8 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
COND_TOOLKIT_DFB!$COND_TOOLKIT_DFB$ac_delim
COND_TOOLKIT_DFB_USE_GUI_1!$COND_TOOLKIT_DFB_USE_GUI_1$ac_delim
COND_TOOLKIT_GTK!$COND_TOOLKIT_GTK$ac_delim
COND_TOOLKIT_GTK_TOOLKIT_VERSION_!$COND_TOOLKIT_GTK_TOOLKIT_VERSION_$ac_delim
COND_TOOLKIT_GTK_TOOLKIT_VERSION_2!$COND_TOOLKIT_GTK_TOOLKIT_VERSION_2$ac_delim
@@ -50929,8 +51035,6 @@ GUIDIST!$GUIDIST$ac_delim
DISTDIR!$DISTDIR$ac_delim
SAMPLES_SUBDIRS!$SAMPLES_SUBDIRS$ac_delim
LDFLAGS_GL!$LDFLAGS_GL$ac_delim
OPENGL_LIBS!$OPENGL_LIBS$ac_delim
DMALLOC_LIBS!$DMALLOC_LIBS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -50972,6 +51076,8 @@ _ACEOF
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
cat >conf$$subs.sed <<_ACEOF
OPENGL_LIBS!$OPENGL_LIBS$ac_delim
DMALLOC_LIBS!$DMALLOC_LIBS$ac_delim
WX_VERSION_TAG!$WX_VERSION_TAG$ac_delim
RESCOMP!$RESCOMP$ac_delim
RESFLAGS!$RESFLAGS$ac_delim
@@ -50987,7 +51093,7 @@ LIBOBJS!$LIBOBJS$ac_delim
LTLIBOBJS!$LTLIBOBJS$ac_delim
_ACEOF
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 13; then
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 15; then
break
elif $ac_last_try; then
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5

View File

@@ -4127,6 +4127,10 @@ if test "$wxUSE_SHARED" = "yes"; then
dnl use versioned symbols if available on the platform
WX_VERSIONED_SYMBOLS([\$(wx_top_builddir)/version-script])
dnl test for GCC's visibility support (sets CFLAGS_VISIBILITY, which is
dnl assigned to CFLAGS and CXXFLAGS below)
WX_VISIBILITY
dnl test for Sun CC which can be used under both Solaris and Linux
if test "x$SUNCXX" = xyes; then
SAMPLES_RPATH_FLAG="-R\$(wx_top_builddir)/lib"
@@ -8075,6 +8079,11 @@ case "${host}" in
;;
esac
dnl Add visibility support flags to CFLAGS/CXXFLAGS - do it this late so that
dnl it doesn't affect compilation checks above
CFLAGS="$CFLAGS $CFLAGS_VISIBILITY"
CXXFLAGS="$CXXFLAGS $CXXFLAGS_VISIBILITY"
dnl for convenience, sort the samples in alphabetical order
dnl
dnl FIXME For some mysterious reasons, sometimes the directories are duplicated

View File

@@ -16,7 +16,7 @@
#ifndef _WX_DLIMPEXP_H_
#define _WX_DLIMPEXP_H_
#if defined(__WXMSW__)
#if defined(__WINDOWS__)
/*
__declspec works in BC++ 5 and later, Watcom C++ 11.0 and later as well
as VC++ and gcc
@@ -51,6 +51,9 @@
#elif defined(__CYGWIN__)
# define WXEXPORT __declspec(dllexport)
# define WXIMPORT __declspec(dllimport)
#elif defined(HAVE_VISIBILITY)
# define WXEXPORT __attribute__ ((visibility("default")))
# define WXIMPORT
#endif
/* for other platforms/compilers we don't anything */
@@ -240,6 +243,23 @@
/* GCC warns about using __attribute__ on forward declarations, so we need
another set of macros for them: */
#if defined(HAVE_VISIBILITY)
#define WXDLLIMPEXP_FWD_BASE
#define WXDLLIMPEXP_FWD_NET
#define WXDLLIMPEXP_FWD_CORE
#define WXDLLIMPEXP_FWD_ADV
#define WXDLLIMPEXP_FWD_QA
#define WXDLLIMPEXP_FWD_ODBC
#define WXDLLIMPEXP_FWD_DBGRID
#define WXDLLIMPEXP_FWD_HTML
#define WXDLLIMPEXP_FWD_GL
#define WXDLLIMPEXP_FWD_XML
#define WXDLLIMPEXP_FWD_XRC
#define WXDLLIMPEXP_FWD_AUI
#define WXDLLIMPEXP_FWD_RICHTEXT
#define WXDLLIMPEXP_FWD_MEDIA
#define WXDLLIMPEXP_FWD_STC
#else
#define WXDLLIMPEXP_FWD_BASE WXDLLIMPEXP_BASE
#define WXDLLIMPEXP_FWD_NET WXDLLIMPEXP_NET
#define WXDLLIMPEXP_FWD_CORE WXDLLIMPEXP_CORE
@@ -255,6 +275,7 @@
#define WXDLLIMPEXP_FWD_RICHTEXT WXDLLIMPEXP_RICHTEXT
#define WXDLLIMPEXP_FWD_MEDIA WXDLLIMPEXP_MEDIA
#define WXDLLIMPEXP_FWD_STC WXDLLIMPEXP_STC
#endif
/* for backwards compatibility, define suffix-less versions too */
#define WXDLLEXPORT WXDLLIMPEXP_CORE

View File

@@ -633,6 +633,11 @@
*/
#undef HAVE_GNU_CXX_HASH_MAP
/*
* Define if the compiler supports simple visibility declarations.
*/
#undef HAVE_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

View File

@@ -676,6 +676,11 @@ typedef pid_t GPid;
*/
#undef HAVE_GNU_CXX_HASH_MAP
/*
* Define if the compiler supports simple visibility declarations.
*/
#undef HAVE_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

View File

@@ -14,7 +14,6 @@
#
# # public symbols added in release 2.6.2 (please keep in alphabetical order):
# @WX_VERSION_TAG@.2 {
# global:
# *wxChoice*GetCurrentSelection*;
# };
#
@@ -28,6 +27,5 @@
# generic branch tag (don't remove this!):
@WX_VERSION_TAG@ {
global:
*;
};