https://gcc.gnu.org/g:32a70f05754e7c3cbc17e8cd43ee97dd01ca069e

commit r17-5292-g32a70f05754e7c3cbc17e8cd43ee97dd01ca069e
Author: Sam James <[email protected]>
Date:   Wed Oct 14 02:24:37 2026 +0100

    gcc: drop obsolete decl checks
    
    Don't search for various facilities guaranteed by C89: abort, atof, atol,
    calloc, clock, errno, free, getenv, malloc, realloc, strtol, strtoul, or
    strstr.
    
    Don't search for clock_t either which C89 guarantees is available in time.h.
    
    The results for clock, strtol, and strtoul weren't even used anyway. Nor
    clock_t!
    
    gcc/ChangeLog:
            PR bootstrap/112422
    
            * config.in: Regenerate.
            * configure: Regenerate.
            * configure.ac: Don't search for abort, atof, atol, calloc, clock,
            errno, free, getenv, malloc, realloc, strotol, strtoul, or strstr.
            Don't check whether clock_t is defined in time.h.
            * system.h: Drop obsolete fallbacks.

Diff:
---
 gcc/config.in    | 100 -------------------------------------------------------
 gcc/configure    |  67 ++++---------------------------------
 gcc/configure.ac |  26 +++------------
 gcc/system.h     |  40 ----------------------
 4 files changed, 12 insertions(+), 221 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index d84f59931da4..54b5847e0669 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -862,24 +862,12 @@
 #endif
 
 
-/* Define to 1 if you have the `clock' function. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_CLOCK
-#endif
-
-
 /* Define to 1 if you have the `clock_gettime' function. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_CLOCK_GETTIME
 #endif
 
 
-/* Define if <time.h> defines clock_t. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_CLOCK_T
-#endif
-
-
 /* Define 0/1 if your assembler and linker support COMDAT groups. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_COMDAT_GROUP
@@ -893,13 +881,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'abort', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_ABORT
-#endif
-
-
 /* Define to 1 if we found a declaration for 'asprintf', otherwise define to
    0. */
 #ifndef USED_FOR_TARGET
@@ -907,18 +888,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'atof', otherwise define to 0. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_ATOF
-#endif
-
-
-/* Define to 1 if we found a declaration for 'atol', otherwise define to 0. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_ATOL
-#endif
-
-
 /* Define to 1 if we found a declaration for 'atoll', otherwise define to 0.
    */
 #ifndef USED_FOR_TARGET
@@ -933,13 +902,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'calloc', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_CALLOC
-#endif
-
-
 /* Define to 1 if we found a declaration for 'clearerr_unlocked', otherwise
    define to 0. */
 #ifndef USED_FOR_TARGET
@@ -947,20 +909,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'clock', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_CLOCK
-#endif
-
-
-/* Define to 1 if we found a declaration for 'errno', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_ERRNO
-#endif
-
-
 /* Define to 1 if we found a declaration for 'feof_unlocked', otherwise define
    to 0. */
 #ifndef USED_FOR_TARGET
@@ -1044,12 +992,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'free', otherwise define to 0. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_FREE
-#endif
-
-
 /* Define to 1 if we found a declaration for 'fwrite_unlocked', otherwise
    define to 0. */
 #ifndef USED_FOR_TARGET
@@ -1078,13 +1020,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'getenv', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_GETENV
-#endif
-
-
 /* Define to 1 if we found a declaration for 'getopt', otherwise define to 0.
    */
 #ifndef USED_FOR_TARGET
@@ -1148,13 +1083,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'malloc', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_MALLOC
-#endif
-
-
 /* Define to 1 if we found a declaration for 'mkstemps', otherwise define to
    0. */
 #ifndef USED_FOR_TARGET
@@ -1176,13 +1104,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'realloc', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_REALLOC
-#endif
-
-
 /* Define to 1 if we found a declaration for 'sbrk', otherwise define to 0. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_DECL_SBRK
@@ -1238,20 +1159,6 @@
 #endif
 
 
-/* Define to 1 if you have the declaration of `strstr(const char*,const
-   char*)', and to 0 if you don't. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_STRSTR
-#endif
-
-
-/* Define to 1 if we found a declaration for 'strtol', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_STRTOL
-#endif
-
-
 /* Define to 1 if we found a declaration for 'strtoll', otherwise define to 0.
    */
 #ifndef USED_FOR_TARGET
@@ -1259,13 +1166,6 @@
 #endif
 
 
-/* Define to 1 if we found a declaration for 'strtoul', otherwise define to 0.
-   */
-#ifndef USED_FOR_TARGET
-#undef HAVE_DECL_STRTOUL
-#endif
-
-
 /* Define to 1 if we found a declaration for 'strtoull', otherwise define to
    0. */
 #ifndef USED_FOR_TARGET
diff --git a/gcc/configure b/gcc/configure
index c68d0865fb65..b891251481ee 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -10512,7 +10512,7 @@ fi
 
 
 
-for ac_func in times clock kill getrlimit setrlimit atoq \
+for ac_func in times kill getrlimit setrlimit atoq \
        popen sysconf strsignal getrusage nl_langinfo \
        gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
        clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked 
fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked fputc_unlocked 
fputs_unlocked   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked  
 putchar_unlocked putc_unlocked madvise mallinfo mallinfo2 fstatat getauxval \
@@ -12020,27 +12020,11 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-as_ac_Symbol=`$as_echo "ac_cv_have_decl_strstr(const char*,const char*)" | 
$as_tr_sh`
-ac_fn_cxx_check_decl "$LINENO" "strstr(const char*,const char*)" 
"$as_ac_Symbol" "
-#include \"ansidecl.h\"
-#include \"system.h\"
-"
-if eval test \"x\$"$as_ac_Symbol"\" = x"yes"; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_STRSTR $ac_have_decl
-_ACEOF
-
-
-for ac_func in getenv atol atoll asprintf sbrk abort atof getcwd getwd \
+for ac_func in atoll asprintf sbrk getcwd getwd \
        madvise mkstemps stpcpy strnlen strsignal strverscmp \
-       strtol strtoul strtoll strtoull setenv unsetenv \
-       errno snprintf vsnprintf vasprintf malloc realloc calloc \
-       free getopt clock getpagesize ffs fmemopen clearerr_unlocked 
feof_unlocked   ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked   
fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked   fread_unlocked 
fwrite_unlocked getchar_unlocked getc_unlocked   putchar_unlocked putc_unlocked
+       strtoll strtoull setenv unsetenv \
+       snprintf vsnprintf vasprintf \
+       getopt getpagesize ffs fmemopen clearerr_unlocked feof_unlocked   
ferror_unlocked fflush_unlocked fgetc_unlocked fgets_unlocked   fileno_unlocked 
fprintf_unlocked fputc_unlocked fputs_unlocked   fread_unlocked fwrite_unlocked 
getchar_unlocked getc_unlocked   putchar_unlocked putc_unlocked
 do
   ac_tr_decl=`$as_echo "HAVE_DECL_$ac_func" | $as_tr_cpp`
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $ac_func is 
declared" >&5
@@ -12435,43 +12419,6 @@ $as_echo "#define HAVE_STRUCT_TMS 1" >>confdefs.h
 
 fi
 
-# use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
-# revisit after autoconf 2.50.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_t" >&5
-$as_echo_n "checking for clock_t... " >&6; }
-if ${gcc_cv_type_clock_t+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-#include "ansidecl.h"
-#include "system.h"
-
-int
-main ()
-{
-clock_t x;
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  gcc_cv_type_clock_t=yes
-else
-  gcc_cv_type_clock_t=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_type_clock_t" >&5
-$as_echo "$gcc_cv_type_clock_t" >&6; }
-if test $gcc_cv_type_clock_t = yes; then
-
-$as_echo "#define HAVE_CLOCK_T 1" >>confdefs.h
-
-fi
-
 # Check if F_SETLKW is supported by fcntl.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for F_SETLKW" >&5
 $as_echo_n "checking for F_SETLKW... " >&6; }
@@ -21830,7 +21777,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21833 "configure"
+#line 21780 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21936,7 +21883,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21939 "configure"
+#line 21886 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 37f04e1a5076..48dd860ccaea 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1577,7 +1577,7 @@ define(gcc_UNLOCKED_FUNCS, clearerr_unlocked 
feof_unlocked dnl
   fileno_unlocked fprintf_unlocked fputc_unlocked fputs_unlocked dnl
   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
   putchar_unlocked putc_unlocked)
-AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoq \
+AC_CHECK_FUNCS(times kill getrlimit setrlimit atoq \
        popen sysconf strsignal getrusage nl_langinfo \
        gettimeofday mbstowcs wcswidth mmap posix_fallocate setlocale \
        gcc_UNLOCKED_FUNCS madvise mallinfo mallinfo2 fstatat getauxval \
@@ -1662,15 +1662,11 @@ AC_CHECK_DECLS([basename(char*)], , ,[
 #include "ansidecl.h"
 #include "system.h"])
 
-AC_CHECK_DECLS([strstr(const char*,const char*)], , ,[
-#include "ansidecl.h"
-#include "system.h"])
-
-gcc_AC_CHECK_DECLS(getenv atol atoll asprintf sbrk abort atof getcwd getwd \
+gcc_AC_CHECK_DECLS(atoll asprintf sbrk getcwd getwd \
        madvise mkstemps stpcpy strnlen strsignal strverscmp \
-       strtol strtoul strtoll strtoull setenv unsetenv \
-       errno snprintf vsnprintf vasprintf malloc realloc calloc \
-       free getopt clock getpagesize ffs fmemopen gcc_UNLOCKED_FUNCS, , ,[
+       strtoll strtoull setenv unsetenv \
+       snprintf vsnprintf vasprintf \
+       getopt getpagesize ffs fmemopen gcc_UNLOCKED_FUNCS, , ,[
 #include "ansidecl.h"
 #include "system.h"])
 
@@ -1741,18 +1737,6 @@ if test $ac_cv_struct_tms = yes; then
   [Define if <sys/times.h> defines struct tms.])
 fi
 
-# use gcc_cv_* here because this doesn't match the behavior of AC_CHECK_TYPE.
-# revisit after autoconf 2.50.
-AC_CACHE_CHECK(for clock_t, gcc_cv_type_clock_t, [
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include "ansidecl.h"
-#include "system.h"
-]], [[clock_t x;]])],[gcc_cv_type_clock_t=yes],[gcc_cv_type_clock_t=no])])
-if test $gcc_cv_type_clock_t = yes; then
-  AC_DEFINE(HAVE_CLOCK_T, 1,
-  [Define if <time.h> defines clock_t.])
-fi
-
 # Check if F_SETLKW is supported by fcntl.
 AC_CACHE_CHECK(for F_SETLKW, ac_cv_f_setlkw, [
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
diff --git a/gcc/system.h b/gcc/system.h
index 8a2cac29d5b4..53d419dcbddc 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -256,10 +256,6 @@ extern int fprintf_unlocked (FILE *, const char *, ...);
 
 #include <errno.h>
 
-#if !defined (errno) && defined (HAVE_DECL_ERRNO) && !HAVE_DECL_ERRNO
-extern int errno;
-#endif
-
 /* Some of glibc's string inlines cause warnings.  Plus we'd rather
    rely on (and therefore test) GCC's string builtins.  */
 #define __NO_STRING_INLINES
@@ -475,26 +471,10 @@ extern int errno;
 extern "C" {
 #endif
 
-#if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF
-extern double atof (const char *);
-#endif
-
-#if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL
-extern long atol (const char *);
-#endif
-
-#if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE
-extern void free (void *);
-#endif
-
 #if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD
 extern char *getcwd (char *, size_t);
 #endif
 
-#if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV
-extern char *getenv (const char *);
-#endif
-
 #if defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT
 extern int getopt (int, char * const *, const char *);
 #endif
@@ -515,10 +495,6 @@ extern void *sbrk (int);
 int setenv(const char *, const char *, int);
 #endif
 
-#if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR
-extern char *strstr (const char *, const char *);
-#endif
-
 #if defined (HAVE_DECL_STPCPY) && !HAVE_DECL_STPCPY
 extern char *stpcpy (char *, const char *);
 #endif
@@ -527,18 +503,6 @@ extern char *stpcpy (char *, const char *);
 int unsetenv(const char *);
 #endif
 
-#if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC
-extern void *malloc (size_t);
-#endif
-
-#if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC
-extern void *calloc (size_t, size_t);
-#endif
-
-#if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC
-extern void *realloc (void *, size_t);
-#endif
-
 #ifdef __cplusplus
 }
 #endif
@@ -586,10 +550,6 @@ extern int setrlimit (int, const struct rlimit *);
 # endif
 #endif
 
-#if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT
-extern void abort (void);
-#endif
-
 #if defined (HAVE_DECL_SNPRINTF) && !HAVE_DECL_SNPRINTF
 extern int snprintf (char *, size_t, const char *, ...);
 #endif

Reply via email to