X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=TCyc Ep/pY7wtGx5KD66QXokX3PnSQwDG22Nzvy3J970GjGRePimsJBvhBT4VNVjT/1oH bAJlDeGCp+xbeJpsxkREnp+Uqf5lH1byDVt1eqsUylePx2yeHlslenOVcUBwWPII n6Y1XzFCOYEP81JMnsJG4cSRD5nRWW3SzrLQ5HQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=MEQ06rQRxw uFRW9zshZpgCLYfmE=; b=FDle2laYf2q4JmG+2m3wbXsBe2EKub3IeWsHE3Cfn+ qe46sKT7TOO4tqV6w+5+XYFNYhY7B1qfPwxK+ybN1kklhsyW9xYYRwti2tN+C6d1 XkJEDYvrDj0BXO/n7BdKIrkPTHwHeIsHwYiMW4M1u2DUwirETALeZI+91MvHeRUb k= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 Subject: Re: environ: fix link error on 64-bit Cygwin To: The Cygwin Mailing List References: <36131639 DOT liFsmjX0ip AT 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 07:52:51 -0600 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 --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 AT redhat DOT com> Subject: Re: environ: fix link error on 64-bit Cygwin References: <36131639 DOT liFsmjX0ip AT omega> In-Reply-To: <36131639 DOT liFsmjX0ip AT omega> --vU6C0yBxDKKLhcmVSdXCKc47MdcOLoVPW Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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" -----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--