Web lists-archives.com

Re: environ: fix link error on 64-bit 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.


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