From a90bb1a7d77be2b191a0e0145b7de6548d3376a7 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Wed, 6 Sep 2023 20:59:03 +0200 Subject: [PATCH] intl: Don't export symbols from static MSVC .obj files. * gettext-runtime/intl/intl-compat.c (DLL_EXPORTED): Set to empty on MSVC when DLL_EXPORT is not defined. * gettext-runtime/intl/printf.c (DLL_EXPORTED): Likewise. * gettext-runtime/intl/setlocale.c (DLL_EXPORTED): Likewise. --- gettext-runtime/intl/intl-compat.c | 17 +++++++++++++++-- gettext-runtime/intl/printf.c | 15 ++++++++++++++- gettext-runtime/intl/setlocale.c | 17 +++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/gettext-runtime/intl/intl-compat.c b/gettext-runtime/intl/intl-compat.c index e2b8d6c37..d141e0453 100644 --- a/gettext-runtime/intl/intl-compat.c +++ b/gettext-runtime/intl/intl-compat.c @@ -1,6 +1,6 @@ /* intl-compat.c - Stub functions to call gettext functions from GNU gettext Library. - Copyright (C) 1995, 2000-2003, 2005 Free Software Foundation, Inc. + Copyright (C) 1995, 2000-2003, 2005, 2023 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -50,7 +50,20 @@ #if HAVE_VISIBILITY && BUILDING_DLL # define DLL_EXPORTED __attribute__((__visibility__("default"))) #elif defined _MSC_VER && BUILDING_DLL -# define 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 DLL_EXPORTED __declspec(dllexport) +# else +# define DLL_EXPORTED +# endif #else # define DLL_EXPORTED #endif diff --git a/gettext-runtime/intl/printf.c b/gettext-runtime/intl/printf.c index de2d58470..836cc0732 100644 --- a/gettext-runtime/intl/printf.c +++ b/gettext-runtime/intl/printf.c @@ -64,7 +64,20 @@ char *alloca (); #if HAVE_VISIBILITY && BUILDING_DLL # define DLL_EXPORTED __attribute__((__visibility__("default"))) #elif defined _MSC_VER && BUILDING_DLL -# define 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 DLL_EXPORTED __declspec(dllexport) +# else +# define DLL_EXPORTED +# endif #else # define DLL_EXPORTED #endif diff --git a/gettext-runtime/intl/setlocale.c b/gettext-runtime/intl/setlocale.c index d18e1f39d..ea671833e 100644 --- a/gettext-runtime/intl/setlocale.c +++ b/gettext-runtime/intl/setlocale.c @@ -1,5 +1,5 @@ /* setlocale() function that respects the locale chosen by the user. - Copyright (C) 2009, 2011, 2013, 2018-2019, 2022 Free Software Foundation, Inc. + Copyright (C) 2009, 2011, 2013, 2018-2019, 2022-2023 Free Software Foundation, Inc. Written by Bruno Haible , 2009. This program is free software: you can redistribute it and/or modify @@ -39,7 +39,20 @@ #if HAVE_VISIBILITY && BUILDING_DLL # define DLL_EXPORTED __attribute__((__visibility__("default"))) #elif defined _MSC_VER && BUILDING_DLL -# define 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 DLL_EXPORTED __declspec(dllexport) +# else +# define DLL_EXPORTED +# endif #else # define DLL_EXPORTED #endif -- 2.47.2