Gnulib setenv on Mac OS X bug?
There seems to be a bug in Gnulib's setenv module on Mac OS X. At configure time it says: checking whether setenv validates arguments ... no (The test program it is running is: | int | main () | { | | if (setenv ("", "", 0) != -1) return 1; | if (errno != EINVAL) return 2; | if (setenv ("a", "=", 1) != 0) return 3; | if (strcmp (getenv ("a"), "=") != 0) return 4; | | ; | return 0; | } and this returns status code 4) As a result, in stdlib.h, this: #if @GNULIB_SETENV@ # if @REPLACE_SETENV@ # undef setenv # define setenv rpl_setenv is replaced by: #if 1 # if 1 # undef setenv # define setenv rpl_setenv However, no rpl_setenv function is getting generated in libgnu.a, so of course the program fails to link. Any ideas? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Hi, Richard W.M. Jones wrote:
There seems to be a bug in Gnulib's setenv module on Mac OS X. At configure time it says:
checking whether setenv validates arguments ... no
(The test program it is running is:
| int | main () | { | | if (setenv ("", "", 0) != -1) return 1; | if (errno != EINVAL) return 2; | if (setenv ("a", "=", 1) != 0) return 3; | if (strcmp (getenv ("a"), "=") != 0) return 4; | | ; | return 0; | }
and this returns status code 4)
This is normal. It's a small bug in the system's setenv routine.
As a result, in stdlib.h, this:
#if @GNULIB_SETENV@ # if @REPLACE_SETENV@ # undef setenv # define setenv rpl_setenv
is replaced by:
#if 1 # if 1 # undef setenv # define setenv rpl_setenv
This is expected too.
However, no rpl_setenv function is getting generated in libgnu.a
If you do $ grep LIBOBJ config.status you should see something like this: S["gl_LTLIBOBJS"]=" setenv.lo" S["gl_LIBOBJS"]=" setenv.o" If you do $ grep -i _setenv config.status you should see something like this (among others): S["REPLACE_SETENV"]="1" S["HAVE_SETENV"]="1" S["GNULIB_SETENV"]="1" If not, then please show the details. Bruno
On Sun, Mar 21, 2010 at 11:18:16PM +0100, Bruno Haible wrote:
If you do $ grep LIBOBJ config.status you should see something like this: S["gl_LTLIBOBJS"]=" setenv.lo" S["gl_LIBOBJS"]=" setenv.o"
$ grep LIBOBJ config.status | grep -i setenv s,@gltests_LIBOBJS@,|#_!!_#| getugroups.o imaxtostr.o mgetgroups.o offtostr.o putenv.o setenv.o symlink.o uinttostr.o umaxtostr.o unlinkdir.o,g s,@gltests_LTLIBOBJS@,|#_!!_#| getugroups.lo imaxtostr.lo mgetgroups.lo offtostr.lo putenv.lo setenv.lo symlink.lo uinttostr.lo umaxtostr.lo unlinkdir.lo,g
If you do $ grep -i _setenv config.status you should see something like this (among others): S["REPLACE_SETENV"]="1" S["HAVE_SETENV"]="1" S["GNULIB_SETENV"]="1"
$ grep -i _setenv config.status s,@GNULIB_SETENV@,|#_!!_#|1,g s,@HAVE_SETENV@,|#_!!_#|1,g s,@REPLACE_SETENV@,|#_!!_#|1,g s,^\([ #]*\)[^ ]*\([ ]*HAVE_SETENV\)[ (].*,\1define\2 1 , s,^\([ #]*\)[^ ]*\([ ]*HAVE_RAW_DECL_SETENV\)[ (].*,\1define\2 1 , Hope that helps. BTW, OS X by default comes with an ancient version of autoconf, 2.61, if that affects things. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones wrote:
If you do
$ grep LIBOBJ config.status you should see something like this: S["gl_LTLIBOBJS"]=" setenv.lo" S["gl_LIBOBJS"]=" setenv.o"
$ grep LIBOBJ config.status | grep -i setenv s,@gltests_LIBOBJS@,|#_!!_#| getugroups.o imaxtostr.o mgetgroups.o offtostr.o putenv.o setenv.o symlink.o uinttostr.o umaxtostr.o unlinkdir.o,g s,@gltests_LTLIBOBJS@,|#_!!_#| getugroups.lo imaxtostr.lo mgetgroups.lo offtostr.lo putenv.lo setenv.lo symlink.lo uinttostr.lo umaxtostr.lo unlinkdir.lo,g
If you do $ grep -i _setenv config.status you should see something like this (among others): S["REPLACE_SETENV"]="1" S["HAVE_SETENV"]="1" S["GNULIB_SETENV"]="1"
$ grep -i _setenv config.status s,@GNULIB_SETENV@,|#_!!_#|1,g s,@HAVE_SETENV@,|#_!!_#|1,g s,@REPLACE_SETENV@,|#_!!_#|1,g s,^\([ #]*\)[^ ]*\([ ]*HAVE_SETENV\)[ (].*,\1define\2 1 , s,^\([ #]*\)[^ ]*\([ ]*HAVE_RAW_DECL_SETENV\)[ (].*,\1define\2 1 ,
This is all as expected. Now you have to turn to your Makefile, and see whether these gl_LIBOBJS are correctly reflected in that Makefile, and why the setenv.o is not being built.
BTW, OS X by default comes with an ancient version of autoconf, 2.61, if that affects things.
This should not be a problem. Gnulib supports all autoconf versions >= 2.59 (see the DEPENDENCIES file).
The logic behind how Gnulib chooses whether or not to include the replacement function is fiendishly complex. Is there any way to force it to include the replacement function?
Gnulib has already chosen to build the replacement function for setenv(). But something in or near your Makefiles is causing a problem. Bruno
On Mon, Mar 22, 2010 at 12:04:58AM +0100, Bruno Haible wrote:
This is all as expected. Now you have to turn to your Makefile, and see whether these gl_LIBOBJS are correctly reflected in that Makefile, and why the setenv.o is not being built.
Part of the reason why setenv.o isn't being built is that setenv.c doesn't exist. It isn't copied into the local directory by gnulib-tool. That led me to realize that the setenv module wasn't being mentioned directly in my invocation of gnulib-tool. It seems like it was previously being pulled in as a dependency of something. I have added it as an explicit module, and now everything works. Why would it not get setenv.c when pulled in as a dependency, but get it when listed explicitly? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones wrote:
Part of the reason why setenv.o isn't being built is that setenv.c doesn't exist. It isn't copied into the local directory by gnulib-tool.
That led me to realize that the setenv module wasn't being mentioned directly in my invocation of gnulib-tool. It seems like it was previously being pulled in as a dependency of something. I have added it as an explicit module, and now everything works.
This should be needed only if your program uses the setenv() function. Was setenv.c being pulled into the gltests/, maybe? Your experience is very similar to the one Jim experienced today: <http://lists.gnu.org/archive/html/bug-gnulib/2010-03/msg00277.html> Bruno
participants (2)
-
Bruno Haible -
Richard W.M. Jones