[binutils-gdb] Fix binutils build on hppa64-hpux with gcc-16 (v3)
John David Anglin
danglin@sourceware.org
Sun Dec 14 21:12:15 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b691ce241e7a3dc2e158a64af1b8edd6b761be2f
commit b691ce241e7a3dc2e158a64af1b8edd6b761be2f
Author: John David Anglin <danglin@gcc.gnu.org>
Date: Sun Dec 14 16:11:19 2025 -0500
Fix binutils build on hppa64-hpux with gcc-16 (v3)
With recent gcc versions, implicit function declarations are errors.
We need to ensure that ffs() and strtoull() are declared and correctly
checked for by configure.
strtoull() is not declared on hpux but it's provided by libiberty.
An unnecessary include of strings.h in elf32-xtensa.c is removed.
Approved-By: Jan Beulich <jbeulich@suse.com>
2025-12-14 John David Anglin <danglin@gcc.gnu.org>
bfd/ChangeLog:
* configure.ac: Check for strtoull declaration.
* elf32-xtensa.c: Remove strings.h include.
* configure: Regenerate.
* config.in: Regenerate.
* sysdep.h: Include strings.h and declare strtoull()
if a declaration for it isn't found by configure.
ld/ChangeLog:
* configure.ac: Check for strtoull declaration.
* configure: Regenerate.
* config.in: Regenerate.
* sysdep.h: Declare strtoull() if a declaration for it
isn't found by configure.
Diff:
---
bfd/config.in | 4 ++++
bfd/configure | 22 +++++++++++++++++-----
bfd/configure.ac | 2 +-
bfd/elf32-xtensa.c | 1 -
bfd/sysdep.h | 8 ++++++++
ld/config.in | 4 ++++
ld/configure | 22 +++++++++++++++++-----
ld/configure.ac | 2 +-
ld/sysdep.h | 4 ++++
9 files changed, 56 insertions(+), 13 deletions(-)
diff --git a/bfd/config.in b/bfd/config.in
index 7458362922c..b3bd7cac45b 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -75,6 +75,10 @@
don't. */
#undef HAVE_DECL_STRNLEN
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOULL
+
/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VASPRINTF
diff --git a/bfd/configure b/bfd/configure
index d9d77b7004c..8b14d09e6a2 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -12063,7 +12063,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -12109,7 +12109,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -12133,7 +12133,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -12178,7 +12178,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -12202,7 +12202,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -15191,6 +15191,16 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRNLEN $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
ac_fn_c_check_decl "$LINENO" "___lc_codepage_func" "ac_cv_have_decl____lc_codepage_func" "#include <locale.h>
"
@@ -17512,6 +17522,8 @@ main ()
if (*(data + i) != *(data3 + i))
return 14;
close (fd);
+ free (data);
+ free (data3);
return 0;
}
_ACEOF
diff --git a/bfd/configure.ac b/bfd/configure.ac
index 4fb3bf41f34..c36594c5291 100644
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -222,7 +222,7 @@ AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
AC_CHECK_FUNCS(fcntl fdopen fileno fls getgid getpagesize getrlimit getuid \
sysconf)
-AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen])
+AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen, strtoull])
AC_CHECK_DECLS([___lc_codepage_func], [], [], [[#include <locale.h>]])
BFD_BINARY_FOPEN
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 403e218a3b3..da0f434c662 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -22,7 +22,6 @@
#include "bfd.h"
#include <stdarg.h>
-#include <strings.h>
#include "bfdlink.h"
#include "libbfd.h"
diff --git a/bfd/sysdep.h b/bfd/sysdep.h
index 1f54a9d897d..e6c8b8a787a 100644
--- a/bfd/sysdep.h
+++ b/bfd/sysdep.h
@@ -37,6 +37,10 @@
#include <stddef.h>
#include <string.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -112,6 +116,10 @@ extern int ffs (int);
extern char *stpcpy (char *__dest, const char *__src);
#endif
+#if !HAVE_DECL_STRTOULL
+extern unsigned long long strtoull(const char *, char **, int);
+#endif
+
#ifdef HAVE_FTELLO
#if !HAVE_DECL_FTELLO
extern off_t ftello (FILE *stream);
diff --git a/ld/config.in b/ld/config.in
index 790efd336be..81146b84bc3 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -118,6 +118,10 @@
*/
#undef HAVE_DECL_STPCPY
+/* Define to 1 if you have the declaration of `strtoull', and to 0 if you
+ don't. */
+#undef HAVE_DECL_STRTOULL
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
diff --git a/ld/configure b/ld/configure
index 95729556429..16e338adc1f 100755
--- a/ld/configure
+++ b/ld/configure
@@ -15458,7 +15458,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -15504,7 +15504,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -15528,7 +15528,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -15573,7 +15573,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -15597,7 +15597,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -18711,6 +18711,16 @@ fi
cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STPCPY $ac_have_decl
_ACEOF
+ac_fn_c_check_decl "$LINENO" "strtoull" "ac_cv_have_decl_strtoull" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strtoull" = xyes; then :
+ ac_have_decl=1
+else
+ ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRTOULL $ac_have_decl
+_ACEOF
@@ -18895,6 +18905,8 @@ main ()
if (*(data + i) != *(data3 + i))
return 14;
close (fd);
+ free (data);
+ free (data3);
return 0;
}
_ACEOF
diff --git a/ld/configure.ac b/ld/configure.ac
index 3e44e3361ef..2c4cc47de01 100644
--- a/ld/configure.ac
+++ b/ld/configure.ac
@@ -451,7 +451,7 @@ AC_CHECK_FUNCS(close getrusage glob lseek mkstemp open realpath waitpid)
BFD_BINARY_FOPEN
-AC_CHECK_DECLS([environ, stpcpy])
+AC_CHECK_DECLS([environ, stpcpy, strtoull])
GCC_AC_FUNC_MMAP
diff --git a/ld/sysdep.h b/ld/sysdep.h
index 1d5cc3ce424..70de112a513 100644
--- a/ld/sysdep.h
+++ b/ld/sysdep.h
@@ -96,6 +96,10 @@ extern char **environ;
extern char *stpcpy (char *__dest, const char *__src);
#endif
+#if !HAVE_DECL_STRTOULL
+extern unsigned long long strtoull(const char *, char **, int);
+#endif
+
#define POISON_BFD_BOOLEAN 1
#endif /* ! defined (LD_SYSDEP_H) */
More information about the Binutils-cvs
mailing list