Fix binutils build on hppa64-hpux with gcc-16 (v2)
Commit Message
This version implements some suggestions from Jan Beulich. We only
include strings.h when it's available. It's a POSIX header and not
defined in C99. A declaration for strtoull() is added to the sysdep.h
headers to avoid having to check for the long long type. I fixed some
typos in the changelog.
Okay?
Dave
---
Fix binutils build on hppa64-hpux with gcc-16 (v2)
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.
On hpux11, ffs() is declared in strings.h. So, we need to ensure
strings.h is included when it's available. strtoull() is not defined
but it's provided by libiberty.
An unnecessary include of strings.h in elf32-xtensa.c is removed.
2025-12-03 John David Anglin <danglin@gcc.gnu.org>
bfd/ChangeLog:
* configure.ac: Check for strings.h header. 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.
Comments
On 03.12.2025 21:04, John David Anglin wrote:
> --- a/bfd/configure.ac
> +++ b/bfd/configure.ac
> @@ -217,12 +217,12 @@ fi
> BFD_CC_FOR_BUILD
>
> AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
> - unistd.h)
> + strings.h unistd.h)
Do we need this part of the change? In a recent build I already see
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
in bfd/config.h.
Jan
On 2025-12-04 5:15 a.m., Jan Beulich wrote:
> On 03.12.2025 21:04, John David Anglin wrote:
>> --- a/bfd/configure.ac
>> +++ b/bfd/configure.ac
>> @@ -217,12 +217,12 @@ fi
>> BFD_CC_FOR_BUILD
>>
>> AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
>> - unistd.h)
>> + strings.h unistd.h)
>
> Do we need this part of the change? In a recent build I already see
>
> /* Define to 1 if you have the <strings.h> header file. */
> #define HAVE_STRINGS_H 1
>
> in bfd/config.h.
You are correct, that part of the change can be removed.
Dave
On 05.12.2025 01:43, John David Anglin wrote:
> On 2025-12-04 5:15 a.m., Jan Beulich wrote:
>> On 03.12.2025 21:04, John David Anglin wrote:
>>> --- a/bfd/configure.ac
>>> +++ b/bfd/configure.ac
>>> @@ -217,12 +217,12 @@ fi
>>> BFD_CC_FOR_BUILD
>>>
>>> AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
>>> - unistd.h)
>>> + strings.h unistd.h)
>>
>> Do we need this part of the change? In a recent build I already see
>>
>> /* Define to 1 if you have the <strings.h> header file. */
>> #define HAVE_STRINGS_H 1
>>
>> in bfd/config.h.
>
> You are correct, that part of the change can be removed.
With it dropped: Okay.
Jan
@@ -217,12 +217,12 @@ fi
BFD_CC_FOR_BUILD
AC_CHECK_HEADERS(fcntl.h sys/file.h sys/resource.h sys/stat.h sys/types.h \
- unistd.h)
+ strings.h unistd.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
@@ -22,7 +22,6 @@
#include "bfd.h"
#include <stdarg.h>
-#include <strings.h>
#include "bfdlink.h"
#include "libbfd.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);
@@ -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
@@ -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) */