Fix binutils build on hppa64-hpux with gcc-16 (v2)

Message ID aTCX2SkKP7j_UbRj@mx3210.local
State New
Headers
Series Fix binutils build on hppa64-hpux with gcc-16 (v2) |

Commit Message

John David Anglin Dec. 3, 2025, 8:04 p.m. UTC
  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

Jan Beulich Dec. 4, 2025, 10:15 a.m. UTC | #1
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
  
John David Anglin Dec. 5, 2025, 12:43 a.m. UTC | #2
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
  
Jan Beulich Dec. 5, 2025, 7:11 a.m. UTC | #3
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
  

Patch

diff --git a/bfd/configure.ac b/bfd/configure.ac
index 4fb3bf41f34..af4728eac20 100644
--- 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)
 
 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 20b6292c14e..168e7491c20 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/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) */