Tested x86_64-pc-linux-gnu, and also manually changing the HAVE_DECL_STRCHRNUL flag. OK for trunk?
-- 8< -- The Contracts implementation uses strchrnul, which is a glibc extension, so bootstrap broke on non-glibc targets. I considered unconditionally using a local definition, but I guess we might as well use the libc version if it exists. PR c++/107781 gcc/cp/ChangeLog: * contracts.cc (strchrnul): Define if needed. gcc/ChangeLog: * configure.ac: Check for strchrnul. * config.in, configure: Regenerate. --- gcc/cp/contracts.cc | 12 ++++++++++++ gcc/config.in | 7 +++++++ gcc/configure.ac | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 26396439361..8b11f26ca27 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -204,6 +204,18 @@ lookup_concrete_semantic (const char *name) return CCS_INVALID; } +#if !HAVE_DECL_STRCHRNUL +/* strchrnul is a glibc extension. */ + +static const char * +strchrnul (const char *s, char c) +{ + if (auto p = strchr (s, c)) + return p; + return strchr (s, '\0'); +} +#endif + /* Compare role and name up to either the NUL terminator or the first occurrence of colon. */ diff --git a/gcc/config.in b/gcc/config.in index 38ef792bd67..4a5dfb4151c 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1126,6 +1126,13 @@ #endif +/* Define to 1 if we found a declaration for 'strchrnul', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#undef HAVE_DECL_STRCHRNUL +#endif + + /* Define to 1 if we found a declaration for 'strnlen', otherwise define to 0. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure.ac b/gcc/configure.ac index 7c55bff6cb0..1124ecfa218 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1581,7 +1581,7 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC" # normal autoconf function for these. But force definition of # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre # basename handling in libiberty.h. -AC_CHECK_DECLS([basename(const char*), strstr(const char*,const char*)], , ,[ +AC_CHECK_DECLS([basename(const char*), strchrnul(const char*, int), strstr(const char*,const char*)], , ,[ #undef HAVE_DECL_BASENAME #define HAVE_DECL_BASENAME 1 #include "ansidecl.h" base-commit: 5c0d171f67d082c353ddc319859111d3b9126c17 prerequisite-patch-id: 275d90e1bd8b940c1cca2840bc38dc4fafa0797b -- 2.31.1