# HG changeset patch # User Markus Mützel # Date 1608973645 -3600 # Sat Dec 26 10:07:25 2020 +0100 # Node ID 7cfc9b239974f7b1f6d8d4086de765eba0ba0d10 # Parent 9e2c5371c145bdc5a9b840e34c4c597a497092dc Visibility: Compile with visibility attributes for Linux (patch #8919). * bootstrap.conf: Add module lib-symbol-visibility. * m4/acinclude.m4: Define macro for exporting symbols in each library for Linux. * Makefile.am: Set visibility flag in compiler flags. * oct-conf-post.in.h: Set attribute for visibility for Linux. Work around mutual dependency issues. diff -r 9e2c5371c145 -r 7cfc9b239974 Makefile.am --- a/Makefile.am Wed Dec 16 01:05:17 2020 -0500 +++ b/Makefile.am Sat Dec 26 10:07:25 2020 +0100 @@ -46,11 +46,11 @@ # Fortran compiler flags. -AM_FFLAGS = ${FPICFLAG} @FFLAGS@ +AM_FFLAGS = ${FPICFLAG} @FFLAGS@ ${CFLAG_VISIBILITY} # C compiler flags. -AM_CFLAGS = ${CPICFLAG} ${XTRA_CFLAGS} ${WARN_CFLAGS} +AM_CFLAGS = ${CPICFLAG} ${XTRA_CFLAGS} ${WARN_CFLAGS} ${CFLAG_VISIBILITY} # ifeq (${INCLUDE_DEPS},no) # omit_deps = true; @@ -58,7 +58,7 @@ # C++ compiler flags. -AM_CXXFLAGS = ${CXXPICFLAG} ${XTRA_CXXFLAGS} ${WARN_CXXFLAGS} +AM_CXXFLAGS = ${CXXPICFLAG} ${XTRA_CXXFLAGS} ${WARN_CXXFLAGS} ${CFLAG_VISIBILITY} FFTW_XCPPFLAGS = @FFTW_XCPPFLAGS@ FFTW_XLDFLAGS = @FFTW_XLDFLAGS@ diff -r 9e2c5371c145 -r 7cfc9b239974 bootstrap.conf --- a/bootstrap.conf Wed Dec 16 01:05:17 2020 -0500 +++ b/bootstrap.conf Sat Dec 26 10:07:25 2020 +0100 @@ -59,6 +59,7 @@ intprops isatty largefile + lib-symbol-visibility link localcharset lstat diff -r 9e2c5371c145 -r 7cfc9b239974 m4/acinclude.m4 --- a/m4/acinclude.m4 Wed Dec 16 01:05:17 2020 -0500 +++ b/m4/acinclude.m4 Sat Dec 26 10:07:25 2020 +0100 @@ -2990,6 +2990,11 @@ ;; *-*-linux* | *-*-gnu*) MKOCTFILE_DL_LDFLAGS="-shared -Wl,-Bsymbolic" + EXTERNAL_DLL_DEFS="-DEXTERNAL_DLL" + OCTAVE_DLL_DEFS="-DOCTAVE_DLL" + OCTINTERP_DLL_DEFS="-DOCTINTERP_DLL" + OCTGUI_DLL_DEFS="-DOCTGUI_DLL" + OCTGRAPHICS_DLL_DEFS="-DOCTGRAPHICS_DLL" ;; i[[3456]]86-*-sco3.2v5*) SH_LDFLAGS=-G diff -r 9e2c5371c145 -r 7cfc9b239974 oct-conf-post.in.h --- a/oct-conf-post.in.h Wed Dec 16 01:05:17 2020 -0500 +++ b/oct-conf-post.in.h Sat Dec 26 10:07:25 2020 +0100 @@ -178,33 +178,41 @@ # define OCTAVE_IMPORT __declspec(dllimport) #else /* All other compilers, at least for now. */ -# define OCTAVE_EXPORT +# define OCTAVE_EXPORT __attribute__ ((visibility ("default"))) # define OCTAVE_IMPORT #endif +/* FIXME: Should the same symbol be exported by multiple libraries? + Long-term sort out the mutual dependencies that prevent exporting symbols + from only one library. */ + /* API macro for liboctave */ -#if defined (OCTAVE_DLL) +#if (defined (OCTAVE_DLL) || defined (OCTINTERP_DLL) \ + || defined (OCTGRAPHICS_DLL) || defined (OCTGUI_DLL)) # define OCTAVE_API OCTAVE_EXPORT #else # define OCTAVE_API OCTAVE_IMPORT #endif /* API macro for libinterp */ -#if defined (OCTINTERP_DLL) +#if (defined (OCTAVE_DLL) || defined (OCTINTERP_DLL) \ + || defined (OCTGRAPHICS_DLL) || defined (OCTGUI_DLL)) # define OCTINTERP_API OCTAVE_EXPORT #else # define OCTINTERP_API OCTAVE_IMPORT #endif /* API macro for libinterp/graphics */ -#if defined (OCTGRAPHICS_DLL) +#if (defined (OCTAVE_DLL) || defined (OCTINTERP_DLL) \ + || defined (OCTGRAPHICS_DLL) || defined (OCTGUI_DLL)) # define OCTGRAPHICS_API OCTAVE_EXPORT #else # define OCTGRAPHICS_API OCTAVE_IMPORT #endif /* API macro for libgui */ -#if defined (OCTGUI_DLL) +#if (defined (OCTAVE_DLL) || defined (OCTINTERP_DLL) \ + || defined (OCTGRAPHICS_DLL) || defined (OCTGUI_DLL)) # define OCTGUI_API OCTAVE_EXPORT #else # define OCTGUI_API OCTAVE_IMPORT