From: Bruno Haible Date: Wed, 6 Sep 2023 00:03:37 +0000 (+0200) Subject: relocatable-lib-lgpl: Don't export symbols from static MSVC .obj files. X-Git-Tag: v1.0~811 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=2923106da77d300a8385ca804daf9b8073f7edef;p=gnulib.git relocatable-lib-lgpl: Don't export symbols from static MSVC .obj files. Reported by Dmitry Bely in . * lib/relocatable.h (RELOCATABLE_DLL_EXPORTED): Don't use __declspec(dllexport) when creating static .obj files with MSVC. --- diff --git a/ChangeLog b/ChangeLog index 24a6188741..8c92d05dae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-09-05 Bruno Haible + + relocatable-lib-lgpl: Don't export symbols from static MSVC .obj files. + Reported by Dmitry Bely in + . + * lib/relocatable.h (RELOCATABLE_DLL_EXPORTED): Don't use + __declspec(dllexport) when creating static .obj files with MSVC. + 2023-09-05 Bruno Haible unigbrk/u8-grapheme-{next,prev} tests: Fix gcc -Wformat warnings. diff --git a/lib/relocatable.h b/lib/relocatable.h index f4634b1238..fcbbb21934 100644 --- a/lib/relocatable.h +++ b/lib/relocatable.h @@ -39,7 +39,20 @@ extern "C" { #if HAVE_VISIBILITY && BUILDING_DLL # define RELOCATABLE_DLL_EXPORTED __attribute__((__visibility__("default"))) #elif defined _MSC_VER && BUILDING_DLL -# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport) +/* When building with MSVC, exporting a symbol means that the object file + contains a "linker directive" of the form /EXPORT:symbol. This can be + inspected through the "objdump -s --section=.drectve FILE" or + "dumpbin /directives FILE" commands. + The symbols from this file should be exported if and only if the object + file gets included in a DLL. Libtool, on Windows platforms, defines + the C macro DLL_EXPORT (together with PIC) when compiling for a DLL + and does not define it when compiling an object file meant to be linked + statically into some executable. */ +# if defined DLL_EXPORT +# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport) +# else +# define RELOCATABLE_DLL_EXPORTED +# endif #else # define RELOCATABLE_DLL_EXPORTED #endif