Bug 56311 - gcc/include-fixed/stdio.h: In function ‘_func’: gcc/include-fixed/stdio.h:135:3: error: expected declaration specifiers before ‘__extension__’
Summary: gcc/include-fixed/stdio.h: In function ‘_func’: gcc/include-fixed/stdio.h:135...
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-13 22:29 UTC by heri+gcc
Modified: 2017-07-22 19:22 UTC (History)
0 users

See Also:
Host: x86_64-linux-gnu
Target: x86_64-pc-mingw64
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
stdio.h (6.11 KB, text/x-chdr)
2013-02-13 22:29 UTC, heri+gcc
Details
cross-x86_64-pc-mingw64-gcc-stage1.log.xz (44.85 KB, application/x-xz)
2013-02-13 22:31 UTC, heri+gcc
Details
gcc-4.7.2-inclhack-hpux10_stdio_declarations.patch (267 bytes, patch)
2013-02-14 19:45 UTC, heri+gcc
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description heri+gcc 2013-02-13 22:29:41 UTC
Created attachment 29445 [details]
stdio.h

I am building a crosscompiler for x86_64-pc-mingw64 on Gentoo/Linux and get the following error during build:

In file included from /var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/gcc-4.7.2/libgcc/../gcc/tsystem.h:88:0,
                 from /var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/gcc-4.7.2/libgcc/libgcc2.c:29:
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h: In function ‘_func’:
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:135:3: error: expected declaration specifiers before ‘__extension__’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:173:15: error: storage class specified for parameter ‘__mingw_sscanf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:176:15: error: storage class specified for parameter ‘__mingw_vsscanf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:179:15: error: storage class specified for parameter ‘__mingw_scanf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:182:15: error: storage class specified for parameter ‘__mingw_vscanf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:185:15: error: storage class specified for parameter ‘__mingw_fscanf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:188:15: error: storage class specified for parameter ‘__mingw_vfscanf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:192:15: error: storage class specified for parameter ‘__mingw_vsnprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:196:15: error: storage class specified for parameter ‘__mingw_snprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:199:15: error: storage class specified for parameter ‘__mingw_printf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:202:15: error: storage class specified for parameter ‘__mingw_vprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:205:15: error: storage class specified for parameter ‘__mingw_fprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:208:15: error: storage class specified for parameter ‘__mingw_vfprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:211:15: error: storage class specified for parameter ‘__mingw_sprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:214:15: error: storage class specified for parameter ‘__mingw_vsprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:217:15: error: storage class specified for parameter ‘__mingw_asprintf’
/var/tmp/portage/cross-x86_64-pc-mingw64/gcc-4.7.2/work/build/./gcc/include-fixed/stdio.h:220:15: error: storage class specified for parameter ‘__mingw_vasprintf’


The code that seems to lead to this problem appears to be around line 96:
#ifndef _STDIO_DEFINED
#ifdef _WIN64
[...]
_func()
#else
#ifdef _MSVCRT_
[...]
#else
[...]
_func()
#endif
#endif
#endif

Apparently GCC somehow destroyed the file during its bootstrap process.
Comment 1 heri+gcc 2013-02-13 22:31:03 UTC
Created attachment 29446 [details]
cross-x86_64-pc-mingw64-gcc-stage1.log.xz
Comment 2 heri+gcc 2013-02-14 10:44:25 UTC
P.S: I am willing to debug this further on my own, but I need some help.

My first guess is that the files in include-fixed are system headers, which are somehow mangled with sed or a similar tool. Where does that happen and with what intend?
Comment 3 Andreas Schwab 2013-02-14 11:05:32 UTC
See fixincludes/inclhack.def, it looks like this is from hackname = hpux10_stdio_declarations, and select = "^#[ \t]*define _iob[ \t]*__iob" needs to be made more strict so that it doesn't match "#define _iob __iob_func()".
Comment 4 heri+gcc 2013-02-14 19:45:33 UTC
Created attachment 29454 [details]
gcc-4.7.2-inclhack-hpux10_stdio_declarations.patch

Attached patch fixes the issue for me. Someone with a HP-UX 10 system should probably test it, though!

I added an $ anchor to the end of the match, to exclude the __iob_func() line that MinGW seems to use. If there is anything (e.g. a comment) after __iob on HP-UX 10, this will obviously fail! (But then it might have created bad code before, too.)
Comment 5 Eric Gallager 2017-07-22 17:53:39 UTC
(In reply to devurandom from comment #4)
> Created attachment 29454 [details]
> gcc-4.7.2-inclhack-hpux10_stdio_declarations.patch
> 
> Attached patch fixes the issue for me. Someone with a HP-UX 10 system should
> probably test it, though!
> 
> I added an $ anchor to the end of the match, to exclude the __iob_func()
> line that MinGW seems to use. If there is anything (e.g. a comment) after
> __iob on HP-UX 10, this will obviously fail! (But then it might have created
> bad code before, too.)

Please send the patch to the gcc-patches mailing list (if it's still needed) and cc the relevant maintainers. John David Anglin is the HPUX guy.
Comment 6 heri+gcc 2017-07-22 19:22:08 UTC
I currently have no need for a Windows cross-compiler. The patch is attached here, should anyone need it -- assuming the issue still exists and the patch still works.