Re: environ: fix link error on 64-bit Cygwin

2018-02-27 Thread cyg Simple
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



Re: environ: fix link error on 64-bit Cygwin

2018-02-27 Thread Corinna Vinschen
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


signature.asc
Description: PGP signature


Re: environ: fix link error on 64-bit Cygwin

2018-02-26 Thread Ken Brown

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



Re: environ: fix link error on 64-bit Cygwin

2018-01-31 Thread Corinna Vinschen
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


signature.asc
Description: PGP signature


Re: environ: fix link error on 64-bit Cygwin

2018-01-31 Thread Eric Blake
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  <br...@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  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



signature.asc
Description: OpenPGP digital signature