diff -up libxmp-4.5.0/configure.ac.lto libxmp-4.5.0/configure.ac --- libxmp-4.5.0/configure.ac.lto 2021-06-10 02:24:24.000000000 +0200 +++ libxmp-4.5.0/configure.ac 2021-06-22 23:29:00.766506145 +0200 @@ -118,24 +118,34 @@ XMP_TRY_COMPILE(whether compiler underst __attribute__((visibility("default"))) int foo(void); __attribute__((visibility("hidden"))) int bar(void); int foo(void) { return 0; } -int bar(void) { return 1; }], - [CFLAGS="${old_CFLAGS} -fvisibility=hidden -DXMP_SYM_VISIBILITY" - LD_VERSCRIPT="-Wl,--version-script,libxmp.map"], - [CFLAGS="${old_CFLAGS}"])] - ) -dnl we want symbol -fvisibility for elf targets, however it works -dnl with darwin/macho too. other than that, windows, dos, os/2, -dnl amiga do not want it: for any such targets, the -Werror switch -dnl is should fail the above check, but it does not. adding the -dnl manual test below for that, instead. +int bar(void) { return 1; }])] +) case $host_os in mingw*|cygwin*|emx*|*djgpp|amigaos*|aros*|morphos*) - CFLAGS="${old_CFLAGS}" if test $ac_cv_c_flag_f_visibility_hidden = yes; then AC_MSG_NOTICE([ignoring -fvisibility flags for $host_os]) fi + ac_cv_c_flag_f_visibility_hidden=no ;; esac +if test $ac_cv_c_flag_f_visibility_hidden = no; then + CFLAGS="${old_CFLAGS}" +else + CFLAGS="${old_CFLAGS} -fvisibility=hidden -DXMP_SYM_VISIBILITY" + LD_VERSCRIPT="-Wl,--version-script,libxmp.map" + +dnl https://github.com/libxmp/libxmp/issues/385 + old_CFLAGS="${CFLAGS}" + if test $ac_cv_c_flag_w_all = yes; then + CFLAGS="${CFLAGS} -Werror" + fi + XMP_TRY_COMPILE(whether compiler understands externally_visible attribute, + ac_cv_c_attribute_visibility_external,[],[ +__attribute__((visibility("default"),externally_visible)) int foo(void); +int foo(void) { return 0; }], + [CFLAGS="${old_CFLAGS} -DHAVE_EXTERNAL_VISIBILITY"], + [CFLAGS="${old_CFLAGS}"]) +fi dnl for clang XMP_TRY_COMPILE(whether compiler understands -Wunknown-warning-option, diff -up libxmp-4.5.0/configure.lto libxmp-4.5.0/configure --- libxmp-4.5.0/configure.lto 2021-06-10 02:24:28.000000000 +0200 +++ libxmp-4.5.0/configure 2021-06-22 23:29:24.327699205 +0200 @@ -4128,22 +4140,60 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_flag_f_visibility_hidden" >&5 $as_echo "$ac_cv_c_flag_f_visibility_hidden" >&6; } if test "x$ac_cv_c_flag_f_visibility_hidden" = xyes; then : - CFLAGS="${old_CFLAGS} -fvisibility=hidden -DXMP_SYM_VISIBILITY" - LD_VERSCRIPT="-Wl,--version-script,libxmp.map" -else - CFLAGS="${old_CFLAGS}" + fi fi case $host_os in mingw*|cygwin*|emx*|*djgpp|amigaos*|aros*|morphos*) - CFLAGS="${old_CFLAGS}" if test $ac_cv_c_flag_f_visibility_hidden = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: ignoring -fvisibility flags for $host_os" >&5 $as_echo "$as_me: ignoring -fvisibility flags for $host_os" >&6;} fi + ac_cv_c_flag_f_visibility_hidden=no ;; esac +if test $ac_cv_c_flag_f_visibility_hidden = no; then + CFLAGS="${old_CFLAGS}" +else + CFLAGS="${old_CFLAGS} -fvisibility=hidden -DXMP_SYM_VISIBILITY" + LD_VERSCRIPT="-Wl,--version-script,libxmp.map" + + old_CFLAGS="${CFLAGS}" + if test $ac_cv_c_flag_w_all = yes; then + CFLAGS="${CFLAGS} -Werror" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler understands externally_visible attribute" >&5 +$as_echo_n "checking whether compiler understands externally_visible attribute... " >&6; } +if ${ac_cv_c_attribute_visibility_external+:} false; then : + $as_echo_n "(cached) " >&6 +else + + oldcflags="${CFLAGS}" + CFLAGS="${CFLAGS} " + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +__attribute__((visibility("default"),externally_visible)) int foo(void); +int foo(void) { return 0; } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_attribute_visibility_external=yes +else + ac_cv_c_attribute_visibility_external=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="${oldcflags}" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_attribute_visibility_external" >&5 +$as_echo "$ac_cv_c_attribute_visibility_external" >&6; } + if test "x$ac_cv_c_attribute_visibility_external" = xyes; then : + CFLAGS="${old_CFLAGS} -DHAVE_EXTERNAL_VISIBILITY" +else + CFLAGS="${old_CFLAGS}" +fi +fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiler understands -Wunknown-warning-option" >&5 diff -up libxmp-4.5.0/src/common.h.lto libxmp-4.5.0/src/common.h --- libxmp-4.5.0/src/common.h.lto 2021-06-10 02:24:24.000000000 +0200 +++ libxmp-4.5.0/src/common.h 2021-06-22 23:29:00.766506145 +0200 @@ -24,6 +24,11 @@ #if (defined(__GNUC__) || defined(__clang__)) && defined(XMP_SYM_VISIBILITY) #if !defined(_WIN32) && !defined(__ANDROID__) && !defined(__APPLE__) && !defined(LIBXMP_AMIGA) && !defined(__MSDOS__) && !defined(B_BEOS_VERSION) && !defined(__ATHEOS__) && !defined(EMSCRIPTEN) && !defined(__MINT__) #define USE_VERSIONED_SYMBOLS +#ifdef HAVE_EXTERNAL_VISIBILITY +#define LIBXMP_EXPORT_VERSIONED __attribute__((visibility("default"),externally_visible)) +#else +#define LIBXMP_EXPORT_VERSIONED __attribute__((visibility("default"))) +#endif #endif #endif diff -up libxmp-4.5.0/src/control.c.lto libxmp-4.5.0/src/control.c --- libxmp-4.5.0/src/control.c.lto 2021-06-10 02:24:24.000000000 +0200 +++ libxmp-4.5.0/src/control.c 2021-06-22 23:29:00.766506145 +0200 @@ -309,12 +309,12 @@ int xmp_channel_vol(xmp_context opaque, } #ifdef USE_VERSIONED_SYMBOLS -LIBXMP_EXPORT extern int xmp_set_player_v40__(xmp_context, int, int); -LIBXMP_EXPORT extern int xmp_set_player_v41__(xmp_context, int, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_set_player_v40__(xmp_context, int, int); +LIBXMP_EXPORT_VERSIONED extern int xmp_set_player_v41__(xmp_context, int, int) __attribute__((alias("xmp_set_player_v40__"))); -LIBXMP_EXPORT extern int xmp_set_player_v43__(xmp_context, int, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_set_player_v43__(xmp_context, int, int) __attribute__((alias("xmp_set_player_v40__"))); -LIBXMP_EXPORT extern int xmp_set_player_v44__(xmp_context, int, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_set_player_v44__(xmp_context, int, int) __attribute__((alias("xmp_set_player_v40__"))); asm(".symver xmp_set_player_v40__, xmp_set_player@XMP_4.0"); @@ -427,14 +427,14 @@ int xmp_set_player__(xmp_context opaque, } #ifdef USE_VERSIONED_SYMBOLS -LIBXMP_EXPORT extern int xmp_get_player_v40__(xmp_context, int); -LIBXMP_EXPORT extern int xmp_get_player_v41__(xmp_context, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_get_player_v40__(xmp_context, int); +LIBXMP_EXPORT_VERSIONED extern int xmp_get_player_v41__(xmp_context, int) __attribute__((alias("xmp_get_player_v40__"))); -LIBXMP_EXPORT extern int xmp_get_player_v42__(xmp_context, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_get_player_v42__(xmp_context, int) __attribute__((alias("xmp_get_player_v40__"))); -LIBXMP_EXPORT extern int xmp_get_player_v43__(xmp_context, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_get_player_v43__(xmp_context, int) __attribute__((alias("xmp_get_player_v40__"))); -LIBXMP_EXPORT extern int xmp_get_player_v44__(xmp_context, int) +LIBXMP_EXPORT_VERSIONED extern int xmp_get_player_v44__(xmp_context, int) __attribute__((alias("xmp_get_player_v40__"))); asm(".symver xmp_get_player_v40__, xmp_get_player@XMP_4.0");