bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Corinna Vinschen <vinschen@redhat.com>
To: bug-gnulib@gnu.org
Subject: [PATCH] Do not decorate symbols as dllexport on Cygwin
Date: Sun,  5 Feb 2023 20:43:44 +0100	[thread overview]
Message-ID: <20230205194344.269174-1-vinschen@redhat.com> (raw)

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



             reply	other threads:[~2023-02-05 19:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-05 19:43 Corinna Vinschen [this message]
2023-02-05 20:41 ` [PATCH] Do not decorate symbols as dllexport on Cygwin Bruno Haible
2023-02-05 20:48   ` Bruno Haible
2023-02-05 21:22   ` Corinna Vinschen
2023-02-06 15:08     ` Corinna Vinschen
2023-02-06 16:36       ` Bruno Haible
2023-02-06 17:37       ` Bruno Haible
2023-02-06 20:04         ` Corinna Vinschen
2023-02-06 20:38           ` Bruno Haible
2023-02-06 20:43             ` Corinna Vinschen
2023-02-06 20:50             ` Reuben Thomas
2023-02-07 13:22               ` Corinna Vinschen
2023-02-07 15:22                 ` Corinna Vinschen
2023-02-10 14:11                   ` Reuben Thomas
2023-02-10 14:21                     ` Bruno Haible
2023-02-11 11:36                       ` Reuben Thomas
2023-02-11 12:06                         ` Corinna Vinschen
2023-02-11 12:29                           ` Reuben Thomas
2023-02-11 12:40                             ` Corinna Vinschen
2023-02-17  9:30                               ` Reuben Thomas
2023-02-17  9:58                                 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230205194344.269174-1-vinschen@redhat.com \
    --to=vinschen@redhat.com \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).