From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129095 invoked by alias); 31 Jan 2018 13:53:01 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 129067 invoked by uid 89); 31 Jan 2018 13:53:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=liconv, Bruno, bruno, Hx-languages-length:2584 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 31 Jan 2018 13:52:54 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 419114F1C1 for ; Wed, 31 Jan 2018 13:52:53 +0000 (UTC) Received: from [10.10.120.51] (ovpn-120-51.rdu2.redhat.com [10.10.120.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6076620D1 for ; Wed, 31 Jan 2018 13:52:52 +0000 (UTC) Subject: Re: environ: fix link error on 64-bit Cygwin To: The Cygwin Mailing List References: <36131639.liFsmjX0ip@omega> From: Eric Blake Openpgp: url=http://people.redhat.com/eblake/eblake.gpg Message-ID: <0d2666a8-1037-fc9c-a17f-72cc59e9d977@redhat.com> Date: Wed, 31 Jan 2018 13:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <36131639.liFsmjX0ip@omega> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YQRYWUxJ3gYp4RQVCfbtBR8PLNl7mMZaJ" X-IsSubscribed: yes X-SW-Source: 2018-01/txt/msg00293.txt.bz2 --YQRYWUxJ3gYp4RQVCfbtBR8PLNl7mMZaJ Content-Type: multipart/mixed; boundary="vU6C0yBxDKKLhcmVSdXCKc47MdcOLoVPW"; protected-headers="v1" From: Eric Blake To: The Cygwin Mailing List Message-ID: <0d2666a8-1037-fc9c-a17f-72cc59e9d977@redhat.com> Subject: Re: environ: fix link error on 64-bit Cygwin References: <36131639.liFsmjX0ip@omega> In-Reply-To: <36131639.liFsmjX0ip@omega> --vU6C0yBxDKKLhcmVSdXCKc47MdcOLoVPW Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Content-length: 2659 Forwarding from the gnulib list; is this something we should fix in cygwin proper? On 01/31/2018 04:42 AM, Bruno Haible wrote: > On 64-bit Cygwin, a libunistring build fails like this: >=20 > $ /bin/sh ../libtool --tag=3DCC --preserve-dup-deps --mode=3Dlink x86_6= 4-pc-cygwin-gcc -g -O2 -L/usr/local/cygwin64/lib -Wl,--disable-auto-impor= t -o test-environ.exe test-environ.o libtests.a ../lib/libunistring.la libt= ests.a > libtool: link: x86_64-pc-cygwin-gcc -g -O2 -Wl,--disable-auto-import -o .= libs/test-environ.exe test-environ.o -L/usr/local/cygwin64/lib libtests.a = ../lib/.libs/libunistring.dll.a -liconv libtests.a -L/usr/local/cygwin64/lib > test-environ.o:test-environ.c:(.rdata$.refptr.environ[.refptr.environ]+0x= 0): undefined reference to `environ' > collect2: error: ld returned 1 exit status >=20 > This fixes it. >=20 >=20 > 2018-01-31 Bruno Haible >=20 > environ: Fix link error on 64-bit Cygwin. > * lib/unistd.in.h (environ): On Cygwin, redeclare with the > __declspec(dllimport) attribute. > * doc/posix-functions/environ.texi: Mention the Cygwin problem. >=20 > diff --git a/doc/posix-functions/environ.texi b/doc/posix-functions/envir= on.texi > index 34ac25a..a6c0095 100644 > --- a/doc/posix-functions/environ.texi > +++ b/doc/posix-functions/environ.texi > @@ -24,6 +24,9 @@ shared libraries on Mac OS X 10.5. Here is a workaroun= d: Instead, one can use > #define environ (*_NSGetEnviron()) > @end smallexample > This works at all versions of Mac OS X. > +@item > +On Cygwin in 64-bit mode, references to this variable cause a link error= when > +the option @code{-Wl,--disable-auto-import} is in use. > @end itemize >=20=20 > Portability problems not fixed by Gnulib: > diff --git a/lib/unistd.in.h b/lib/unistd.in.h > index 6802e3b..4ef0ffa 100644 > --- a/lib/unistd.in.h > +++ b/lib/unistd.in.h > @@ -400,6 +400,13 @@ _GL_WARN_ON_USE (dup3, "dup3 is unportable - " >=20=20 >=20=20 > #if @GNULIB_ENVIRON@ > +# if defined __CYGWIN__ > +/* The 'environ' variable is defined in a DLL. Therefore its declaration= needs > + the '__declspec(dllimport)' attribute, but the system's la= cks it. > + This leads to a link error on 64-bit Cygwin when the option > + -Wl,--disable-auto-import is in use. */ > +_GL_EXTERN_C __declspec(dllimport) char **environ; > +# endif > # if !@HAVE_DECL_ENVIRON@ > /* Set of environment variables and values. An array of strings of the = form > "VARIABLE=3DVALUE", terminated with a NULL. */ >=20 >=20 >=20 --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org --vU6C0yBxDKKLhcmVSdXCKc47MdcOLoVPW-- --YQRYWUxJ3gYp4RQVCfbtBR8PLNl7mMZaJ Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 619 -----BEGIN PGP SIGNATURE----- Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAlpxyjQACgkQp6FrSiUn Q2prlQf+JLi4QGxW4340aQl7MyEAN6cY9EPYKQvtWNq15tD616eskdRVzZI/kW9a ZdSrDYQ0CVEO11PfyW/AbTvc7CY8y2s6bCjbjpgjXeHWKAhia2z1Z3Yz1apmJ6Qt YpNnztEImA+yfqRFxPOh7a8VhubBpHGPjKD3Vi+Xy0+yteerUtFMThXvZmLJ6VjB WPbBaC0jeRpbQuhW2KTTFObf0vttCPCrCqj5FE24Kf381ZuJ2wmBBz7Sg7ryiiDZ oBDAWenMBoIfLV8vvp+AzD6K7cghhg/PA0ohVhdvrL5/5hh1PcsoauFKSGWZO5mw p6OKWWB0eeTr3npHwyasNhAVCYpE6A== =v66N -----END PGP SIGNATURE----- --YQRYWUxJ3gYp4RQVCfbtBR8PLNl7mMZaJ--