# HG changeset patch # User Markus Mützel # Date 1611163341 -3600 # Wed Jan 20 18:22:21 2021 +0100 # Node ID 624d65de7dc9c4d49ae81a72c7419d1fce5a26df # Parent d90757d23c323f67d01798b371394afb257a2484 Optionally disable linking with visibility attributes (bug #59820) * configure.ac: Add argument --disable-lib-visibility to manually disable linking with visibility attributes. * Makefile.am: Use visibility attributes according to configure result. * oct-conf-post.in.h, build-aux/mk-octave-config-h.sh: Optionally set visibility attributes. diff -r d90757d23c32 -r 624d65de7dc9 Makefile.am --- a/Makefile.am Mon Jan 18 19:04:39 2021 +0100 +++ b/Makefile.am Wed Jan 20 18:22:21 2021 +0100 @@ -44,13 +44,17 @@ AM_YFLAGS = -dv ${WARN_YFLAGS} +if AMCOND_LIB_VISIBILITY + OCTAVE_VISIBILITY_FLAG = ${CFLAG_VISIBILITY} +endif + # Fortran compiler flags. -AM_FFLAGS = ${FPICFLAG} @FFLAGS@ ${CFLAG_VISIBILITY} +AM_FFLAGS = ${FPICFLAG} @FFLAGS@ $(OCTAVE_VISIBILITY_FLAG) # C compiler flags. -AM_CFLAGS = ${CPICFLAG} ${XTRA_CFLAGS} ${WARN_CFLAGS} ${CFLAG_VISIBILITY} +AM_CFLAGS = ${CPICFLAG} ${XTRA_CFLAGS} ${WARN_CFLAGS} $(OCTAVE_VISIBILITY_FLAG) # ifeq (${INCLUDE_DEPS},no) # omit_deps = true; @@ -58,7 +62,7 @@ # C++ compiler flags. -AM_CXXFLAGS = ${CXXPICFLAG} ${XTRA_CXXFLAGS} ${WARN_CXXFLAGS} ${CFLAG_VISIBILITY} +AM_CXXFLAGS = ${CXXPICFLAG} ${XTRA_CXXFLAGS} ${WARN_CXXFLAGS} $(OCTAVE_VISIBILITY_FLAG) FFTW_XCPPFLAGS = @FFTW_XCPPFLAGS@ FFTW_XLDFLAGS = @FFTW_XLDFLAGS@ diff -r d90757d23c32 -r 624d65de7dc9 build-aux/mk-octave-config-h.sh --- a/build-aux/mk-octave-config-h.sh Mon Jan 18 19:04:39 2021 +0100 +++ b/build-aux/mk-octave-config-h.sh Wed Jan 20 18:22:21 2021 +0100 @@ -182,20 +182,25 @@ # define octave_unused_parameter(param) (void) param; # endif -# if defined (_WIN32) || defined (__CYGWIN__) -# if defined (__GNUC__) - /* GCC */ -# define OCTAVE_EXPORT __attribute__ ((dllexport)) -# define OCTAVE_IMPORT __attribute__ ((dllimport)) +# if defined (OCTAVE_ENABLE_LIB_VISIBILITY) +# if defined (_WIN32) || defined (__CYGWIN__) +# if defined (__GNUC__) + /* GCC */ +# define OCTAVE_EXPORT __attribute__ ((dllexport)) +# define OCTAVE_IMPORT __attribute__ ((dllimport)) +# else + /* MSVC */ +# define OCTAVE_EXPORT __declspec(dllexport) +# define OCTAVE_IMPORT __declspec(dllimport) +# endif # else - /* MSVC */ -# define OCTAVE_EXPORT __declspec(dllexport) -# define OCTAVE_IMPORT __declspec(dllimport) + /* All other platforms. */ +# define OCTAVE_EXPORT __attribute__ ((visibility ("default"))) +# define OCTAVE_IMPORT # endif # else - /* All other platforms. */ -# define OCTAVE_EXPORT __attribute__ ((visibility ("default"))) -# define OCTAVE_IMPORT +# define OCTAVE_EXPORT +# define OCTAVE_IMPORT # endif /* API macro for liboctave */ diff -r d90757d23c32 -r 624d65de7dc9 configure.ac --- a/configure.ac Mon Jan 18 19:04:39 2021 +0100 +++ b/configure.ac Wed Jan 20 18:22:21 2021 +0100 @@ -2680,6 +2680,25 @@ [if test "$enableval" = yes; then install_build_logs=yes; fi]) AM_CONDITIONAL([AMCOND_INSTALL_BUILD_LOGS], [test $install_build_logs = yes]) +### Link libraries with visibility attributes + +ENABLE_LIB_VISIBILITY=yes +AC_ARG_ENABLE(lib-visibility, + [AS_HELP_STRING([--disable-lib-visibility], + [don't link libraries with visibility settings (export all symbols)])], + [case $enableval in + yes) ENABLE_LIB_VISIBILITY=yes ;; + no) ENABLE_LIB_VISIBILITY=no ;; + *) AC_MSG_ERROR([bad value $enableval for --enable-lib-visibility]) ;; + esac]) + +if test $ENABLE_LIB_VISIBILITY = yes; then + AC_DEFINE(OCTAVE_ENABLE_LIB_VISIBILITY, 1, + [Define to 1 if linking with visibility attributes]) +fi + +AM_CONDITIONAL([AMCOND_LIB_VISIBILITY], [test $ENABLE_LIB_VISIBILITY = yes]) + ### Add extra compiler flags now that feature testing is complete. ## Add warning flags diff -r d90757d23c32 -r 624d65de7dc9 oct-conf-post.in.h --- a/oct-conf-post.in.h Mon Jan 18 19:04:39 2021 +0100 +++ b/oct-conf-post.in.h Wed Jan 20 18:22:21 2021 +0100 @@ -170,19 +170,24 @@ /* oct-dlldefs.h */ -#if defined (_WIN32) || defined (__CYGWIN__) -# if defined (__GNUC__) - /* GCC */ -# define OCTAVE_EXPORT __attribute__ ((dllexport)) -# define OCTAVE_IMPORT __attribute__ ((dllimport)) +#if defined (OCTAVE_ENABLE_LIB_VISIBILITY) +# if defined (_WIN32) || defined (__CYGWIN__) +# if defined (__GNUC__) + /* GCC */ +# define OCTAVE_EXPORT __attribute__ ((dllexport)) +# define OCTAVE_IMPORT __attribute__ ((dllimport)) +# else + /* MSVC */ +# define OCTAVE_EXPORT __declspec(dllexport) +# define OCTAVE_IMPORT __declspec(dllimport) +# endif # else - /* MSVC */ -# define OCTAVE_EXPORT __declspec(dllexport) -# define OCTAVE_IMPORT __declspec(dllimport) + /* All other platforms. */ +# define OCTAVE_EXPORT __attribute__ ((visibility ("default"))) +# define OCTAVE_IMPORT # endif #else - /* All other platforms. */ -# define OCTAVE_EXPORT __attribute__ ((visibility ("default"))) +# define OCTAVE_EXPORT # define OCTAVE_IMPORT #endif