Bug 13121 - bfd HEAD 2011-08-23 does not build on AIX 5.3 without --enable-werror=no
Summary: bfd HEAD 2011-08-23 does not build on AIX 5.3 without --enable-werror=no
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-23 09:50 UTC by Christopher January
Modified: 2012-05-01 16:09 UTC (History)
5 users (show)

See Also:
Host: powerpc-ibm-aix5.3.0.0
Target: powerpc-ibm-aix5.3.0.0
Build: powerpc-ibm-aix5.3.0.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christopher January 2011-08-23 09:50:55 UTC
Without passing --enable-werror=no to configure the build fails here:

make[4]: Entering directory `/home/cjanuary/code/patches/tarball/build-gdb-cvs-aix-53-ppc64/bfd'
/bin/sh ./libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../src/bfd -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE -DAIX_CORE  -DAIX_WEAK_SUPPORT -I. -I../../src/bfd -I../../src/bfd/../include  -DHAVE_rs6000coff_vec -DHAVE_aix5coff64_vec -I./../intl -DBINDIR='"/usr/local/bin"'  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT reloc.lo -MD -MP -MF .deps/reloc.Tpo -c -o reloc.lo ../../src/bfd/reloc.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../src/bfd -DAIX_5_CORE -DAIX_CORE_DUMPX_CORE -DAIX_CORE -DAIX_WEAK_SUPPORT -I. -I../../src/bfd -I../../src/bfd/../include -DHAVE_rs6000coff_vec -DHAVE_aix5coff64_vec -I./../intl -DBINDIR=\"/usr/local/bin\" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT reloc.lo -MD -MP -MF .deps/reloc.Tpo -c ../../src/bfd/reloc.c -o reloc.o
cc1: warnings being treated as errors
../../src/bfd/reloc.c: In function 'bfd_generic_lookup_section_flags':
../../src/bfd/reloc.c:6127: warning: declaration of 'finfo' shadows a global declaration
/usr/include/unistd.h:937: warning: shadowed declaration is here
make[4]: *** [reloc.lo] Error 1

The line in unistd.h:

        extern int      ffinfo(int, int, void *, int32long64_t);

and the line in reloc.c:

void
bfd_generic_lookup_section_flags (struct bfd_link_info *info ATTRIBUTE_UNUSED,
                                  struct flag_info *finfo)

Obviously this warning can be ignored. Either configure needs to suppress the warning or not enable -Werror on AIX.
Comment 1 Pedro Alves 2011-08-23 12:42:36 UTC
bfd is owned by binutils.  Changing product.
Comment 2 Alan Modra 2011-08-24 13:40:49 UTC
I think we should just remove -Wshadow from WARN_CFLAGS, and fix gcc to stop warning about this sort of shadowing.
Comment 3 Steven Schweda 2012-01-04 06:01:09 UTC
   I was recently trying to build 2.22 on my AIX (6.1) system when I ran
into this problem.  My solution was simple: Change the variable name
"finfo" to something less collision-prone ("flaginfo"):

blue# diff -u bfd/reloc.c_orig bfd/reloc.c
--- bfd/reloc.c_orig    2011-07-24 09:20:06.000000000 -0500
+++ bfd/reloc.c 2011-12-31 00:32:36.000000000 -0600
@@ -6124,9 +6124,9 @@

  void
  bfd_generic_lookup_section_flags (struct bfd_link_info *info ATTRIBUTE_UNUSED,
-                                 struct flag_info *finfo)
+                                 struct flag_info *flaginfo)
  {
-   if (finfo != NULL)
+   if (flaginfo != NULL)
      {
        (*_bfd_error_handler) (_("INPUT_SECTION_FLAGS are not supported.\n"));
        return;


   To me, that seemed effective and harmless.  Around here:

blue# uname -a
AIX blue 1 6 000F1F6E4C00

blue# gcc --version
gcc (GCC) 4.2.0
[...]
Comment 4 Nick Clifton 2012-01-06 10:42:34 UTC
Hi Steven,

  There are lots of instances of the use of "finfo" as a variable name in the binutils sources.  Are you sure that just changing the one use in bfd/reloc.c is sufficient in order to allow the binutils to compile under AIX ?

Cheers
  Nick
Comment 5 Steven Schweda 2012-01-06 13:42:11 UTC
> Are you sure [...]

Pretty sure, plus the other stuff described elsewhere:

      http://sourceware.org/bugzilla/show_bug.cgi?id=13558

If I ran the world (and cared about AIX), then I'd probably change them
all, but that was the only instance which stopped the build here.  The
conflict was with <unistd.h>.  Perhaps the other instances of "finfo"
deftly avoid <unistd.h>?
Comment 6 Sourceware Commits 2012-01-06 15:44:44 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2012-01-06 15:44:34

Modified files:
	bfd            : ChangeLog reloc.c 

Log message:
	PR binutils/13121
	* reloc.c (bfd_generic_lookup_section_flags): Rename 'finfo' to
	'flaginfo' to avoid conflicts with AIX system headers.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5576&r2=1.5577
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/reloc.c.diff?cvsroot=src&r1=1.219&r2=1.220
Comment 7 Nick Clifton 2012-01-06 16:01:57 UTC
Hi Steven,

  In which case I am happy to make a small change to the sources in order to continue to allow them to be compiled with -Werror.

Cheers
  Nick
Comment 8 Daniel Richard G. 2012-04-27 19:56:15 UTC
I encountered this same issue building binutils 2.22 on AIX 4.3. If you build with --enable-targets=all, however, then reloc.c isn't the only file that needs patching.

As of current git master, the following files similarly make use of variables/parameters named "finfo" and thus need the same treatment:

	bfd/aoutx.h
	bfd/coff-ppc.c
	bfd/cofflink.c
	bfd/elf32-arm.c
	bfd/elf64-sparc.c
	bfd/elflink.c
	bfd/pdp11.c
	binutils/rescoff.c
Comment 10 Nick Clifton 2012-05-01 16:09:14 UTC
Sources updated - all variables called 'finfo' should be renamed now.