diff options
author | Richard Mudgett <rmudgett@digium.com> | 2011-12-19 21:43:19 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2011-12-19 21:43:19 +0000 |
commit | 38e4643cb4beadc0bd61b2ac560da32101cff8a5 (patch) | |
tree | 833d87372da2e0c9d2da86b0426299d5cb201cc6 | |
parent | eb37d38b7dbd97989d25510f4271554550dc817c (diff) |
Fix crashes on other platforms caused by interference from Darwin weak symbol support.
Support weak symbols on a platform specific basis. The Mac OS X (Darwin)
support must be isolated from the other platforms because it has caused
other platforms to crash. Several other platforms including Linux have
GCC versions that define the weak attribute. However, this attribute is
only setup for use in the code by Darwin.
(closes issue ASTERISK-18728)
Reported by: Ben Klang
Review: https://reviewboard.asterisk.org/r/1617/
........
Merged revisions 348647 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 348648 from http://svn.asterisk.org/svn/asterisk/branches/10
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@348649 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rwxr-xr-x | configure | 147 | ||||
-rw-r--r-- | configure.ac | 34 |
2 files changed, 177 insertions, 4 deletions
@@ -1,5 +1,5 @@ #! /bin/sh -# From configure.ac Revision: 338139 . +# From configure.ac Revision: 339721 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.63 for asterisk trunk. # @@ -22857,6 +22857,17 @@ CFLAGS="$saved_CFLAGS" +# Support weak symbols on a platform specific basis. The Mac OS X +# (Darwin) support must be isolated from the other platforms because +# it has caused other platforms to fail. +# +case "${OSARCH}" in + darwin*) + # Allow weak symbol support on Darwin platforms only because there + # is active community support for it. + # However, Darwin seems to break weak symbols for each new version. + # + { $as_echo "$as_me:$LINENO: checking for compiler 'attribute weak_import' support" >&5 $as_echo_n "checking for compiler 'attribute weak_import' support... " >&6; } saved_CFLAGS="$CFLAGS" @@ -22975,6 +22986,10 @@ CFLAGS="$saved_CFLAGS" + # Several other platforms including Linux have GCC versions that + # define the weak attribute. However, this attribute is only + # setup for use in the code by Darwin. + { $as_echo "$as_me:$LINENO: checking for compiler 'attribute weak' support" >&5 $as_echo_n "checking for compiler 'attribute weak' support... " >&6; } saved_CFLAGS="$CFLAGS" @@ -23092,6 +23107,134 @@ fi CFLAGS="$saved_CFLAGS" + ;; + linux-gnu) + # Primarily support weak symbols on Linux platforms. + # + +{ $as_echo "$as_me:$LINENO: checking for compiler 'attribute weakref' support" >&5 +$as_echo_n "checking for compiler 'attribute weakref' support... " >&6; } +saved_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Wall -Wno-unused -Werror" +PBX_WEAKREF=0 + +if test "xweakref("foo")" = "x" +then +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +static void __attribute__((weakref)) *test(void *muffin, ...) {return (void *) 0;} +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 ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$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 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + PBX_WEAKREF=1 + +cat >>confdefs.h <<_ACEOF +#define HAVE_ATTRIBUTE_weakref 1 +_ACEOF + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +static void __attribute__((weakref("foo"))) *test(void *muffin, ...) {return (void *) 0;} +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 ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$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 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + { $as_echo "$as_me:$LINENO: result: yes" >&5 +$as_echo "yes" >&6; } + PBX_WEAKREF=1 + +cat >>confdefs.h <<_ACEOF +#define HAVE_ATTRIBUTE_weakref 1 +_ACEOF + +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + + +CFLAGS="$saved_CFLAGS" + + + ;; + *) + # Allow weak symbols on other platforms. However, any problems + # with this feature on other platforms must be fixed by the + # community. + # { $as_echo "$as_me:$LINENO: checking for compiler 'attribute weakref' support" >&5 $as_echo_n "checking for compiler 'attribute weakref' support... " >&6; } @@ -23210,6 +23353,8 @@ fi CFLAGS="$saved_CFLAGS" + ;; +esac { $as_echo "$as_me:$LINENO: checking for -ffunction-sections support" >&5 $as_echo_n "checking for -ffunction-sections support... " >&6; } diff --git a/configure.ac b/configure.ac index f84b92db0..e239e8a1a 100644 --- a/configure.ac +++ b/configure.ac @@ -898,9 +898,37 @@ AST_GCC_ATTRIBUTE(always_inline) AST_GCC_ATTRIBUTE(deprecated) AST_GCC_ATTRIBUTE(sentinel) AST_GCC_ATTRIBUTE(warn_unused_result) -AST_GCC_ATTRIBUTE(weak_import, [], [], PBX_WEAKREF) -AST_GCC_ATTRIBUTE(weak, [], [], PBX_WEAKREF) -AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF) + +# Support weak symbols on a platform specific basis. The Mac OS X +# (Darwin) support must be isolated from the other platforms because +# it has caused other platforms to fail. +# +case "${OSARCH}" in + darwin*) + # Allow weak symbol support on Darwin platforms only because there + # is active community support for it. + # However, Darwin seems to break weak symbols for each new version. + # + AST_GCC_ATTRIBUTE(weak_import, [], [], PBX_WEAKREF) + + # Several other platforms including Linux have GCC versions that + # define the weak attribute. However, this attribute is only + # setup for use in the code by Darwin. + AST_GCC_ATTRIBUTE(weak, [], [], PBX_WEAKREF) + ;; + linux-gnu) + # Primarily support weak symbols on Linux platforms. + # + AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF) + ;; + *) + # Allow weak symbols on other platforms. However, any problems + # with this feature on other platforms must be fixed by the + # community. + # + AST_GCC_ATTRIBUTE(weakref, [weakref("foo")], static, PBX_WEAKREF) + ;; +esac AC_MSG_CHECKING(for -ffunction-sections support) saved_CFLAGS="${CFLAGS}" |