[Asterisk-code-review] menuselect: Remove ineffective weak attribute detection. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Fri Nov 17 09:39:59 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7260


Change subject: menuselect: Remove ineffective weak attribute detection.
......................................................................

menuselect: Remove ineffective weak attribute detection.

menuselect detects compiler support for multiple styles of weak
functions.  This is a remnant from 2013 when OPTIONAL_API required weak
functions.  It is no longer correct for menuselect to switch
dependencies from optional to required based on lack of weak function
support.

Note an issue remains - dependencies should switch from optional to
required based on OPTIONAL_API being enabled or disabled.  I don't think
this is possible.  menuselect needs to know at startup if OPTIONAL_API
is enabled or disabled, so the only way to fix this is to remove
OPTIONAL_API from menuselect and create a configure option.  I've left
the code that switches in place but it's preprocessed out.

Additionally removed:
- WEAKREF variable from Asterisk makeopts.in.
- Related disabled code from test_utils.
- Pointless AC_REVISION call from menuselect/configure.ac.

Change-Id: Ifa702e5f98eb45f338b2f131a93354632a8fb389
---
M makeopts.in
M menuselect/autoconfig.h.in
M menuselect/configure
M menuselect/configure.ac
M menuselect/menuselect.c
M tests/test_utils.c
6 files changed, 6 insertions(+), 374 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/60/7260/1

diff --git a/makeopts.in b/makeopts.in
index 1d31c29..43a4728 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -73,7 +73,6 @@
 CONFIG_SIGNED_CHAR=@CONFIG_SIGNED_CHAR@
 
 GNU_LD=@GNU_LD@
-WEAKREF=@PBX_WEAKREF@
 HAVE_DYNAMIC_LIST=@PBX_DYNAMIC_LIST@
 
 prefix = @prefix@
diff --git a/menuselect/autoconfig.h.in b/menuselect/autoconfig.h.in
index 9cafa56..590ce61 100644
--- a/menuselect/autoconfig.h.in
+++ b/menuselect/autoconfig.h.in
@@ -26,15 +26,6 @@
 /* Define to 1 if you have the `asprintf' function. */
 #undef HAVE_ASPRINTF
 
-/* Define to 1 if your GCC C compiler supports the 'weak' attribute. */
-#undef HAVE_ATTRIBUTE_weak
-
-/* Define to 1 if your GCC C compiler supports the 'weak_import' attribute. */
-#undef HAVE_ATTRIBUTE_weak_import
-
-/* Define to 1 if your GCC C compiler supports the 'weakref' attribute. */
-#undef HAVE_ATTRIBUTE_weakref
-
 /* Define to 1 if you have the curses library. */
 #undef HAVE_CURSES
 
diff --git a/menuselect/configure b/menuselect/configure
index 4235ea0..13a330b 100755
--- a/menuselect/configure
+++ b/menuselect/configure
@@ -1,5 +1,4 @@
 #! /bin/sh
-# From configure.ac Revision.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.69.
 #
@@ -655,7 +654,6 @@
 EGREP
 GREP
 CPP
-PBX_WEAKREF
 MENUSELECT_DEBUG
 GNU_MAKE
 OBJEXT
@@ -2218,7 +2216,6 @@
 
 
 
-
 ac_aux_dir=
 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
   if test -f "$ac_dir/install-sh"; then
@@ -3194,305 +3191,6 @@
 
 
 
-# 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:${as_lineno-$LINENO}: checking for compiler 'attribute weak_import' support" >&5
-$as_echo_n "checking for compiler 'attribute weak_import' support... " >&6; }
-saved_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
-PBX_WEAKREF=0
-
-if test "x" = "x"
-then
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
- void __attribute__((weak_import)) *test(void *muffin, ...) {return (void *) 0;}
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	PBX_WEAKREF=1
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_weak_import 1
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
- void __attribute__(()) *test(void *muffin, ...) ;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	PBX_WEAKREF=1
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_weak_import 1
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-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:${as_lineno-$LINENO}: checking for compiler 'attribute weak' support" >&5
-$as_echo_n "checking for compiler 'attribute weak' support... " >&6; }
-saved_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wall -Wno-unused -Werror"
-PBX_WEAKREF=0
-
-if test "x" = "x"
-then
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
- void __attribute__((weak)) *test(void *muffin, ...) {return (void *) 0;}
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	PBX_WEAKREF=1
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_weak 1
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
- void __attribute__(()) *test(void *muffin, ...) ;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-	PBX_WEAKREF=1
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_ATTRIBUTE_weak 1
-_ACEOF
-
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-CFLAGS="$saved_CFLAGS"
-
-
-	;;
-	linux-gnu)
-	# Primarily support weak symbols on Linux platforms.
-	#
-
-{ $as_echo "$as_me:${as_lineno-$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 confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-static void __attribute__((weakref)) *test(void *muffin, ...) {return (void *) 0;}
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-static void __attribute__((weakref("foo"))) *test(void *muffin, ...) ;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$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:${as_lineno-$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 confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-static void __attribute__((weakref)) *test(void *muffin, ...) {return (void *) 0;}
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-static void __attribute__((weakref("foo"))) *test(void *muffin, ...) ;
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  { $as_echo "$as_me:${as_lineno-$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:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
-
-CFLAGS="$saved_CFLAGS"
-
-
-	;;
-esac
 
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
diff --git a/menuselect/configure.ac b/menuselect/configure.ac
index 29c43cb..5945f5c 100644
--- a/menuselect/configure.ac
+++ b/menuselect/configure.ac
@@ -15,7 +15,6 @@
 AC_CONFIG_HEADER(autoconfig.h)
 
 AC_COPYRIGHT("Menuselect")
-AC_REVISION($Revision$)
 
 AC_CANONICAL_BUILD
 AC_CANONICAL_HOST
@@ -80,37 +79,6 @@
 		*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)  ;;
     esac])
 AC_SUBST(MENUSELECT_DEBUG)
-
-# 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_FUNC_ALLOCA
 AC_CHECK_FUNCS([asprintf getloadavg setenv strcasestr strndup strnlen strsep unsetenv vasprintf])
diff --git a/menuselect/menuselect.c b/menuselect/menuselect.c
index 689cebf..83f6098 100644
--- a/menuselect/menuselect.c
+++ b/menuselect/menuselect.c
@@ -986,8 +986,12 @@
 		}
 	}
 
-	/* If weak linking is not supported, move module uses which are other modules to the dependency list */
-#if !defined(HAVE_ATTRIBUTE_weak_import) && !defined(HAVE_ATTRIBUTE_weakref) && !defined(HAVE_ATTRIBUTE_weak)
+/*
+ * BUGBUG:
+ * This doesn't work, the only way we can fix this is to remove OPTIONAL_API
+ * toggle from menuselect and add a command-line argument to ./configure.
+ */
+#if 0
 	AST_LIST_TRAVERSE(&categories, cat, list) {
 		AST_LIST_TRAVERSE(&cat->members, mem, list) {
 			if (mem->is_separator) {
diff --git a/tests/test_utils.c b/tests/test_utils.c
index 072cf0a..68a2857 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -324,20 +324,6 @@
 		break;
 	}
 
-#if 0 /* Not defined on Solaris */
-	ast_test_status_update(test,
-			       "address of __stub__ast_crypto_loaded is %p\n",
-			       __stub__ast_crypto_loaded);
-#ifndef HAVE_ATTRIBUTE_weak_import
-	ast_test_status_update(test,
-			       "address of __ref__ast_crypto_loaded is %p\n",
-			       __ref__ast_crypto_loaded);
-#endif
-	ast_test_status_update(test,
-			       "pointer to ast_crypto_loaded is %p\n",
-			       ast_crypto_loaded);
-#endif
-
 	return ast_crypto_loaded() ? AST_TEST_PASS : AST_TEST_FAIL;
 }
 
@@ -387,20 +373,6 @@
 	case TEST_EXECUTE:
 		break;
 	}
-
-#if 0
-	ast_test_status_update(test,
-			       "address of __stub__ast_agi_register is %p\n",
-			       __stub__ast_agi_register);
-#ifndef HAVE_ATTRIBUTE_weak_import
-	ast_test_status_update(test,
-			       "address of __ref__ast_agi_register is %p\n",
-			       __ref__ast_agi_register);
-#endif
-	ast_test_status_update(test,
-			       "pointer to ast_agi_register is %p\n",
-			       ast_agi_register);
-#endif
 
 	if (ast_agi_register(ast_module_info->self, &noop_command) == AST_OPTIONAL_API_UNAVAILABLE) {
 		ast_test_status_update(test, "Unable to register testnoop command, because res_agi is not loaded.\n");

-- 
To view, visit https://gerrit.asterisk.org/7260
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa702e5f98eb45f338b2f131a93354632a8fb389
Gerrit-Change-Number: 7260
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171117/de53b57b/attachment-0001.html>


More information about the asterisk-code-review mailing list