Bug 13558 - binutils 2.22 v. AIX 6.1 -- build fails with large-file support problems (and mkdtemp confusion)
Summary: binutils 2.22 v. AIX 6.1 -- build fails with large-file support problems (and...
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: 2012-01-04 06:30 UTC by Steven Schweda
Modified: 2012-05-16 14:28 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch against current binutils CVS source (893 bytes, patch)
2012-05-01 19:18 UTC, Daniel Richard G.
Details | Diff
Patch for other files in binutils CVS (1.53 KB, patch)
2012-05-04 20:40 UTC, Daniel Richard G.
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Schweda 2012-01-04 06:30:07 UTC
I was recently trying to build 2.22 on my AIX (6.1) system when I ran
into a problem.  Instance 1:

[...]
In file included from syslex.c:549:
/usr/include/unistd.h:171: error: conflicting types for 'lseek64'
/usr/include/unistd.h:169: error: previous declaration of 'lseek64' was here
In file included from /usr/include/unistd.h:746,
                 from syslex.c:549:
/usr/include/sys/lockf.h:64: error: conflicting types for 'lockf64'
/usr/include/sys/lockf.h:62: error: previous declaration of 'lockf64' was here
[and a host of others ...]

   The cause seems to be sub-optimal handling of the large-file support
macros, which need to be defined before the affected system header files
are processed.

   My manual fix to binutils/syslex.c was this:

blue# diff binutils/syslex.c_orig binutils/syslex.c

blue# diff binutils/syslex.c_orig binutils/syslex.c
1c1
<
---
> #include "config.h"

From the looks of it, I suspect that this thing is generated, and so the
change would need to be made elsewhere, but the essence is to get
"config.h" processed before the system header files.

   Similarly, instance 2:

[...]
gcc -DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include -DLOCALEDIR=
"\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_aix_emulation  -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT od-xcoff.o
-MD -MP -MF .deps/od-xcoff.Tpo -c -o od-xcoff.o od-xcoff.c
In file included from sysdep.h:27,
                 from od-xcoff.c:24:
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/include/stdio.h:511: error: c
onflicting types for 'fgetpos64'
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/include/stdio.h:310: error: p
revious declaration of 'fgetpos64' was here
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/include/stdio.h:514: error: c
onflicting types for 'fseeko64'
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/include/stdio.h:454: error: p
revious declaration of 'fseeko64' was here
[...]

   My fix:

blue# diff binutils/od-xcoff.c_orig binutils/od-xcoff.c
21a22,23
> #include "config.h"
>



   Also, the "configure" test for 'mkdtemp' gets a result which might
best be described as unfortunate:

[...]
gcc -DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include -DLOCALEDIR=
"\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_aix_emulation  -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT bucomm.o -M
D -MP -MF .deps/bucomm.Tpo -c -o bucomm.o bucomm.c
cc1: warnings being treated as errors
bucomm.c: In function 'make_tempdir':
bucomm.c:531: warning: implicit declaration of function 'mkdtemp'
bucomm.c:531: warning: return makes pointer from integer without a cast
gmake[4]: *** [bucomm.o] Error 1
[...]

   My manual fix:

blue# diff binutils/config.h_orig binutils/config.h
93c93
< #define HAVE_MKDTEMP 1
---
> /* #define HAVE_MKDTEMP 1 */

   I didn't look at the details, but I'm guessing that "configure" did
some less-than-thorough test for "mkdtemp".  Perhaps "mkdtemp" is in
some run-time library, so a link-only test might work, but it appears
not to be in any of the system header files, so an actual compilation
(with "warnings being treated as errors") will fail this way.  For my
purposes, the (sleazy) manual edit of "binutils/config.h" was good
enough, but a more realistic test in "configure" would be more
satisfying.

   Around here:

blue# uname -a
AIX blue 1 6 000F1F6E4C00

blue# gcc --version
gcc (GCC) 4.2.0
[...]
Comment 1 Michael Haubenwallner 2012-03-14 08:29:24 UTC
Quite similar troubles here on AIX 7.1:

(In reply to comment #0)
> In file included from syslex.c:549:
> /usr/include/unistd.h:171: error: conflicting types for 'lseek64'
> /usr/include/unistd.h:169: error: previous declaration of 'lseek64' was here
> In file included from /usr/include/unistd.h:746,
>                  from syslex.c:549:

> blue# diff binutils/syslex.c_orig binutils/syslex.c
> 1c1
> <
> ---
> > #include "config.h"
> 
> From the looks of it, I suspect that this thing is generated, and so the
> change would need to be made elsewhere, but the essence is to get
> "config.h" processed before the system header files.

Particular reason here is the _LARGE_FILES macro, defined by config.h, which has to be defined before any system header.

> blue# diff binutils/od-xcoff.c_orig binutils/od-xcoff.c
> 21a22,23
> > #include "config.h"

Same here.

>    Also, the "configure" test for 'mkdtemp' gets a result which might
> best be described as unfortunate:

> bucomm.c:531: warning: implicit declaration of function 'mkdtemp'

>    I didn't look at the details, but I'm guessing that "configure" did
> some less-than-thorough test for "mkdtemp".  Perhaps "mkdtemp" is in
> some run-time library, so a link-only test might work, but it appears
> not to be in any of the system header files, so an actual compilation
> (with "warnings being treated as errors") will fail this way.

Exactly: Since AIX 6.1, mkdtemp() is declared upon _XOPEN_SOURCE >= 700, and thus the symbol is available in libc.

The difference is: Upon _ALL_SOURCE (defined in config.h),
AIX 6.1 defines (overrides!) _XOPEN_SOURCE=600, while
AIX 7.1 defines (overrides!) _XOPEN_SOURCE=700, 

This particularly isn't a problem on AIX 7.1, but still the check for mkdtemp() should be extended to if the declaration is available too.
Comment 2 Daniel Richard G. 2012-05-01 19:18:49 UTC
Created attachment 6383 [details]
Patch against current binutils CVS source

syslex.c is a Lex-generated source file. Although the Lex source (syslex.l) #includes "config.h" right at the beginning, the generated source adds a few hundred lines of boilerplate before that, which unfortunately contains numerous system header #includes.

Tweaking the rule that invokes Lex did not appear feasible, so instead I modified the build definitions to compile a small wrapper source file that #includes config.h and then syslex.c, while removing the former #include from syslex.l.

(I did not encounter any issue with mkdtemp() on AIX 4.3.)
Comment 3 Daniel Richard G. 2012-05-04 20:38:59 UTC
The binutils CVS source is rife with this problem as well. Aside from syslex.c, the following files do not handle config.h and/or sysdep.h correctly, and fail to build on AIX with the same class of errors as in the original report:

    bfd/aout-cris.c
    bfd/aout-ns32k.c
    bfd/aout-sparcle.c
    bfd/aout0.c
    bfd/coff-stgo32.c
    bfd/cpu-lm32.c
    bfd/cpu-microblaze.c
    bfd/cpu-score.c
    bfd/cpu-tilegx.c
    bfd/cpu-tilepro.c
    bfd/elf32-lm32.c
    bfd/elf32-microblaze.c
    bfd/elf32-score7.c
    bfd/elf32-tilepro.c
    bfd/elfxx-tilegx.c
    bfd/nlm32-ppc.c
    bfd/ns32knetbsd.c
    bfd/sunos.c
Comment 4 Daniel Richard G. 2012-05-04 20:40:43 UTC
Created attachment 6393 [details]
Patch for other files in binutils CVS

This patch fixes the issue in the aforementioned files.
Comment 5 Daniel Richard G. 2012-05-07 17:12:22 UTC
I've filed bug 14072 as a generalization of this bug.

The AIX-specific failure mode reported here may not be easy to re-create in development, but there may be a way to get the same effect artificially, thereby preventing bugs like this from arising in the future.
Comment 6 cvs-commit@gcc.gnu.org 2012-05-16 14:26:50 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	nickc@sourceware.org	2012-05-16 14:26:46

Modified files:
	binutils       : ChangeLog Makefile.am Makefile.in syslex.l 
	binutils/doc   : Makefile.in 
	bfd            : ChangeLog aout-cris.c aout-ns32k.c 
	                 aout-sparcle.c aout0.c bfd-in2.h coff-stgo32.c 
	                 cpu-lm32.c cpu-microblaze.c cpu-score.c 
	                 cpu-tilegx.c cpu-tilepro.c elf32-lm32.c 
	                 elf32-microblaze.c elf32-score7.c 
	                 elf32-tilepro.c elfxx-tilegx.c mach-o.h 
	                 nlm32-ppc.c ns32knetbsd.c pef.h plugin.c 
	                 stab-syms.c sunos.c syms.c xsym.h 
Added files:
	binutils       : syslex_wrap.c 

Log message:
	PR binutils/13558
	* bfd/aout-cris.c: Include sysdep.h before bfd.h.
	* bfd/aout-ns32k.c: Likewise.
	* bfd/aout-sparcle.c: Likewise.
	* bfd/aout0.c: Likewise.
	* bfd/bfd-in2.h: Likewise.
	* bfd/coff-stgo32.c: Likewise.
	* bfd/cpu-lm32.c: Likewise.
	* bfd/cpu-microblaze.c: Likewise.
	* bfd/cpu-score.c: Likewise.
	* bfd/cpu-tilegx.c: Likewise.
	* bfd/cpu-tilepro.c: Likewise.
	* bfd/elf32-lm32.c: Likewise.
	* bfd/elf32-microblaze.c: Likewise.
	* bfd/elf32-score7.c: Likewise.
	* bfd/elf32-tilepro.c: Likewise.
	* bfd/elfxx-tilegx.c: Likewise.
	* bfd/mach-o.h: Likewise.
	* bfd/nlm32-ppc.c: Likewise.
	* bfd/ns32knetbsd.c: Likewise.
	* bfd/pef.h: Likewise.
	* bfd/plugin.c: Likewise.
	* bfd/stab-syms.c: Likewise.
	* bfd/sunos.c: Likewise.
	* bfd/syms.c: Likewise.
	* bfd/xsym.h: Likewise.
	
	* Makefile.am (CFILES): Add syslex_wrap.c.
	(sysinfo): Depend upon syslex_wrap.o.
	(syslex_wrap.o): New rule.
	(syslex.o): Delete rule.
	* syslex_wrap.c: New file.
	* Makefile.in: Regenerate.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/syslex_wrap.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/ChangeLog.diff?cvsroot=src&r1=1.1907&r2=1.1908
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/Makefile.am.diff?cvsroot=src&r1=1.134&r2=1.135
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/Makefile.in.diff?cvsroot=src&r1=1.158&r2=1.159
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/syslex.l.diff?cvsroot=src&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/src/binutils/doc/Makefile.in.diff?cvsroot=src&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5686&r2=1.5687
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/aout-cris.c.diff?cvsroot=src&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/aout-ns32k.c.diff?cvsroot=src&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/aout-sparcle.c.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/aout0.c.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in2.h.diff?cvsroot=src&r1=1.571&r2=1.572
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/coff-stgo32.c.diff?cvsroot=src&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-lm32.c.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-microblaze.c.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-score.c.diff?cvsroot=src&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tilegx.c.diff?cvsroot=src&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/cpu-tilepro.c.diff?cvsroot=src&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-lm32.c.diff?cvsroot=src&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-microblaze.c.diff?cvsroot=src&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-score7.c.diff?cvsroot=src&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-tilepro.c.diff?cvsroot=src&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elfxx-tilegx.c.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/mach-o.h.diff?cvsroot=src&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/nlm32-ppc.c.diff?cvsroot=src&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ns32knetbsd.c.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/pef.h.diff?cvsroot=src&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/plugin.c.diff?cvsroot=src&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/stab-syms.c.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/sunos.c.diff?cvsroot=src&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/syms.c.diff?cvsroot=src&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/xsym.h.diff?cvsroot=src&r1=1.12&r2=1.13
Comment 7 Nick Clifton 2012-05-16 14:28:02 UTC
I have checked in Daniel's patches.  Bug 14072 remains open however, so there may be more patches to come.

Cheers
  Nick