From fbca1dce36c87794363799334890df85c30667e5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 3 Jul 2022 16:50:12 +0200 Subject: [PATCH] lib-symbol-visibility: Improve documentation. Reported by Vivien Kraus in . * doc/lib-symbol-visibility.texi: List the platforms. Extend the LIBFOO_DLL_EXPORTED to work also with mingw and also with --disable-shared. --- ChangeLog | 9 +++++++++ doc/lib-symbol-visibility.texi | 30 ++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae9e8de4eb..8694db8900 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2022-07-03 Bruno Haible + + lib-symbol-visibility: Improve documentation. + Reported by Vivien Kraus in + . + * doc/lib-symbol-visibility.texi: List the platforms. Extend the + LIBFOO_DLL_EXPORTED to work also with mingw and also with + --disable-shared. + 2022-07-03 Bruno Haible supersede: Support the file name "/dev/null" on native Windows. diff --git a/doc/lib-symbol-visibility.texi b/doc/lib-symbol-visibility.texi index 60cde8dae4..9574e439dd 100644 --- a/doc/lib-symbol-visibility.texi +++ b/doc/lib-symbol-visibility.texi @@ -106,6 +106,24 @@ It defines a Makefile variable @code{@@CFLAG_VISIBILITY@@} containing as a substituted variable: @@HAVE_VISIBILITY@@. Its value is 1 when symbol visibility control is supported, and 0 otherwise. +As of 2022, symbol visibility control is supported on +@itemize @bullet +@item +ELF platforms (glibc, Linux, *BSD, Solaris) with GCC or clang, +@item +macOS, +@item +AIX with gcc or xlclang. +@end itemize +@noindent +It is not supprted on +@itemize @bullet +@item +Other compilers on ELF platforms or AIX, +@item +Windows. +@end itemize + To use this module in a library, say libfoo, you will do these steps: @enumerate @@ -121,7 +139,7 @@ for the compilation of the sources that make up the library. @item Define a macro specific to your library like this. @smallexample -#if BUILDING_LIBFOO && HAVE_VISIBILITY +#if HAVE_VISIBILITY && BUILDING_LIBFOO #define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default"))) #else #define LIBFOO_DLL_EXPORTED @@ -149,13 +167,17 @@ your library. Note about other compilers: MSVC support can be added easily, by extending the definition of the macro mentioned above, to something like this: @smallexample -#if BUILDING_LIBFOO && HAVE_VISIBILITY +#if HAVE_VISIBILITY && BUILDING_LIBFOO #define LIBFOO_DLL_EXPORTED __attribute__((__visibility__("default"))) -#elif BUILDING_LIBFOO && defined _MSC_VER +#elif (defined _WIN32 && !defined __CYGWIN__) && BUILDING_SHARED && BUILDING_LIBFOO #define LIBFOO_DLL_EXPORTED __declspec(dllexport) -#elif defined _MSC_VER +#elif (defined _WIN32 && !defined __CYGWIN__) && BUILDING_SHARED #define LIBFOO_DLL_EXPORTED __declspec(dllimport) #else #define LIBFOO_DLL_EXPORTED #endif @end smallexample +@noindent +Here @code{BUILDING_SHARED} is a C macro that you have to define. It +ought to evaluate to 1 in a build configured with @samp{--enable-shared}, +or to 0 in a build configured with @samp{--disable-shared}. -- 2.39.5