blob: 4147b7e7b4c026c2520e014edf3ce1df912ef313 [file] [log] [blame]
Fix gcc 4.8 build broken for python 2.7.
The error was reported while building chromeos-chrome - "error:
'PyArg_ParseTuple' is an unrecognized format function type". The issue is that
'-Wformat' is no longer included by default in gcc 4.8. The solution is to add
'-Wformat' explictly to configure. For GCC 4.7, since '-Wformat' is enabled by
default, the modification has no impact to current gcc. Below shows the
difference between gcc 4.7 and gcc 4.8.
void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
int
main ()
{
;
return 0;
}
With gcc 4.7:
$ gcc -Werror /tmp/foo.c
/tmp/foo.c:1:1: error: PyArg_ParseTuple is an unrecognized format function type [-Werror=format]
cc1: all warnings being treated as errors
$ echo $?
1
With gcc 4.8:
$ ~/coding/gcc-python/gcc-svn-trunk/install/bin/gcc -Werror /tmp/foo.c
$ echo $?
0
but on adding -Wall:
$ ~/coding/gcc-python/gcc-svn-trunk/install/bin/gcc -Werror -Wall /tmp/foo.c
/tmp/foo.c:1:1: error: PyArg_ParseTuple is an unrecognized format function type [-Werror=format=]
void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
^
cc1: all warnings being treated as errors
$ echo $?
1
or indeed just -Wformat:
$ ~/coding/gcc-python/gcc-svn-trunk/install/bin/gcc -Werror -Wformat /tmp/foo.c
/tmp/foo.c:1:1: error: PyArg_ParseTuple is an unrecognized format function type [-Werror=format=]
void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));
^
cc1: all warnings being treated as errors
$ echo $?
1
--- configure.in.orig 2013-04-09 11:13:52.568435225 -0700
+++ configure.in 2013-04-09 11:14:06.998565440 -0700
@@ -1192,7 +1192,7 @@ if test "$GCC" = "yes"
then
AC_MSG_CHECKING(whether gcc supports ParseTuple __format__)
save_CFLAGS=$CFLAGS
- CFLAGS="$CFLAGS -Werror"
+ CFLAGS="$CFLAGS -Werror -Wformat"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[void f(char*,...)__attribute((format(PyArg_ParseTuple, 1, 2)));]], [[]])
],[