The attached patch tweaks the configuration check for attribute
ifunc support in libatomic to avoid the new type safety warnings.
It also changes the libatomic declarations of ifunc resolvers to
avoid the new warnings. With it conftest.c compiles successfully
(see below) as does libatomic, and no there are regressions in
tests on x86_64. Does it look good to check in?
I haven't been paying close attention so if Steve or someone else
already submitted a patch with the libatomic_i.h changes I can take
mine out.
Martin
configure:14689: checking whether the target supports the ifunc attribute
configure:14712: /ssd/build/gcc-git-maint/./gcc/xgcc
-B/ssd/build/gcc-git-maint/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem
/usr/local/x86_64-pc-linux-gnu/include -isystem
/usr/local/x86_64-pc-linux-gnu/sys-include -m32 -o conftest -O2 -O0 -g3
-pthread -pthread -Werror conftest.c >&5
configure:14712: $? = 0
configure:14720: result: yes
PR c/81854 - weak alias of an incompatible symbol accepted
libatomic/ChangeLog:
2017-10-02 Martin Sebor <mse...@redhat.com>
PR c/81854
* acinclude.m4 (LIBAT_CHECK_IFUNC): Have ifunc resolver return
a function pointer rather than void* to avoid GCC 8 warnings.
* configure: Regenerate.
* libatomic_i.h: Declare ifunc resolvers to return function
pointers rather than void*.
diff --git a/libatomic/acinclude.m4 b/libatomic/acinclude.m4
index 485d731..383218f 100644
--- a/libatomic/acinclude.m4
+++ b/libatomic/acinclude.m4
@@ -195,7 +195,8 @@ AC_DEFUN([LIBAT_CHECK_IFUNC], [
CFLAGS="$CFLAGS -Werror"
AC_TRY_LINK([
int foo_alt(void) { return 0; }
- void *foo_sel(void) { return foo_alt; }
+ typedef int F (void);
+ F *foo_sel(void) { return foo_alt; }
int foo(void) __attribute__((ifunc("foo_sel")));],
[return foo();], libat_cv_have_ifunc=yes, libat_cv_have_ifunc=no)])
LIBAT_DEFINE_YESNO([HAVE_IFUNC], [$libat_cv_have_ifunc],
diff --git a/libatomic/configure b/libatomic/configure
index c05fc9d..e88a7b8 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -12333,6 +12333,7 @@ _ACEOF
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 2" >&5
$as_echo_n "checking for __atomic_load/store for size 2... " >&6; }
if test "${libat_cv_have_at_ldst_2+set}" = set; then :
@@ -12400,6 +12401,7 @@ _ACEOF
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 4" >&5
$as_echo_n "checking for __atomic_load/store for size 4... " >&6; }
if test "${libat_cv_have_at_ldst_4+set}" = set; then :
@@ -12467,6 +12469,7 @@ _ACEOF
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 8" >&5
$as_echo_n "checking for __atomic_load/store for size 8... " >&6; }
if test "${libat_cv_have_at_ldst_8+set}" = set; then :
@@ -12534,6 +12537,7 @@ _ACEOF
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 16" >&5
$as_echo_n "checking for __atomic_load/store for size 16... " >&6; }
if test "${libat_cv_have_at_ldst_16+set}" = set; then :
@@ -12602,6 +12606,7 @@ _ACEOF
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_test_and_set for size 1" >&5
$as_echo_n "checking for __atomic_test_and_set for size 1... " >&6; }
if test "${libat_cv_have_at_tas_1+set}" = set; then :
@@ -14693,7 +14698,8 @@ else
/* end confdefs.h. */
int foo_alt(void) { return 0; }
- void *foo_sel(void) { return foo_alt; }
+ typedef int F (void);
+ F *foo_sel(void) { return foo_alt; }
int foo(void) __attribute__((ifunc("foo_sel")));
int
main ()
diff --git a/libatomic/libatomic_i.h b/libatomic/libatomic_i.h
index 4eb372a..2dad4a8 100644
--- a/libatomic/libatomic_i.h
+++ b/libatomic/libatomic_i.h
@@ -240,7 +240,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
# if IFUNC_NCOND(N) == 1
# define GEN_SELECTOR(X) \
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
- static void * C2(select_,X) (void) \
+ static typeof(C2(libat_,X)) * C2(select_,X) (void) \
{ \
if (IFUNC_COND_1) \
return C3(libat_,X,_i1); \
@@ -250,7 +250,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
# define GEN_SELECTOR(X) \
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN; \
- static void * C2(select_,X) (void) \
+ static typeof(C2(libat_,X)) * C2(select_,X) (void) \
{ \
if (IFUNC_COND_1) \
return C3(libat_,X,_i1); \
@@ -263,7 +263,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN; \
extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN; \
extern typeof(C2(libat_,X)) C3(libat_,X,_i3) HIDDEN; \
- static void * C2(select_,X) (void) \
+ static typeof(C2(libat_,X)) * C2(select_,X) (void) \
{ \
if (IFUNC_COND_1) \
return C3(libat_,X,_i1); \