[New-bugs-announce] [issue9031] distutils uses invalid "-Wstrict-prototypes" flag when compiling C++ extension module

Matteo Vescovi report at bugs.python.org
Fri Jun 18 22:12:32 CEST 2010


New submission from Matteo Vescovi <matteo.vescovi at yahoo.co.uk>:

Hi,

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 presage.py -> 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/_presage.so
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 at 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/unixcompiler.py 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.


Cheers,
- Matteo

----------
assignee: tarek
components: Distutils
messages: 108136
nosy: matteo.vescovi, tarek
priority: normal
severity: normal
status: open
title: distutils uses invalid "-Wstrict-prototypes" flag when compiling C++ extension module
type: feature request
versions: Python 2.5, Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9031>
_______________________________________


More information about the New-bugs-announce mailing list