+2023-09-05 Bruno Haible <bruno@clisp.org>
+
+ relocatable-lib-lgpl: Don't export symbols from static MSVC .obj files.
+ Reported by Dmitry Bely <dmitry.bely@gmail.com> in
+ <https://lists.gnu.org/archive/html/bug-gnu-libiconv/2023-08/msg00002.html>.
+ * lib/relocatable.h (RELOCATABLE_DLL_EXPORTED): Don't use
+ __declspec(dllexport) when creating static .obj files with MSVC.
+
2023-09-05 Bruno Haible <bruno@clisp.org>
unigbrk/u8-grapheme-{next,prev} tests: Fix gcc -Wformat warnings.
#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