* Silence compiler warning on @ 2006-04-18 9:40 Mark Kettenis 2006-04-18 23:50 ` Ian Lance Taylor 2006-05-04 18:39 ` Daniel Jacobowitz 0 siblings, 2 replies; 7+ messages in thread From: Mark Kettenis @ 2006-04-18 9:40 UTC (permalink / raw) To: binutils Right now, when I compile BFD on HP-UX 10.20, I get the following warning (wich is fatal because of -Werror): /export/jive/kettenis/src/gdb/bfd/bfd.c: In function `_bfd_abort': /export/jive/kettenis/src/gdb/bfd/bfd.c:801: warning: `noreturn' function does return The problem here is that the system headers don't declare _exit() with __attribute__((noreturn). Previously we didn't get this warning because _bfd_abort() called xexit(), which was declared with __attribute__((noreturn)) (and xexit.c was compiled without -Werror). The attached patch is an attempt to fix this. Ok? Index: ChangeLog from Mark Kettenis <kettenis@jive.nl> * bfd.c (_bfd_abort): Provide prototype for _exit with ATTRIBUTE_NORETURN. Index: bfd.c =================================================================== RCS file: /cvs/src/src/bfd/bfd.c,v retrieving revision 1.81 diff -u -p -r1.81 bfd.c --- bfd.c 16 Mar 2006 12:20:15 -0000 1.81 +++ bfd.c 18 Apr 2006 08:58:52 -0000 @@ -783,6 +783,9 @@ bfd_assert (const char *file, int line) void _bfd_abort (const char *file, int line, const char *fn) { + /* Make sure the compiler knows _exit doesn't return. */ + extern void _exit (int) ATTRIBUTE_NORETURN; + if (fn != NULL) (*_bfd_error_handler) (_("BFD %s internal error, aborting at %s line %d in %s\n"), ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Silence compiler warning on 2006-04-18 9:40 Silence compiler warning on Mark Kettenis @ 2006-04-18 23:50 ` Ian Lance Taylor 2006-04-19 7:44 ` Mark Kettenis 2006-05-04 18:39 ` Daniel Jacobowitz 1 sibling, 1 reply; 7+ messages in thread From: Ian Lance Taylor @ 2006-04-18 23:50 UTC (permalink / raw) To: Mark Kettenis; +Cc: binutils Mark Kettenis <mark.kettenis@xs4all.nl> writes: > Index: ChangeLog > from Mark Kettenis <kettenis@jive.nl> > > * bfd.c (_bfd_abort): Provide prototype for _exit with > ATTRIBUTE_NORETURN. I think something like this should use AC_CHECK_DECLS to avoid a conflict with the system header files. Ian ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Silence compiler warning on 2006-04-18 23:50 ` Ian Lance Taylor @ 2006-04-19 7:44 ` Mark Kettenis 2006-04-19 8:22 ` Ian Lance Taylor 0 siblings, 1 reply; 7+ messages in thread From: Mark Kettenis @ 2006-04-19 7:44 UTC (permalink / raw) To: ian; +Cc: binutils > From: Ian Lance Taylor <ian@airs.com> > Date: 18 Apr 2006 16:13:59 -0700 > > Mark Kettenis <mark.kettenis@xs4all.nl> writes: > > > Index: ChangeLog > > from Mark Kettenis <kettenis@jive.nl> > > > > * bfd.c (_bfd_abort): Provide prototype for _exit with > > ATTRIBUTE_NORETURN. > > I think something like this should use AC_CHECK_DECLS to avoid a > conflict with the system header files. I fail to see how that would work. I'm not trying to add a missing prototype; I'm trying to augment a prototype with a noreturn attribute. A conflict with the system header files seems rather unlikely; the only variation I could imagine, is that some (pre ISO C) header files fail to provide the proper return type. Mark ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Silence compiler warning on 2006-04-19 7:44 ` Mark Kettenis @ 2006-04-19 8:22 ` Ian Lance Taylor 0 siblings, 0 replies; 7+ messages in thread From: Ian Lance Taylor @ 2006-04-19 8:22 UTC (permalink / raw) To: Mark Kettenis; +Cc: binutils Mark Kettenis <mark.kettenis@xs4all.nl> writes: > > From: Ian Lance Taylor <ian@airs.com> > > Date: 18 Apr 2006 16:13:59 -0700 > > > > Mark Kettenis <mark.kettenis@xs4all.nl> writes: > > > > > Index: ChangeLog > > > from Mark Kettenis <kettenis@jive.nl> > > > > > > * bfd.c (_bfd_abort): Provide prototype for _exit with > > > ATTRIBUTE_NORETURN. > > > > I think something like this should use AC_CHECK_DECLS to avoid a > > conflict with the system header files. > > I fail to see how that would work. I'm not trying to add a missing > prototype; I'm trying to augment a prototype with a noreturn attribute. You're right, AC_CHECK_DECLS isn't the right thing to use. What is needed is some test to make sure that you can compile code with the declaration that you want to add. > A conflict with the system header files seems rather unlikely; the > only variation I could imagine, is that some (pre ISO C) header files > fail to provide the proper return type. _exit is not an ISO C function. System header files are sadly unreliable when it comes to declaring functions. If the system header file happens to declare the function in some incompatible way--say it uses unsigned int--then you will introduce a build failure. I think it's safer to use an autoconf test to see whether the prototype declaration is safe. We've had unfortunate experiences over the years with attempts to declare functions which should be declared in system header files. Ian ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Silence compiler warning on 2006-04-18 9:40 Silence compiler warning on Mark Kettenis 2006-04-18 23:50 ` Ian Lance Taylor @ 2006-05-04 18:39 ` Daniel Jacobowitz 2006-05-05 12:20 ` Mark Kettenis 1 sibling, 1 reply; 7+ messages in thread From: Daniel Jacobowitz @ 2006-05-04 18:39 UTC (permalink / raw) To: Mark Kettenis; +Cc: binutils On Tue, Apr 18, 2006 at 11:12:57AM +0200, Mark Kettenis wrote: > Right now, when I compile BFD on HP-UX 10.20, I get the following > warning (wich is fatal because of -Werror): > > /export/jive/kettenis/src/gdb/bfd/bfd.c: In function `_bfd_abort': > /export/jive/kettenis/src/gdb/bfd/bfd.c:801: warning: `noreturn' function does return > > The problem here is that the system headers don't declare _exit() with > __attribute__((noreturn). Previously we didn't get this warning > because _bfd_abort() called xexit(), which was declared with > __attribute__((noreturn)) (and xexit.c was compiled without -Werror). > > The attached patch is an attempt to fix this. Ok? > > > Index: ChangeLog > from Mark Kettenis <kettenis@jive.nl> > > * bfd.c (_bfd_abort): Provide prototype for _exit with > ATTRIBUTE_NORETURN. I would like this fixed before binutils 2.17. Does something like this work for you? -- Daniel Jacobowitz CodeSourcery 2006-05-04 Daniel Jacobiwtz <dan@codesourcery.com> * configure.in: Check if _exit with ATTRIBUTE_NORETURN is OK. * bfd.c (_bfd_abort): Handle USE_EXIT_NORETURN. * configure, config.in: Regenerated. Index: configure.in =================================================================== RCS file: /cvs/src/src/bfd/configure.in,v retrieving revision 1.206 diff -u -p -r1.206 configure.in --- configure.in 16 Apr 2006 18:01:02 -0000 1.206 +++ configure.in 4 May 2006 18:37:57 -0000 @@ -159,6 +159,19 @@ AC_CHECK_DECLS(strstr) AC_CHECK_DECLS(snprintf) AC_CHECK_DECLS(vsnprintf) +# At least HP-UX 10.20 declares _exit without noreturn. If we can +# add the attribute ourselves, we'll do so. +AC_CACHE_CHECK([if we can redeclare _exit], bfd_cv_exit_noreturn, +[AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([#include "../include/ansidecl.h"], + [[extern void _exit (int) ATTRIBUTE_NORETURN; _exit (0);]])], + [bfd_cv_exit_noreturn=yes], + [bfd_cv_exit_noreturn=no])]) +if test "$bfd_cv_exit_noreturn" = yes; then + AC_DEFINE(USE_EXIT_NORETURN, 1, + [Define if redeclaring _exit with noreturn is OK]) +fi + # If we are configured native, pick a core file support file. COREFILE= COREFLAG= Index: bfd.c =================================================================== RCS file: /cvs/src/src/bfd/bfd.c,v retrieving revision 1.81 diff -u -p -r1.81 bfd.c --- bfd.c 16 Mar 2006 12:20:15 -0000 1.81 +++ bfd.c 4 May 2006 18:37:57 -0000 @@ -783,6 +783,10 @@ bfd_assert (const char *file, int line) void _bfd_abort (const char *file, int line, const char *fn) { +#ifdef USE_EXIT_NORETURN + /* Make sure the compiler knows _exit doesn't return. */ + extern void _exit (int) ATTRIBUTE_NORETURN; +#endif if (fn != NULL) (*_bfd_error_handler) (_("BFD %s internal error, aborting at %s line %d in %s\n"), ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Silence compiler warning on 2006-05-04 18:39 ` Daniel Jacobowitz @ 2006-05-05 12:20 ` Mark Kettenis 2006-05-05 13:07 ` Daniel Jacobowitz 0 siblings, 1 reply; 7+ messages in thread From: Mark Kettenis @ 2006-05-05 12:20 UTC (permalink / raw) To: drow; +Cc: binutils > Date: Thu, 4 May 2006 14:39:30 -0400 > From: Daniel Jacobowitz <drow@false.org> > > On Tue, Apr 18, 2006 at 11:12:57AM +0200, Mark Kettenis wrote: > > Right now, when I compile BFD on HP-UX 10.20, I get the following > > warning (wich is fatal because of -Werror): > > > > /export/jive/kettenis/src/gdb/bfd/bfd.c: In function `_bfd_abort': > > /export/jive/kettenis/src/gdb/bfd/bfd.c:801: warning: `noreturn' function does return > > > > The problem here is that the system headers don't declare _exit() with > > __attribute__((noreturn). Previously we didn't get this warning > > because _bfd_abort() called xexit(), which was declared with > > __attribute__((noreturn)) (and xexit.c was compiled without -Werror). > > > > The attached patch is an attempt to fix this. Ok? > > > > Index: ChangeLog > > from Mark Kettenis <kettenis@jive.nl> > > > > * bfd.c (_bfd_abort): Provide prototype for _exit with > > ATTRIBUTE_NORETURN. > > I would like this fixed before binutils 2.17. Does something like this > work for you? Unfortunately not :( configure:11800: checking if we can redeclare _exit configure:11821: gcc -c -g -O2 conftest.c >&5 conftest.c:80: ../include/ansidecl.h: No such file or directory However, it seems that this only happens with GCC 2.95.3 (and probably older versions). Newer GCC versions seem to be aware of the fact that _exit() will never return. Perhaps people should just upgrade to a newer GCC or use --disable-werror. There is another nasty configure issue on HP-UX 10.20 though. I'll try to finish the patch I was working on today. > 2006-05-04 Daniel Jacobiwtz <dan@codesourcery.com> > > * configure.in: Check if _exit with ATTRIBUTE_NORETURN is OK. > * bfd.c (_bfd_abort): Handle USE_EXIT_NORETURN. > * configure, config.in: Regenerated. Mark ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Silence compiler warning on 2006-05-05 12:20 ` Mark Kettenis @ 2006-05-05 13:07 ` Daniel Jacobowitz 0 siblings, 0 replies; 7+ messages in thread From: Daniel Jacobowitz @ 2006-05-05 13:07 UTC (permalink / raw) To: Mark Kettenis; +Cc: binutils On Fri, May 05, 2006 at 11:41:18AM +0200, Mark Kettenis wrote: > Unfortunately not :( > > configure:11800: checking if we can redeclare _exit > configure:11821: gcc -c -g -O2 conftest.c >&5 > conftest.c:80: ../include/ansidecl.h: No such file or directory !!! How the heck did that work for me? Oh, there's an <ansidecl.h> on this system... > However, it seems that this only happens with GCC 2.95.3 (and probably > older versions). Newer GCC versions seem to be aware of the fact that > _exit() will never return. Perhaps people should just upgrade to a > newer GCC or use --disable-werror. Yes, newer GCCs do automatically add attributes to system header functions. I'm just going to punt then; you can take another shot at it if you'd like :-) -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-05-05 12:23 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2006-04-18 9:40 Silence compiler warning on Mark Kettenis 2006-04-18 23:50 ` Ian Lance Taylor 2006-04-19 7:44 ` Mark Kettenis 2006-04-19 8:22 ` Ian Lance Taylor 2006-05-04 18:39 ` Daniel Jacobowitz 2006-05-05 12:20 ` Mark Kettenis 2006-05-05 13:07 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).