https://gcc.gnu.org/g:d92d6e39580af4c946f6eb453dcbe6fd85d5e1f9

commit r17-5288-gd92d6e39580af4c946f6eb453dcbe6fd85d5e1f9
Author: Sam James <[email protected]>
Date:   Wed Oct 14 01:47:28 2026 +0100

    libssp: drop redundant function checks
    
    Don't search for C89 functions: memmove, strncat, strncpy.
    
    Note that for strncpy, we actually did use the check in stnrcpy-chk.c,
    but for strncat, we didn't bother, so I doubt even further this had any
    utility. Unconditionally search for mempcpy (non-C89).
    
    Note further that the strncpy, strncat checks were skipped for no-link
    targets, so it's even less likely again that this was serving any purpose
    these days.
    
    Followup to r17-5050-g03f6b3bd2e83db.
    
    libssp/ChangeLog:
            PR bootstrap/112422
    
            * config.h.in: Regenerate.
            * configure: Regenerate.
            * configure.ac: Don't search for memmove, strncat, strncpy.
            Unconditionally search for mempcpy.
            * strncpy-chk.c: Drop HAVE_STRNCPY guard.
            * memmove-chk.c: Drop HAVE_MEMMOVE guard.

Diff:
---
 libssp/config.h.in   |   9 ----
 libssp/configure     | 128 ++++++++++++++++++++++++---------------------------
 libssp/configure.ac  |   9 +---
 libssp/memmove-chk.c |   2 -
 libssp/strncpy-chk.c |   2 -
 5 files changed, 60 insertions(+), 90 deletions(-)

diff --git a/libssp/config.h.in b/libssp/config.h.in
index 59003eb1d4a0..25bd3e3306c2 100644
--- a/libssp/config.h.in
+++ b/libssp/config.h.in
@@ -22,9 +22,6 @@
 /* Define to 1 if you have the <malloc.h> header file. */
 #undef HAVE_MALLOC_H
 
-/* Define to 1 if you have the `memmove' function. */
-#undef HAVE_MEMMOVE
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
@@ -46,12 +43,6 @@
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Define to 1 if you have the `strncat' function. */
-#undef HAVE_STRNCAT
-
-/* Define to 1 if you have the `strncpy' function. */
-#undef HAVE_STRNCPY
-
 /* Define to 1 if you have the <syslog.h> header file. */
 #undef HAVE_SYSLOG_H
 
diff --git a/libssp/configure b/libssp/configure
index c56a2ddff318..7728401ef71f 100755
--- a/libssp/configure
+++ b/libssp/configure
@@ -1817,6 +1817,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_header_compile
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is 
declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -1886,52 +1932,6 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_func
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is 
declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -4867,27 +4867,6 @@ fi
 done
 
 
-if test x$gcc_no_link = xyes; then
-  # Presume the ISO C functions are available; add target-specific
-  # configuration here if required.
-  $as_echo "#define HAVE_STRNCPY 1" >>confdefs.h
-
-  $as_echo "#define HAVE_STRNCAT 1" >>confdefs.h
-
-else
-  for ac_func in memmove mempcpy strncpy strncat
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-fi
 ac_fn_c_check_decl "$LINENO" "gets" "ac_cv_have_decl_gets" 
"$ac_includes_default"
 if test "x$ac_cv_have_decl_gets" = xyes; then :
   ac_have_decl=1
@@ -4899,6 +4878,17 @@ cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_GETS $ac_have_decl
 _ACEOF
 
+for ac_func in mempcpy
+do :
+  ac_fn_c_check_func "$LINENO" "mempcpy" "ac_cv_func_mempcpy"
+if test "x$ac_cv_func_mempcpy" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMPCPY 1
+_ACEOF
+
+fi
+done
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether vsnprintf is usable" 
>&5
 $as_echo_n "checking whether vsnprintf is usable... " >&6; }
@@ -11553,7 +11543,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11556 "configure"
+#line 11546 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11659,7 +11649,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11662 "configure"
+#line 11652 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libssp/configure.ac b/libssp/configure.ac
index 2bf4d928575f..81f6b0d0d416 100644
--- a/libssp/configure.ac
+++ b/libssp/configure.ac
@@ -126,15 +126,8 @@ AM_CONDITIONAL(LIBSSP_USE_SYMVER_SUN, [test 
"x$ssp_use_symver" = xsun])
 
 AC_CHECK_HEADERS(alloca.h malloc.h paths.h syslog.h unistd.h fcntl.h)
 
-if test x$gcc_no_link = xyes; then
-  # Presume the ISO C functions are available; add target-specific
-  # configuration here if required.
-  AC_DEFINE(HAVE_STRNCPY)
-  AC_DEFINE(HAVE_STRNCAT)
-else
-  AC_CHECK_FUNCS(memmove mempcpy strncpy strncat)
-fi
 AC_CHECK_DECLS([gets])
+AC_CHECK_FUNCS([mempcpy])
 
 AC_MSG_CHECKING([whether vsnprintf is usable])
 AC_RUN_IFELSE([AC_LANG_PROGRAM([
diff --git a/libssp/memmove-chk.c b/libssp/memmove-chk.c
index fd069796b9d3..f5cce9a4099f 100644
--- a/libssp/memmove-chk.c
+++ b/libssp/memmove-chk.c
@@ -38,7 +38,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
 extern void __chk_fail (void) __attribute__((__noreturn__));
 
-#ifdef HAVE_MEMMOVE
 void *
 __memmove_chk (void *dest, const void *src, size_t len, size_t slen)
 {
@@ -46,4 +45,3 @@ __memmove_chk (void *dest, const void *src, size_t len, 
size_t slen)
     __chk_fail ();
   return memmove (dest, src, len);
 }
-#endif
diff --git a/libssp/strncpy-chk.c b/libssp/strncpy-chk.c
index fd56fc43551e..5c0c4bb8f13a 100644
--- a/libssp/strncpy-chk.c
+++ b/libssp/strncpy-chk.c
@@ -37,7 +37,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 
 extern void __chk_fail (void) __attribute__((__noreturn__));
 
-#ifdef HAVE_STRNCPY
 char *
 __strncpy_chk (char *__restrict__ dest, const char *__restrict__ src,
                size_t len, size_t slen)
@@ -46,4 +45,3 @@ __strncpy_chk (char *__restrict__ dest, const char 
*__restrict__ src,
     __chk_fail ();
   return strncpy (dest, src, len);
 }
-#endif

Reply via email to