This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch/libiberty: Avoid clobbering dllimport attribute when declaring sys_nerr, sys_errlist, environ.


Danny Smith <danny_smith_0000@yahoo.co.nz> writes:

> 	* configure.ac: Add environ to AC_CHECK_DECLS.
> 	* configure: Regenerate.
> 	* config.in: Regenerate.
> 	* setenv.c: (environ): Check HAVE_DECL_ENVIRON not HAVE_ENVIRON_DECL.

These are OK.

> 	* strerror.c (sys_nerr): Don't declare if defined as macro by system header.
> 	(sys_errorlist): Likewise.

This is one is so fragile I can't approve it.  If you look at the top
of strerror.c, you will see that it tries to carefully hide the system
declarations of sys_nerr and sys_errlist in <stdio.h> and <errno.h>.
Your patch only works because later on somebody added an includes of
<stdlib.h> in which the declarations are not hidden.

The right fix is going to be to use AC_CHECK_DECLS on sys_nerr and
sys_errlist, and to only declare them if they do exist but are not
declared.

We could also observe that the only reason we are compiling strerror.c
at all is for the functions errno_max, strerrno and strtoerrno, none
of which are particularly interesting.  I can't find any code which
uses libiberty and actually calls these functions.  Linking against
libiberty/strerror.o gives me these warning on Fedora Core 4:

../../gcc/libiberty/strerror.c:593: warning: `sys_nerr' is deprecated; use `strerror' or `strerror_r' instead

I think we should consider removing those functions, and only
compiling strerror.c if the strerror function is not available (i.e.,
non-C90 libraries).

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]