From: Bruno Haible Date: Wed, 31 Jan 2018 08:04:52 +0000 (+0100) Subject: environ: Fix link error on 64-bit Cygwin. X-Git-Tag: v1.0~5746 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=cf56f8f618c48cfadd2499ced58574633d12f129;p=gnulib.git 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/ChangeLog b/ChangeLog index ca0ea99b11..47566b7100 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2018-01-31 Bruno Haible + + 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. + 2018-01-30 Bruno Haible get-rusage-data: Add support for Minix 3. diff --git a/doc/posix-functions/environ.texi b/doc/posix-functions/environ.texi index 34ac25ad82..a6c00958da 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 6802e3b60c..4ef0ffabb8 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. */