New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/cgo: cannot use stdout anymore with GCC4.8 #5118
Labels
Milestone
Comments
GCC 4.8 is released and will be adopted by Linux distributions: Archlinux already ships it. The GCC bug started with the following commit (SVN revision 186977): http://gcc.gnu.org/viewcvs/gcc?view=revision&revision=186977 Author: dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon Apr 30 11:43:43 2012 +0000 Switch -ftrack-macro-expansion=2 on by default. This switches the compiler to -ftrack-macro-expansion=2 by default. Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk. libcpp/ * init.c (cpp_create_reader): Switch -ftrack-macro-expansion=2 on by default. Add comments. gcc/docs/ * cppopts.texi: Adjust for enabling -ftrack-macro-expansion=2 by default. I don't think GCC 4.8.1 will ship early enough. A possible fix is to patch cgo to use -ftrack-macro-expansion=0, how will it behave with older GCCs? clang happily ignores it. diff -r 5260abd6df41 src/cmd/cgo/gcc.go --- a/src/cmd/cgo/gcc.go Sat Mar 30 19:05:00 2013 +0800 +++ b/src/cmd/cgo/gcc.go Sat Mar 30 18:12:48 2013 +0100 @@ -787,6 +787,10 @@ "-Wno-unused-function", "-Qunused-arguments", ) + } else { + c = append(c, + "-ftrack-macro-expansion=0", // GCC 4.8 misses statements with no effect (issue 5118). + ) } c = append(c, p.GccOptions...) |
have you filed bug reports to gcc? gcc on gentoo (version 4.6.3) still rejects the -ftrack-macro-expansion=0 option, so we need another workaround, i'm afraid (that option is introduced in gcc 4.7 and i think there will be plenty of pre 4.7 gcc installations out there, so just in case we can't find better workarounds, i'm inclined to leave this for Go 1.1.1). because gcc 4.8.0 is release before Go 1.1, i will label this issue as Go 1.1Maybe. Labels changed: added priority-soon, go1.1maybe, removed priority-triage. |
I don't know how to report: * I cannot attach preprocessed files to the report, because they compile fine * I cannot attach a copy of my stdio.h to the report, because including it from the local directory makes it work correctly. * Even replacing the include by #include "/usr/include/stdio.h" makes the warning work as expected. |
This is caused by bad interaction with -Wsystem-headers, so perhaps it's not a bug in the eyes of a gcc developer. @iant. $ cat stdio.c #include <test.h> void f(void) { stdout; } $ cat test.h int *stdout; #define stdout stdout $ gcc -Wall -Werror -c stdio.c -I . In file included from stdio.c:1:0: stdio.c: In function ‘f’: ./test.h:2:16: error: statement with no effect [-Werror=unused-value] #define stdout stdout ^ stdio.c:4:2: note: in expansion of macro ‘stdout’ stdout; ^ cc1: all warnings being treated as errors $ gcc -Wall -Werror -c stdio.c -isystem . $ $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-4.8.0/configure --enable-languages=c,c++,go,lto Thread model: posix gcc version 4.8.0 (GCC) |
Issue #5153 has been merged into this issue. |
I don't see this build error on Win7 (32-bit) or Win8 (64-bit) using one of the mingw-w64 based 4.8.0 toolchains from http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.0/ Only 4.8.0-based builds on my Arch 32 and 64-bit boxes currently fail. |
Filed http://gcc.gnu.org/PR57201 . |
This issue was closed by revision 8a28085. Status changed to Fixed. |
adg
added a commit
that referenced
this issue
May 11, 2015
…r errors ««« CL 9120045 / e4f62df3e6c9 cmd/cgo: pass -Wsystem-headers when looking for errors This works around a bug in GCC 4.8.0. Fixes #5118. R=golang-dev, r, minux.ma CC=golang-dev https://golang.org/cl/9120045 »»» R=golang-dev, r CC=golang-dev https://golang.org/cl/9259047
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: