From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 1B47B1F5A0 for ; Sun, 5 Feb 2023 21:23:01 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=P9bsVL5q; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOmTL-0002FZ-RY; Sun, 05 Feb 2023 16:22:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOmTL-0002FN-0b for bug-gnulib@gnu.org; Sun, 05 Feb 2023 16:22:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOmTI-0003bM-Rm for bug-gnulib@gnu.org; Sun, 05 Feb 2023 16:22:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675632167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=65dkBrZKCQcYLNhQNbXIJPlDmicZyTzO902cCuWqWCc=; b=P9bsVL5q/RkcOy2EyYWLDVmtUlyaranaRfb3AXRV+Juwyhgx1ntrET5YfL9Akf+csoEvGr tGHPk7QLSPOO5u3sATret6t8bjKK57EX3kFdXW9sfFoMqjls9eSVzwyNL+aaHJZprh7TUP JW+HFJc7qN/4p2Xmk8j8OO3pJYNGFpI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-264-T09I5Nu_MqObb78UG4AhiQ-1; Sun, 05 Feb 2023 16:22:44 -0500 X-MC-Unique: T09I5Nu_MqObb78UG4AhiQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E46FF1C0514D; Sun, 5 Feb 2023 21:22:43 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.192.107]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB02F18EC5; Sun, 5 Feb 2023 21:22:43 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 30FEEA80770; Sun, 5 Feb 2023 22:22:42 +0100 (CET) Date: Sun, 5 Feb 2023 22:22:42 +0100 From: Corinna Vinschen To: Bruno Haible , bug-gnulib@gnu.org Subject: Re: [PATCH] Do not decorate symbols as dllexport on Cygwin Message-ID: References: <20230205194344.269174-1-vinschen@redhat.com> <2995619.l0kZKy6ypc@nimes> MIME-Version: 1.0 In-Reply-To: <2995619.l0kZKy6ypc@nimes> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=vinschen@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org On Feb 5 21:41, Bruno Haible wrote: > Hi Corinna, > > Thanks for the heads-up and patch. > > > Note that dllimport/dllexport decorations are not at all required on > > Cygwin for quite some time. > > Is this true in all circumstances? I thought that when --disable-auto-import > is in use AND the shared library wants to export variables, dllimport > and dllexport decorations are necessary. > > > On Cygwin --export-all-symbols is default. However, if just a single > > symbol is decorated with dllexport, ld switches to exporting only these > > symbols. > > ... > > 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. > > So, there are three types of packages: > (A) Those that use --disable-auto-import (e.g. [1][2]) and provide an > explicit list of exports for their shared libraries. > (B) Those that don't use --disable-auto-import but want to limit > the exposed symbols for other reasons (e.g. namespace cleanliness). > Such as those that use the libtool options '-export-symbols' or > '-export-symbols-regex'. > (C) Those like 'recode', which want all symbols to be exported (e.g. > if namespace cleanliness is not an issue for them). > > For packages of type (A) or (B), the symbol gl_get_setlocale_null_lock > *MUST* be exported, otherwise there may be different get_setlocale_null_lock > functions accessed by different code, which will destroy the purpose of this > function, i.e. open the door to potential crashes due to use of setlocale(). > > For packages of type (C), the symbol gl_get_setlocale_null_lock *MUST NOT* > be exported, otherwise all other symbols will not be exported. > > AFAIU, your patch fixes packages of type (C), while at the same time breaking > packages of type (A) or (B). > > Is there an easy way to distinguish packages of type (C) from those of type > (A), (B)? > > Another option — since we are talking about a single symbol and a single > platform — would be if the locking for setlocale_null were not necessary > on Cygwin in the first place. I determined that it is necessary by running > the unit test gnulib/tests/test-setlocale_null-mt-all.c [3] on Cygwin: > without the lock, it crashed within less than 1 second. Could the > implementation of setlocale() in Cygwin be changed in such a way that this > test does not crash? Then the lock would be necessary. Well, we could do that by adding Cygwin-internal locking to setlocale calls. But that would only be available in the next Cygwin version of course. May I ask what's the idea to provide a thread-safe setlocale? It was never defined as thread-safe and POSIX explicitely mentions that. Any application expecting to call setlocale thread-safe is broken by design. It should use the newlocale/duplocale/uselocale/freelocale API instead, isn't it? Corinna > > Bruno > > [1] https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=blob;f=gettext-tools/woe32dll/export.h;hb=HEAD > [2] https://haible.de/bruno/woe32dll.html > [3] https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=tests/test-setlocale_null-mt-all.c;hb=HEAD > >