]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Check for strnlen declaration to fix Solaris 10 build
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 7 Jul 2021 11:55:14 +0000 (13:55 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 7 Jul 2021 11:55:14 +0000 (13:55 +0200)
binutils currently fails to compile on Solaris 10:

/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function 'bfd_get_debug_link_info_1':
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: implicit declaration of function 'strnlen' [-Werror=implicit-function-declaration]
 1231 |   crc_offset = strnlen (name, size) + 1;
      |        ^~~~~~~
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: incompatible implicit declaration of built-in function 'strnlen' [-Werror]
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function 'bfd_get_alt_debug_link_info':
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1319:20: error: incompatible implicit declaration of built-in function 'strnlen' [-Werror]
 1319 |   buildid_offset = strnlen (name, size) + 1;
      |    ^~~~~~~

and in a couple of other places.  The platform lacks strnlen, and while
libiberty.h can provide a fallback declaration, the necessary configure
test isn't run.

Fixed with the following patch.  Tested on i386-pc-solaris2.10.

2021-07-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

bfd:
* configure.ac: Check for strnlen declaration.
* configure, config.in: Regenerate.

binutils:
* configure.ac: Check for strnlen declaration.
* configure, config.in: Regenerate.

bfd/ChangeLog
bfd/config.in
bfd/configure
bfd/configure.ac
binutils/ChangeLog
binutils/config.in
binutils/configure
binutils/configure.ac

index 78f84b149e03dce09e7a8411012f730c2c164dc5..f2af3b01ef07435cca001da90de4295c168d6654 100644 (file)
@@ -1,3 +1,8 @@
+2021-07-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * configure.ac: Check for strnlen declaration.
+       * configure, config.in: Regenerate.
+
 2021-07-05  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/28040
index 6d46ea72a6c3a44a83cd386dc97db4522639466d..f54a3cacbea7eeba286d363ee9dfcb1a55efccd1 100644 (file)
    */
 #undef HAVE_DECL_STPCPY
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
 /* Define to 1 if you have the declaration of `vasprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_VASPRINTF
index c46e85eb73de2ae3c127e0e3d07d3eff8bb57f7f..6faff42ca81ccaa9ae62838ef6f13af7d88017c7 100755 (executable)
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_VASPRINTF $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
 
 
 
index 07a75ed162639427d8a9243dd6ce509bdfbec90c..fec067b21356799ecdb945f4ce172150624d3ec7 100644 (file)
@@ -260,7 +260,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])
+AC_CHECK_DECLS([basename, ffs, stpcpy, asprintf, vasprintf, strnlen])
 
 BFD_BINARY_FOPEN
 
index e0cb4c97f1fc03c2ee31b6b7c0d1b5680b6021fb..1db8ef60e1e39efeebd348e7e7d2e3a528140216 100644 (file)
@@ -1,3 +1,8 @@
+2021-07-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * configure.ac: Check for strnlen declaration.
+       * configure, config.in: Regenerate.
+
 2021-07-05  Nick Clifton  <nickc@redhat.com>
 
        * po/uk.po: Updated Ukranian translation.
index e79967c5c14c8311dfc2d9a74c7a70c063173c52..e6fa66fc41b61d9fd9b656e5c979f5955534802a 100644 (file)
    */
 #undef HAVE_DECL_STPCPY
 
+/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
+   don't. */
+#undef HAVE_DECL_STRNLEN
+
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
index 2698196671b9ba6e64048d51add935c307caff1d..eeb8c2d38190f749aa14557b01dc0b4d67c3db78 100755 (executable)
 cat >>confdefs.h <<_ACEOF
 #define HAVE_DECL_STPCPY $ac_have_decl
 _ACEOF
+ac_fn_c_check_decl "$LINENO" "strnlen" "ac_cv_have_decl_strnlen" "$ac_includes_default"
+if test "x$ac_cv_have_decl_strnlen" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_STRNLEN $ac_have_decl
+_ACEOF
 
 
 # Link in zlib if we can.  This allows us to read compressed debug
index b8ab642e06880031f7db1f7afde5ba434d5dc0b9..b2d0be00b60b073ea5b98af7290db2bde3106c6e 100644 (file)
@@ -265,7 +265,7 @@ if test $bu_cv_header_utime_h = yes; then
   AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
 fi
 
-AC_CHECK_DECLS([asprintf, environ, getc_unlocked, sbrk, stpcpy])
+AC_CHECK_DECLS([asprintf, environ, getc_unlocked, sbrk, stpcpy, strnlen])
 
 # Link in zlib if we can.  This allows us to read compressed debug
 # sections.  This is used only by readelf.c (objdump uses bfd for