* Re: environ: fix link error on 64-bit Cygwin
[not found] <36131639.liFsmjX0ip@omega>
@ 2018-01-31 13:53 ` Eric Blake
2018-01-31 14:40 ` Corinna Vinschen
0 siblings, 1 reply; 5+ messages in thread
From: Eric Blake @ 2018-01-31 13:53 UTC (permalink / raw)
To: The Cygwin Mailing List
[-- Attachment #1.1: Type: text/plain, Size: 2659 bytes --]
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:
>
> $ /bin/sh ../libtool --tag=CC --preserve-dup-deps --mode=link x86_64-pc-cygwin-gcc -g -O2 -L/usr/local/cygwin64/lib -Wl,--disable-auto-import -o test-environ.exe test-environ.o libtests.a ../lib/libunistring.la libtests.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]+0x0): undefined reference to `environ'
> collect2: error: ld returned 1 exit status
>
> This fixes it.
>
>
> 2018-01-31 Bruno Haible <bruno@clisp.org>
>
> 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.
>
> diff --git a/doc/posix-functions/environ.texi b/doc/posix-functions/environ.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 workaround: 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
>
> 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 - "
>
>
> #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 <unistd.h> lacks 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=VALUE", terminated with a NULL. */
>
>
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: environ: fix link error on 64-bit Cygwin
2018-01-31 13:53 ` environ: fix link error on 64-bit Cygwin Eric Blake
@ 2018-01-31 14:40 ` Corinna Vinschen
2018-02-26 21:28 ` Ken Brown
0 siblings, 1 reply; 5+ messages in thread
From: Corinna Vinschen @ 2018-01-31 14:40 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1137 bytes --]
On Jan 31 07:52, Eric Blake wrote:
> Forwarding from the gnulib list; is this something we should fix in
> cygwin proper?
Why does anybody remove the -Wl,--disable-auto-import flag? What for?
The idea was to never use this flag on Cygwin and to get rid of the
dllimport/dllexport nonsense...
> On 01/31/2018 04:42 AM, Bruno Haible wrote:
> > On 64-bit Cygwin, a libunistring build fails like this:
> > [...]
> > 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]+0x0): undefined reference to `environ'
> > collect2: error: ld returned 1 exit status
> >
> > This fixes it.
> > [...]
> > +_GL_EXTERN_C __declspec(dllimport) char **environ;
But, other than that, an equivalent newlib patch would be ok.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: environ: fix link error on 64-bit Cygwin
2018-01-31 14:40 ` Corinna Vinschen
@ 2018-02-26 21:28 ` Ken Brown
2018-02-27 10:38 ` Corinna Vinschen
2018-02-27 14:10 ` cyg Simple
0 siblings, 2 replies; 5+ messages in thread
From: Ken Brown @ 2018-02-26 21:28 UTC (permalink / raw)
To: cygwin
On 1/31/2018 9:40 AM, Corinna Vinschen wrote:
> On Jan 31 07:52, Eric Blake wrote:
>> Forwarding from the gnulib list; is this something we should fix in
>> cygwin proper?
>
> Why does anybody remove the -Wl,--disable-auto-import flag? What for?
> The idea was to never use this flag on Cygwin and to get rid of the
> dllimport/dllexport nonsense...
>
>> On 01/31/2018 04:42 AM, Bruno Haible wrote:
>>> On 64-bit Cygwin, a libunistring build fails like this:
>>> [...]
>>> 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]+0x0): undefined reference to `environ'
>>> collect2: error: ld returned 1 exit status
>>>
>>> This fixes it.
>>> [...]
>>> +_GL_EXTERN_C __declspec(dllimport) char **environ;
>
> But, other than that, an equivalent newlib patch would be ok.
Before patching newlib, please note that Bruno's patch doesn't work on
32-bit Cygwin. Projects (like emacs and clisp) that use gnulib's unistd
module with that patch will get link errors like this:
undefined reference to `_imp__environ'
I have no idea why this error occurs only on 32-bit.
I've made Bruno aware of the problem, and I'm waiting to see what he
comes up with.
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: environ: fix link error on 64-bit Cygwin
2018-02-26 21:28 ` Ken Brown
@ 2018-02-27 10:38 ` Corinna Vinschen
2018-02-27 14:10 ` cyg Simple
1 sibling, 0 replies; 5+ messages in thread
From: Corinna Vinschen @ 2018-02-27 10:38 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1771 bytes --]
On Feb 26 16:28, Ken Brown wrote:
> On 1/31/2018 9:40 AM, Corinna Vinschen wrote:
> > On Jan 31 07:52, Eric Blake wrote:
> > > Forwarding from the gnulib list; is this something we should fix in
> > > cygwin proper?
> >
> > Why does anybody remove the -Wl,--disable-auto-import flag? What for?
> > The idea was to never use this flag on Cygwin and to get rid of the
> > dllimport/dllexport nonsense...
> >
> > > On 01/31/2018 04:42 AM, Bruno Haible wrote:
> > > > On 64-bit Cygwin, a libunistring build fails like this:
> > > > [...]
> > > > 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]+0x0): undefined reference to `environ'
> > > > collect2: error: ld returned 1 exit status
> > > >
> > > > This fixes it.
> > > > [...]
> > > > +_GL_EXTERN_C __declspec(dllimport) char **environ;
> >
> > But, other than that, an equivalent newlib patch would be ok.
>
> Before patching newlib, please note that Bruno's patch doesn't work on
> 32-bit Cygwin. Projects (like emacs and clisp) that use gnulib's unistd
> module with that patch will get link errors like this:
>
> undefined reference to `_imp__environ'
>
> I have no idea why this error occurs only on 32-bit.
>
> I've made Bruno aware of the problem, and I'm waiting to see what he comes
> up with.
No worries. I'll wait patiently for a newlib patch.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: environ: fix link error on 64-bit Cygwin
2018-02-26 21:28 ` Ken Brown
2018-02-27 10:38 ` Corinna Vinschen
@ 2018-02-27 14:10 ` cyg Simple
1 sibling, 0 replies; 5+ messages in thread
From: cyg Simple @ 2018-02-27 14:10 UTC (permalink / raw)
To: cygwin
On 2/26/2018 4:28 PM, Ken Brown wrote:
> On 1/31/2018 9:40 AM, Corinna Vinschen wrote:
>> On Jan 31 07:52, Eric Blake wrote:
>>> Forwarding from the gnulib list; is this something we should fix in
>>> cygwin proper?
>>
>> Why does anybody remove the -Wl,--disable-auto-import flag? What for?
>> The idea was to never use this flag on Cygwin and to get rid of the
>> dllimport/dllexport nonsense...
>>
>>> On 01/31/2018 04:42 AM, Bruno Haible wrote:
>>>> On 64-bit Cygwin, a libunistring build fails like this:
>>>> [...]
>>>> 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]+0x0):
>>>> undefined reference to `environ'
>>>> collect2: error: ld returned 1 exit status
>>>>
>>>> This fixes it.
>>>> [...]
>>>> +_GL_EXTERN_C __declspec(dllimport) char **environ;
>>
>> But, other than that, an equivalent newlib patch would be ok.
>
> Before patching newlib, please note that Bruno's patch doesn't work on
> 32-bit Cygwin. Projects (like emacs and clisp) that use gnulib's unistd
> module with that patch will get link errors like this:
>
> Â undefined reference to `_imp__environ'
>
> I have no idea why this error occurs only on 32-bit.
>
> I've made Bruno aware of the problem, and I'm waiting to see what he
> comes up with.
>
_imp__environ? Shouldn't that be _imp_environ for Cygwin?
_imp__environ to me indicates the VC version of char **_environ instead.
Is the correct header being used?
--
cyg Simple
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-27 14:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <36131639.liFsmjX0ip@omega>
2018-01-31 13:53 ` environ: fix link error on 64-bit Cygwin Eric Blake
2018-01-31 14:40 ` Corinna Vinschen
2018-02-26 21:28 ` Ken Brown
2018-02-27 10:38 ` Corinna Vinschen
2018-02-27 14:10 ` cyg Simple
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).