From: Vadim Zeitlin Date: Sun, 23 Nov 2008 01:53:24 +0000 (+0000) Subject: don't use __thread keyword with g++ < 4 as it results in mysterious problems at link... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/eb6a8d695e5bdbd2ceeba9ba67d4216de2778715 don't use __thread keyword with g++ < 4 as it results in mysterious problems at link time related to thread-local static wxString::ms_cache git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/aclocal.m4 b/aclocal.m4 index 5e83ac5ba2..8e2f54a28a 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -15,6 +15,8 @@ m4_include([build/aclocal/ac_raf_func_which_getservbyname_r.m4]) m4_include([build/aclocal/atomic_builtins.m4]) m4_include([build/aclocal/ax_cflags_gcc_option.m4]) m4_include([build/aclocal/ax_func_which_gethostbyname_r.m4]) +m4_include([build/aclocal/ax_gcc_option.m4]) +m4_include([build/aclocal/ax_gxx_version.m4]) m4_include([build/aclocal/bakefile-dllar.m4]) m4_include([build/aclocal/bakefile-lang.m4]) m4_include([build/aclocal/bakefile.m4]) diff --git a/build/aclocal/ax_gcc_option.m4 b/build/aclocal/ax_gcc_option.m4 new file mode 100644 index 0000000000..a9869ff2c5 --- /dev/null +++ b/build/aclocal/ax_gcc_option.m4 @@ -0,0 +1,130 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_gcc_option.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_OPTION(OPTION,EXTRA-OPTIONS,TEST-PROGRAM,ACTION-IF-SUCCESSFUL,ACTION-IF-NOT-SUCCESFUL) +# +# DESCRIPTION +# +# AX_GCC_OPTION checks wheter gcc accepts the passed OPTION. If it accepts +# the OPTION then ACTION-IF-SUCCESSFUL will be executed, otherwise +# ACTION-IF-UNSUCCESSFUL. +# +# NOTE: This macro will be obsoleted by AX_C_CHECK_FLAG AX_CXX_CHECK_FLAG, +# AX_CPP_CHECK_FLAG, AX_CXXCPP_CHECK_FLAG and AX_LD_CHECK_FLAG. +# +# A typical usage should be the following one: +# +# AX_GCC_OPTION([-fomit-frame-pointer],[],[],[ +# AC_MSG_NOTICE([The option is supported])],[ +# AC_MSG_NOTICE([No luck this time]) +# ]) +# +# The macro doesn't discriminate between languages so, if you are testing +# for an option that works for C++ but not for C you should use '-x c++' +# as EXTRA-OPTIONS: +# +# AX_GCC_OPTION([-fno-rtti],[-x c++],[],[ ... ],[ ... ]) +# +# OPTION is tested against the following code: +# +# int main() +# { +# return 0; +# } +# +# The optional TEST-PROGRAM comes handy when the default main() is not +# suited for the option being checked +# +# So, if you need to test for -fstrict-prototypes option you should +# probably use the macro as follows: +# +# AX_GCC_OPTION([-fstrict-prototypes],[-x c++],[ +# int main(int argc, char ** argv) +# { +# (void) argc; +# (void) argv; +# +# return 0; +# } +# ],[ ... ],[ ... ]) +# +# Note that the macro compiles but doesn't link the test program so it is +# not suited for checking options that are passed to the linker, like: +# +# -Wl,-L +# +# In order to avoid such kind of problems you should think about usinguse +# the AX_*_CHECK_FLAG family macros +# +# LAST MODIFICATION +# +# 2008-04-12 +# +# COPYLEFT +# +# Copyright (c) 2008 Francesco Salvestrini +# Copyright (c) 2008 Bogdan Drozdowski +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Macro Archive. When you make and +# distribute a modified version of the Autoconf Macro, you may extend this +# special exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_GCC_OPTION], [ + AC_REQUIRE([AC_PROG_CC]) + + AC_MSG_CHECKING([if gcc accepts $1 option]) + + AS_IF([ test "x$GCC" = "xyes" ],[ + AS_IF([ test -z "$3" ],[ + ax_gcc_option_test="int main() +{ + return 0; +}" + ],[ + ax_gcc_option_test="$3" + ]) + + # Dump the test program to file + cat < conftest.c +$ax_gcc_option_test +EOF + + # Dump back the file to the log, useful for debugging purposes + AC_TRY_COMMAND(cat conftest.c 1>&AS_MESSAGE_LOG_FD) + + AS_IF([ AC_TRY_COMMAND($CC $2 $1 -c conftest.c 1>&AS_MESSAGE_LOG_FD) ],[ + AC_MSG_RESULT([yes]) + $4 + ],[ + AC_MSG_RESULT([no]) + $5 + ]) + ],[ + AC_MSG_RESULT([no gcc available]) + ]) +]) diff --git a/build/aclocal/ax_gxx_version.m4 b/build/aclocal/ax_gxx_version.m4 new file mode 100644 index 0000000000..4b1fdd0fd1 --- /dev/null +++ b/build/aclocal/ax_gxx_version.m4 @@ -0,0 +1,67 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_gxx_version.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GXX_VERSION +# +# DESCRIPTION +# +# This macro retrieves the g++ version and returns it in the GXX_VERSION +# variable if available, an empty string otherwise. +# +# LAST MODIFICATION +# +# 2008-04-12 +# +# COPYLEFT +# +# Copyright (c) 2008 Francesco Salvestrini +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Macro Archive. When you make and +# distribute a modified version of the Autoconf Macro, you may extend this +# special exception to the GPL to apply to your modified version as well. + +AC_DEFUN([AX_GXX_VERSION], [ + GXX_VERSION="" + AX_GCC_OPTION([-dumpversion],[],[],[ + ax_gcc_version_option=yes + ],[ + ax_gcc_version_option=no + ]) + AS_IF([test "x$GXX" = "xyes"],[ + AS_IF([test "x$ax_gxx_version_option" != "no"],[ + AC_CACHE_CHECK([gxx version],[ax_cv_gxx_version],[ + ax_cv_gxx_version="`$CXX -dumpversion`" + AS_IF([test "x$ax_cv_gxx_version" = "x"],[ + ax_cv_gxx_version="" + ]) + ]) + GXX_VERSION=$ax_cv_gxx_version + ]) + ]) + AC_SUBST([GXX_VERSION]) +]) diff --git a/configure b/configure index 4e7928750b..5f6f566b7f 100755 --- a/configure +++ b/configure @@ -701,6 +701,7 @@ PANGOXFT_LIBS CFLAGS_VISIBILITY CXXFLAGS_VISIBILITY LIBICONV +GXX_VERSION SDL_CONFIG SDL_CFLAGS SDL_LIBS @@ -40261,13 +40262,133 @@ echo "$as_me: WARNING: wxMutex won't be recursive on this platform" >&2;} fi fi - { echo "$as_me:$LINENO: checking for __thread keyword" >&5 + + GXX_VERSION="" + + + + { echo "$as_me:$LINENO: checking if gcc accepts -dumpversion option" >&5 +echo $ECHO_N "checking if gcc accepts -dumpversion option... $ECHO_C" >&6; } + + if test "x$GCC" = "xyes" ; then + + if test -z "" ; then + + ax_gcc_option_test="int main() +{ + return 0; +}" + +else + + ax_gcc_option_test="" + +fi + + + # Dump the test program to file + cat < conftest.c +$ax_gcc_option_test +EOF + + # Dump back the file to the log, useful for debugging purposes + { ac_try='cat conftest.c 1>&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } + + if { ac_try='$CC -dumpversion -c conftest.c 1>&5' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } ; then + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + + ax_gcc_version_option=yes + + +else + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + + ax_gcc_version_option=no + + +fi + + +else + + { echo "$as_me:$LINENO: result: no gcc available" >&5 +echo "${ECHO_T}no gcc available" >&6; } + +fi + + + if test "x$GXX" = "xyes"; then + + if test "x$ax_gxx_version_option" != "no"; then + + { echo "$as_me:$LINENO: checking gxx version" >&5 +echo $ECHO_N "checking gxx version... $ECHO_C" >&6; } +if test "${ax_cv_gxx_version+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + ax_cv_gxx_version="`$CXX -dumpversion`" + if test "x$ax_cv_gxx_version" = "x"; then + + ax_cv_gxx_version="" + +fi + + +fi +{ echo "$as_me:$LINENO: result: $ax_cv_gxx_version" >&5 +echo "${ECHO_T}$ax_cv_gxx_version" >&6; } + GXX_VERSION=$ax_cv_gxx_version + +fi + + +fi + + + + if test -n "$ax_cv_gxx_version"; then + { echo "$as_me:$LINENO: checking for __thread support in g++" >&5 +echo $ECHO_N "checking for __thread support in g++... $ECHO_C" >&6; } + case "$ax_cv_gxx_version" in + 1.* | 2.* ) + { echo "$as_me:$LINENO: result: doesn't exist" >&5 +echo "${ECHO_T}doesn't exist" >&6; } + wx_cv_cc___thread=no + ;; + 3.*) + { echo "$as_me:$LINENO: result: broken" >&5 +echo "${ECHO_T}broken" >&6; } + wx_cv_cc___thread=no + ;; + *) + { echo "$as_me:$LINENO: result: works" >&5 +echo "${ECHO_T}works" >&6; } + wx_cv_cc___thread=yes + ;; + esac + else + { echo "$as_me:$LINENO: checking for __thread keyword" >&5 echo $ECHO_N "checking for __thread keyword... $ECHO_C" >&6; } if test "${wx_cv_cc___thread+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else - cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext @@ -40278,8 +40399,8 @@ int main () { - static __thread int n = 0; - static __thread int *p = 0; + static __thread int n = 0; + static __thread int *p = 0; ; return 0; @@ -40316,6 +40437,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $wx_cv_cc___thread" >&5 echo "${ECHO_T}$wx_cv_cc___thread" >&6; } + fi if test "$wx_cv_cc___thread" = "yes"; then cat >>confdefs.h <<\_ACEOF @@ -51774,6 +51896,7 @@ PANGOXFT_LIBS!$PANGOXFT_LIBS$ac_delim CFLAGS_VISIBILITY!$CFLAGS_VISIBILITY$ac_delim CXXFLAGS_VISIBILITY!$CXXFLAGS_VISIBILITY$ac_delim LIBICONV!$LIBICONV$ac_delim +GXX_VERSION!$GXX_VERSION$ac_delim SDL_CONFIG!$SDL_CONFIG$ac_delim SDL_CFLAGS!$SDL_CFLAGS$ac_delim SDL_LIBS!$SDL_LIBS$ac_delim @@ -51785,7 +51908,6 @@ GNOMEVFS_CFLAGS!$GNOMEVFS_CFLAGS$ac_delim GNOMEVFS_LIBS!$GNOMEVFS_LIBS$ac_delim HILDON_CFLAGS!$HILDON_CFLAGS$ac_delim HILDON_LIBS!$HILDON_LIBS$ac_delim -CAIRO_CFLAGS!$CAIRO_CFLAGS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -51827,6 +51949,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +CAIRO_CFLAGS!$CAIRO_CFLAGS$ac_delim CAIRO_LIBS!$CAIRO_LIBS$ac_delim GST_CFLAGS!$GST_CFLAGS$ac_delim GST_LIBS!$GST_LIBS$ac_delim @@ -51923,7 +52046,6 @@ SETFILE!$SETFILE$ac_delim OBJCXXFLAGS!$OBJCXXFLAGS$ac_delim GCC_PCH!$GCC_PCH$ac_delim ICC_PCH!$ICC_PCH$ac_delim -ICC_PCH_CREATE_SWITCH!$ICC_PCH_CREATE_SWITCH$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -51965,6 +52087,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +ICC_PCH_CREATE_SWITCH!$ICC_PCH_CREATE_SWITCH$ac_delim ICC_PCH_USE_SWITCH!$ICC_PCH_USE_SWITCH$ac_delim BK_MAKE_PCH!$BK_MAKE_PCH$ac_delim COND_BUILD_DEBUG!$COND_BUILD_DEBUG$ac_delim @@ -52061,7 +52184,6 @@ COND_SHARED_0_USE_GUI_1_USE_OPENGL_1!$COND_SHARED_0_USE_GUI_1_USE_OPENGL_1$ac_de COND_SHARED_0_USE_GUI_1_wxUSE_LIBJPEG_builtin!$COND_SHARED_0_USE_GUI_1_wxUSE_LIBJPEG_builtin$ac_delim COND_SHARED_0_USE_GUI_1_wxUSE_LIBPNG_builtin!$COND_SHARED_0_USE_GUI_1_wxUSE_LIBPNG_builtin$ac_delim COND_SHARED_0_USE_GUI_1_wxUSE_LIBTIFF_builtin!$COND_SHARED_0_USE_GUI_1_wxUSE_LIBTIFF_builtin$ac_delim -COND_SHARED_0_USE_STC_1!$COND_SHARED_0_USE_STC_1$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -52103,6 +52225,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +COND_SHARED_0_USE_STC_1!$COND_SHARED_0_USE_STC_1$ac_delim COND_SHARED_0_wxUSE_EXPAT_builtin!$COND_SHARED_0_wxUSE_EXPAT_builtin$ac_delim COND_SHARED_0_wxUSE_REGEX_builtin!$COND_SHARED_0_wxUSE_REGEX_builtin$ac_delim COND_SHARED_0_wxUSE_ZLIB_builtin!$COND_SHARED_0_wxUSE_ZLIB_builtin$ac_delim @@ -52199,7 +52322,6 @@ WX_LIBRARY_BASENAME_GUI!$WX_LIBRARY_BASENAME_GUI$ac_delim USE_GUI!$USE_GUI$ac_delim AFMINSTALL!$AFMINSTALL$ac_delim WIN32INSTALL!$WIN32INSTALL$ac_delim -TOOLKIT!$TOOLKIT$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then @@ -52241,6 +52363,7 @@ _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF +TOOLKIT!$TOOLKIT$ac_delim TOOLKIT_DIR!$TOOLKIT_DIR$ac_delim TOOLCHAIN_NAME!$TOOLCHAIN_NAME$ac_delim TOOLCHAIN_FULLNAME!$TOOLCHAIN_FULLNAME$ac_delim @@ -52280,7 +52403,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` = 37; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 38; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 diff --git a/configure.in b/configure.in index ff46cc9b4d..ed22d24091 100644 --- a/configure.in +++ b/configure.in @@ -5000,18 +5000,40 @@ if test "$TOOLKIT" != "MSW" -a "$USE_OS2" != 1; then fi dnl test for compiler thread-specific variables support - AC_CACHE_CHECK([for __thread keyword], - wx_cv_cc___thread, - [ - AC_TRY_COMPILE([#include ], - [ - static __thread int n = 0; - static __thread int *p = 0; - ], - wx_cv_cc___thread=yes, - wx_cv_cc___thread=no - ) - ]) + AX_GXX_VERSION + if test -n "$ax_cv_gxx_version"; then + dnl g++ supports __thread since at least version 3.3 but its support + dnl seems to be broken until 4.1, see + dnl http://thread.gmane.org/gmane.comp.lib.wxwidgets.devel/108388 + AC_MSG_CHECKING([for __thread support in g++]) + case "$ax_cv_gxx_version" in + 1.* | 2.* ) + AC_MSG_RESULT([doesn't exist]) + wx_cv_cc___thread=no + ;; + 3.*) + AC_MSG_RESULT([broken]) + wx_cv_cc___thread=no + ;; + *) + AC_MSG_RESULT([works]) + wx_cv_cc___thread=yes + ;; + esac + else + AC_CACHE_CHECK([for __thread keyword], + wx_cv_cc___thread, + [ + AC_TRY_COMPILE([#include ], + [ + static __thread int n = 0; + static __thread int *p = 0; + ], + wx_cv_cc___thread=yes, + wx_cv_cc___thread=no + ) + ]) + fi if test "$wx_cv_cc___thread" = "yes"; then AC_DEFINE(HAVE___THREAD_KEYWORD)