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.
Created attachment 29446 [details] cross-x86_64-pc-mingw64-gcc-stage1.log.xz
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?
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()".
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.)
(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.
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.