]> Savannah Git Hosting - gnulib.git/commitdiff
relocatable-lib-lgpl: Don't export symbols from static MSVC .obj files.
authorBruno Haible <bruno@clisp.org>
Wed, 6 Sep 2023 00:03:37 +0000 (02:03 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 6 Sep 2023 00:16:46 +0000 (02:16 +0200)
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.

ChangeLog
lib/relocatable.h

index 24a6188741c6b5105e621783df17990f7faea539..8c92d05daee805b2f81d2be5768232e9b9e62aad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
index f4634b12389461abfe712dde6afaf80c36b10649..fcbbb219342ea702506ae487188fbc2ae73f6b4b 100644 (file)
@@ -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