Message ID | 708e46d4-2d8b-247f-0120-0548d20b0f25@acm.org |
---|---|
State | New |
Headers | show |
Series | bootstrap: Don't use strsignal [PR 98300] | expand |
On Thu, Dec 17, 2020 at 09:06:57AM -0500, Nathan Sidwell wrote: > > Sadly strsignal is nonportable, so signal numbers it is then. > > c++tools/ > * server.cc (crash_signal): Don't use strsignal. Strange. It is portable, we even have a fallback implementation for it in libiberty. And toplev.c certainly uses it. Looking at gcc/configure.ac, there is: AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \ popen sysconf strsignal getrusage nl_langinfo \ gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \ gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat) and gcc_AC_CHECK_DECLS(getenv atol atoll asprintf sbrk abort atof getcwd getwd \ madvise stpcpy strnlen strsignal strverscmp \ strtol strtoul strtoll strtoull setenv unsetenv \ errno snprintf vsnprintf vasprintf malloc realloc calloc \ free getopt clock getpagesize ffs gcc_UNLOCKED_FUNCS, , ,[ #include "ansidecl.h" #include "system.h"]) that refer to strsignal. So, I bet it is purely a matter of ensuring configure declares the function if it wasn't declared by the C library headers. system.h has: #ifdef __cplusplus extern "C" { #endif /* If the system doesn't provide strsignal, we get it defined in libiberty but no declaration is supplied. */ #if !defined (HAVE_STRSIGNAL) \ || (defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL) # ifndef strsignal extern const char *strsignal (int); # endif #endif > --- i/c++tools/server.cc > +++ w/c++tools/server.cc > @@ -213,7 +213,8 @@ static void ATTRIBUTE_NORETURN ATTRIBUTE_COLD > crash_signal (int sig) > { > signal (sig, SIG_DFL); > - internal_error ("signal %s", strsignal (sig)); > + // strsignal is not portable :( > + internal_error ("signal %d", sig); > } > > /* A fatal error of some kind. */ Jakub
diff --git i/c++tools/server.cc w/c++tools/server.cc index 6457dc5b878..8514ef6293b 100644 --- i/c++tools/server.cc +++ w/c++tools/server.cc @@ -213,7 +213,8 @@ static void ATTRIBUTE_NORETURN ATTRIBUTE_COLD crash_signal (int sig) { signal (sig, SIG_DFL); - internal_error ("signal %s", strsignal (sig)); + // strsignal is not portable :( + internal_error ("signal %d", sig); } /* A fatal error of some kind. */