GCC 10 introduces a function attribute to define symbol versioning. Add a configure check to see if __attribute__((symver)) is supported. If it is then define the OLD_VERSION, NEW_VERSION, COMPAT_VERSION and COMPAT_VERSION_NEWPROTO macros using just attribute symver, attribute alias and typeof function names. And avoid defining symbols in asm statements.
Signed-off-by: Mark Wielaard <m...@klomp.org> --- ChangeLog | 4 ++++ configure.ac | 13 +++++++++++++ lib/ChangeLog | 5 +++++ lib/eu-config.h | 20 ++++++++++++++++++-- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 854568e0..bff3bdef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-04-10 Mark Wielaard <m...@klomp.org> + + * configure.ac: Add __attribute__((symver)) check. + 2020-03-30 Mark Wielaard <m...@klomp.org> * configure.ac: Set version to 0.179. diff --git a/configure.ac b/configure.ac index a39e800f..2a0aaca8 100644 --- a/configure.ac +++ b/configure.ac @@ -158,6 +158,19 @@ if test "$ac_cv_gcc_struct" = "yes"; then [Defined if __attribute__((gcc_struct)) is supported]) fi +AC_CACHE_CHECK([whether gcc supports __attribute__((symver))], + ac_cv_gcc_symver, [dnl +save_CFLAGS="$CFLAGS" +CFLAGS="$save_CFLAGS -Werror" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([dnl +__attribute__ ((__symver__ ("foo@VERS_1"))) int foo_v1 (void) { } +])], ac_cv_gcc_symver=yes, ac_cv_gcc_symver=no) +CFLAGS="$save_CFLAGS"]) +if test "$ac_cv_gcc_symver" = "yes"; then + AC_DEFINE([HAVE_GCC_SYMVER], [1], + [Defined if __attribute__((symver)) is supported]) +fi + AC_CACHE_CHECK([whether gcc supports -fPIC], ac_cv_fpic, [dnl save_CFLAGS="$CFLAGS" CFLAGS="$save_CFLAGS -fPIC -Werror" diff --git a/lib/ChangeLog b/lib/ChangeLog index 51c79841..07837cce 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2020-04-10 Mark Wielaard <m...@klomp.org> + + * eu-config.h: If HAVE_GCC_SYMVER define symbol versioning macros + using attribute symver. + 2019-08-25 Srđan Milaković <sm...@rice.edu> * dynamicsizehash_concurrent.{c,h}: New files. diff --git a/lib/eu-config.h b/lib/eu-config.h index 84b22d7c..ccbedeb0 100644 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@ -177,6 +177,21 @@ asm (".section predict_data, \"aw\"; .previous\n" #ifdef SYMBOL_VERSIONING +#ifdef HAVE_GCC_SYMVER +# define OLD_VERSION(name, version) \ + __attribute__((__symver__( #name "@" #version))) \ + __attribute__((__alias__( #name ))) \ + __typeof__( name ) _compat_##version_##name; +#define NEW_VERSION(name, version) \ + __attribute__((__symver__(#name "@@" #version))) \ + __typeof__ ( name ) name ; +# define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ + __attribute__((__symver__ ( #name "@" #version ))) \ + __typeof__(_compat_##prefix##_##name) _compat_##prefix##_##name; +# define COMPAT_VERSION(name, version, prefix) \ + __attribute__((__symver__(#name "@" #version))) \ + __typeof__(name) _compat_##prefix##_##name; +#else /* HAVE_GCC_SYMVER */ # define OLD_VERSION(name, version) \ asm (".globl _compat." #version "." #name "\n" \ "_compat." #version "." #name " = " #name "\n" \ @@ -190,13 +205,14 @@ asm (".section predict_data, \"aw\"; .previous\n" # define COMPAT_VERSION(name, version, prefix) \ asm (".symver _compat." #version "." #name "," #name "@" #version); \ __typeof (name) _compat_##prefix##_##name asm ("_compat." #version "." #name); -#else +#endif /* HAVE_GCC_SYMVER */ +#else /* SYMBOL_VERSIONING */ # define OLD_VERSION(name, version) /* Nothing for static linking. */ # define NEW_VERSION(name, version) /* Nothing for static linking. */ # define COMPAT_VERSION_NEWPROTO(name, version, prefix) \ error "should use #ifdef SYMBOL_VERSIONING" # define COMPAT_VERSION(name, version, prefix) error "should use #ifdef SYMBOL_VERSIONING" -#endif +#endif /* SYMBOL_VERSIONING */ #ifndef FALLTHROUGH # ifdef HAVE_FALLTHROUGH -- 2.18.2