Note that dllimport/dllexport decorations are not at all required on Cygwin for quite some time.
Worse, this breaks building DLLs and DLL import libs using libtool. On Cygwin --export-all-symbols is default. However, if just a single symbol is decorated with dllexport, ld switches to exporting only these symbols. So, when creating DLLs and DLL import libs which are also linked against libgnu.a, the result is that the actual DLL (i. e. cygfoo-1.dll) contains all symbols of all object files given on the command line. However, the DLL import lib (i. e. libfoo.dll.a) will contain only the default symbols and the single symbol gl_get_setlocale_null_lock. This in turn breaks linking against the just created cygfoo-1.dll. An example of that is current recode. Building this package with --enable-shared is broken, unless one adds -Wl,--export-all-symbols to the link stage command line explicitely, because of the decorated gl_get_setlocale_null_lock variable. Fix this by dropping the dllexport decoration when building for the Cygwin target. * lib/setlocale-lock.c: don't decorate gl_get_setlocale_null_lock as dllexport on Cygwin. * lib/setlocale_null.c: don't dllimport gl_get_setlocale_null_lock on Cygwin. --- lib/setlocale-lock.c | 2 +- lib/setlocale_null.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/setlocale-lock.c b/lib/setlocale-lock.c index b70ba09b0020..ab23cadd2939 100644 --- a/lib/setlocale-lock.c +++ b/lib/setlocale-lock.c @@ -41,7 +41,7 @@ typedef int dummy; # if HAVE_VISIBILITY /* Override the effect of the compiler option '-fvisibility=hidden'. */ # define DLL_EXPORTED __attribute__((__visibility__("default"))) -# elif defined _WIN32 || defined __CYGWIN__ +# elif defined _WIN32 && !defined __CYGWIN__ # define DLL_EXPORTED __declspec(dllexport) # else # define DLL_EXPORTED diff --git a/lib/setlocale_null.c b/lib/setlocale_null.c index 6ac563db14a9..5bf04a5ad84d 100644 --- a/lib/setlocale_null.c +++ b/lib/setlocale_null.c @@ -201,7 +201,7 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize) # elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */ extern -# if defined _WIN32 || defined __CYGWIN__ +# if defined _WIN32 && !defined __CYGWIN__ __declspec(dllimport) # endif pthread_mutex_t *gl_get_setlocale_null_lock (void); -- 2.39.1