I am on Debian GNU/Linux unstable (updated daily).
Python-related package versions are:
python: 2.7.2-9
python2.7: 2.7.2-12
python2.7-minimal: 2.7.2-12
python-dev: 2.7.2-9
python2.7-dev: 2.7.2-12
$ python-config --cflags
-I/usr/include/python2.7 -I/usr/include/python2.7
I conclude that this is a packaging bug in Debian's Python package?
I will file an appropriate bug to Debian bug tracking system.
On the other hand, you can see that broken python-config scripts are
in the wild, so it may be a good idea to add -fno-strict-aliasing anyway.
2012/1/17, David Malcolm <dmalcolm(a)redhat.com>:
On Sun, 2012-01-15 at 20:47 +0900, Seo Sanghyeon wrote:
> I have a problem building gcc-python-plugin. (commit 50214ad8)
>
> cc -I/usr/lib/gcc/i486-linux-gnu/4.6/plugin/include -fPIC -O2 -Wall
> -Werror -g -I/usr/include/python2.7 -I/usr/include/python2.7
> -L/usr/lib/python2.7/config -lpthread -ldl -lutil -lm -lpython2.7
> -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions -c -o
> autogenerated-callgraph.o autogenerated-callgraph.c
> autogenerated-callgraph.c: In function
> 'autogenerated_callgraph_add_types':
> autogenerated-callgraph.c:211:5: error: dereferencing type-punned
> pointer will break strict-aliasing rules [-Werror=strict-aliasing]
> autogenerated-callgraph.c:214:5: error: dereferencing type-punned
> pointer will break strict-aliasing rules [-Werror=strict-aliasing]
> cc1: all warnings being treated as errors
Thanks for posting this. What OS are you building this on, with what
version of Python? What's the output of running this command:
$ python-config --cflags
On the builds on my machine, those lines are the invocations of the
Py_INCREF() macro here:
209 void autogenerated_callgraph_add_types(PyObject *m)
210 {
211 Py_INCREF(&gcc_CallgraphEdgeType);
212 PyModule_AddObject(m, "CallgraphEdge", (PyObject
*)&gcc_CallgraphEdgeType);
213
214 Py_INCREF(&gcc_CallgraphNodeType);
215 PyModule_AddObject(m, "CallgraphNode", (PyObject
*)&gcc_CallgraphNodeType);
Unfortunately, Python 2's implementation of various macros including
Py_INCREF() relies on undefined C behavior. See PEP 3123:
http://www.python.org/dev/peps/pep-3123/
which has the gory details.
Thus on modern GCCs it *needs* "-fno-strict-aliasing" in the build flags
to avoid this error from gcc: see also e.g.
http://codespeak.net/pipermail/cython-dev/2008-April/000380.html
http://bugs.python.org/issue969718
The plugin is getting its build flags from $(python-config --cflags).
That *ought* to contain "-fno-strict-aliasing".
Perhaps the plugin's Makefile should simply add this flag for good
measure? (Trivial patch attached)
Hope this is helpful
Dave