https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109293
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Xi Ruoyao <xry...@gcc.gnu.org>: https://gcc.gnu.org/g:743088c3c7c670f180978dd7b59a57fd9626c5a2 commit r12-9326-g743088c3c7c670f180978dd7b59a57fd9626c5a2 Author: Xi Ruoyao <xry...@xry111.site> Date: Tue Mar 28 01:48:02 2023 +0800 fixincludes: Declare memmem if it's not declared in system headers [PR109293] memmem is not POSIX so the system may lack it. Then libiberty will provide an implementation, but it's a "supplemental function" and not declared in libiberty.h. We need to declare the prototype to use it then. See libiberty doc at https://gcc.gnu.org/onlinedocs/libiberty/Supplemental-Functions.html. Tested by bootstrapping GCC in the following container environments on x86_64-linux-gnu: 1. "Vanilla" system with memmem in Glibc. 2. memmem removed from string.h. 3. memmem removed from both string.h and libc.so. For 3, also verified that memmem from libiberty is linked into fixincl executable. Note that the backport does not contain a complete regeneration of configure and config.h.in (attempting such regeneration resulted in all the USED_FOR_TARGET conditional disappearing; this already happened in trunk at r13-2200). fixincludes/ChangeLog: PR other/109293 * configure.ac (AC_CHECK_DECLS): Add memmem. * configure: Regenerate. * config.h.in: Regenerate. * system.h (memmem): Declare if HAVE_DECL_MEMMEM is zero. (cherry picked from commit 21c74b6ea41d21ef96813b34bfa55c51a82d6c99)