Check for strnlen declaration to fix Solaris 10 build

Message ID ydd35sry92t.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series
  • Check for strnlen declaration to fix Solaris 10 build
Related show

Commit Message

Rainer Orth July 6, 2021, 11:29 a.m.
binutils currently fails to compile on Solaris 10:

/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function ‘bf
d_get_debug_link_info_1’:
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: i
mplicit declaration of function ‘strnlen’ [-Werror=implicit-function-declarati
on]
 1231 |	  crc_offset = strnlen (name, size) + 1;
      |		       ^~~~~~~
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1231:16: error: i
ncompatible implicit declaration of built-in function ‘strnlen’ [-Werror]
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c: In function ‘bf
d_get_alt_debug_link_info’:
/vol/src/gnu/binutils/hg/binutils-2.37-branch/git/bfd/opncls.c:1319:20: error: i
ncompatible 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.

Ok for master and the 2.37 branch?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


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.

Comments

Florian Weimer via Binutils July 6, 2021, 1:48 p.m. | #1
Hi Rainer,

> 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.

> 

> Ok for master and the 2.37 branch?


Approved for both - please apply.

Cheers
   Nick

Patch

# HG changeset patch
# Parent  f5471d6b70fd78ddb6f9d416a0d3598ff08625f8
Check for strnlen declaration to fix Solaris 10 build

diff --git a/bfd/configure.ac b/bfd/configure.ac
--- a/bfd/configure.ac
+++ b/bfd/configure.ac
@@ -260,7 +260,7 @@  AC_CHECK_HEADERS(fcntl.h sys/file.h sys/
 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
 
diff --git a/binutils/configure.ac b/binutils/configure.ac
--- a/binutils/configure.ac
+++ b/binutils/configure.ac
@@ -265,7 +265,7 @@  if test $bu_cv_header_utime_h = yes; the
   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