Author matteo.vescovi
Recipients matteo.vescovi, tarek
Date 2010-06-18.20:12:29
SpamBayes Score 6.24642e-11
Marked as misclassified No
Message-id <>

It seems like distutils passes an invalid "-Wstrict-prototypes" flag when compiling a C++ extension module on Linux (tested on Debian lenny and sid).

running build
running build_py
creating build
creating build/lib.linux-i686-2.6
copying -> build/lib.linux-i686-2.6
running build_ext
building '_presage' extension
creating build/temp.linux-i686-2.6
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -O2 -g -Wall -O2 -fPIC -I../../src/lib -I/usr/include/python2.6 -c presage_wrap.cpp -o build/temp.linux-i686-2.6/presage_wrap.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -L/usr/local/lib -Wl,--as-needed -g -O2 -g -Wall -O2 build/temp.linux-i686-2.6/presage_wrap.o -L../../src/lib/.libs -lpresage -o build/lib.linux-i686-2.6/
running build_scripts
creating build/scripts-2.6
copying and adjusting presage_python_demo -> build/scripts-2.6
changing mode of build/scripts-2.6/presage_python_demo from 644 to 755

I did a bit of digging on this one. It looks like distutils reuses whatever flags python was built with.

matt@burrow:/usr/lib/python2.5/distutils$ python2.5
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sysconfig
>>> sysconfig.get_config_var("CFLAGS")
'-fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes'

In /usr/lib/python2.5/distutils/ I found this comment:

# XXX Things not currently handled:
#   * optimization/debug/warning flags; we just use whatever's in Python's
#     Makefile and live with it.  Is this adequate?  If not, we might
#     have to have a bunch of subclasses GNUCCompiler, SGICCompiler,
#     SunCCompiler, and I suspect down that road lies madness.

It would be nice is distutils was smart enough to recognize that a c++ module was being built and to strip the unneeded flags.

Please consider this as a wishlist request, as this causes only a warning, not a failure.

- Matteo
Date User Action Args
2010-06-18 20:12:32matteo.vescovisetrecipients: + matteo.vescovi, tarek
2010-06-18 20:12:32matteo.vescovisetmessageid: <>
2010-06-18 20:12:31matteo.vescovilinkissue9031 messages
2010-06-18 20:12:29matteo.vescovicreate