From: Bruno Haible Date: Wed, 6 Sep 2023 18:59:03 +0000 (+0200) Subject: intl: Don't export symbols from static MSVC .obj files. X-Git-Tag: v0.23~414 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8752367c1cbd1a5c231e423dbd1c186ea1c67841;p=thirdparty%2Fgettext.git intl: Don't export symbols from static MSVC .obj files. * gettext-runtime/intl/configure.ac (WOE32DLL): Set to 1 or 0, not 'yes' or 'no'. Don't define as C macro any more. (DLL_VARIABLE): Test DLL_EXPORT, not _DLL. * gettext-runtime/intl/export.h: Use the value of WOE32DLL at configure time. Set LIBINTL_DLL_EXPORTED to empty on MSVC when DLL_EXPORT is not defined. * gettext-runtime/intl/Makefile.am (libgnuintl.h): Substitute the value of @WOE32DLL@. * 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. --- diff --git a/gettext-runtime/intl/Makefile.am b/gettext-runtime/intl/Makefile.am index 1694815cd..da7abb758 100644 --- a/gettext-runtime/intl/Makefile.am +++ b/gettext-runtime/intl/Makefile.am @@ -230,7 +230,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.in.h $(srcdir)/export.h -e 's,@''HAVE_NEWLOCALE''@,@HAVE_NEWLOCALE@,g' \ -e 's,@''ENHANCE_LOCALE_FUNCS''@,@ENHANCE_LOCALE_FUNCS@,g' \ < $(srcdir)/libgnuintl.in.h \ - | if test '@WOE32DLL@' = yes; then \ + | if test '@WOE32DLL@' = 1; then \ sed -e 's/extern \([^()]*\);/extern __declspec (dllimport) \1;/'; \ else \ cat; \ @@ -239,6 +239,7 @@ libgnuintl.h: $(srcdir)/libgnuintl.in.h $(srcdir)/export.h -e "/#define _LIBINTL_H/r $(srcdir)/export.h" \ | sed -e '/#define _LIBINTL_H/,/[*][/]$$/{/#define _LIBINTL_H/!d;}' \ | sed -e 's,@''HAVE_VISIBILITY''@,@HAVE_VISIBILITY@,g' \ + | sed -e 's,@''WOE32DLL''@,@WOE32DLL@,g' \ > libgnuintl.h MOSTLYCLEANFILES += libgnuintl.h diff --git a/gettext-runtime/intl/configure.ac b/gettext-runtime/intl/configure.ac index 2a31e3475..30a86065e 100644 --- a/gettext-runtime/intl/configure.ac +++ b/gettext-runtime/intl/configure.ac @@ -229,21 +229,26 @@ if test "$enable_shared" = yes; then else is_woe32dll=no fi -WOE32DLL=$is_woe32dll -AC_SUBST([WOE32DLL]) -AM_CONDITIONAL([WOE32DLL], [test $is_woe32dll = yes]) if test $is_woe32dll = yes; then - AC_DEFINE([WOE32DLL], [1], - [Define when --enable-shared is used on Windows.]) + WOE32DLL=1 +else + WOE32DLL=0 fi +AC_SUBST([WOE32DLL]) +AM_CONDITIONAL([WOE32DLL], [test $is_woe32dll = yes]) dnl Put some default definitions into config.h. AH_BOTTOM([ /* Tweak gnulib code according to the needs of this library. */ #define IN_LIBINTL 1 -/* On Windows, variables that may be in a DLL must be marked specially. */ -#if (defined _MSC_VER && defined _DLL) && !defined IN_RELOCWRAPPER +/* On Windows, variables that may be in a DLL must be marked specially. + The symbols marked with DLL_VARIABLE 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 _MSC_VER && defined DLL_EXPORT) && !defined IN_RELOCWRAPPER # define DLL_VARIABLE __declspec (dllimport) #else # define DLL_VARIABLE diff --git a/gettext-runtime/intl/export.h b/gettext-runtime/intl/export.h index 7988aca3e..aadf1633e 100644 --- a/gettext-runtime/intl/export.h +++ b/gettext-runtime/intl/export.h @@ -1,5 +1,5 @@ /* Control of exported symbols from libintl. - Copyright (C) 2005-2022 Free Software Foundation, Inc. + Copyright (C) 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 @@ -15,11 +15,20 @@ along with this program. If not, see . */ #if @HAVE_VISIBILITY@ && BUILDING_LIBINTL -#define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default"))) -#elif (defined _WIN32 && !defined __CYGWIN__) && defined WOE32DLL && BUILDING_LIBINTL -#define LIBINTL_DLL_EXPORTED __declspec(dllexport) -#elif (defined _WIN32 && !defined __CYGWIN__) && defined WOE32DLL -#define LIBINTL_DLL_EXPORTED __declspec(dllimport) +# define LIBINTL_DLL_EXPORTED __attribute__((__visibility__("default"))) +#elif (defined _WIN32 && !defined __CYGWIN__) && @WOE32DLL@ && BUILDING_LIBINTL +/* 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 LIBINTL_DLL_EXPORTED __declspec(dllexport) +# else +# define LIBINTL_DLL_EXPORTED +# endif +#elif (defined _WIN32 && !defined __CYGWIN__) && @WOE32DLL@ +# define LIBINTL_DLL_EXPORTED __declspec(dllimport) #else -#define LIBINTL_DLL_EXPORTED +# define LIBINTL_DLL_EXPORTED #endif 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