classification
Title: distutils uses invalid "-Wstrict-prototypes" flag when compiling C++ extension module
Type: enhancement Stage: resolved
Components: Distutils Versions: Python 3.2
process
Status: closed Resolution: duplicate
Dependencies: Superseder: C++ compilation support for distutils
View: 1222585
Assigned To: tarek Nosy List: Arfrever, eric.araujo, matteo.vescovi, tarek
Priority: low Keywords:

Created on 2010-06-18 20:12 by matteo.vescovi, last changed 2010-09-07 13:32 by eric.araujo. This issue is now closed.

Messages (2)
msg108136 - (view) Author: Matteo Vescovi (matteo.vescovi) Date: 2010-06-18 20:12
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@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
msg108183 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * Date: 2010-06-19 14:27
It's a duplicate of issue #1222585. The patch in that issue will also make distutils not reuse flags Python was built with.
History
Date User Action Args
2010-09-07 13:32:50eric.araujosetnosy: + eric.araujo

superseder: C++ compilation support for distutils
stage: resolved
2010-08-07 21:32:14terry.reedysetstatus: open -> closed
resolution: duplicate
versions: + Python 3.2, - Python 2.6
2010-06-19 14:27:39Arfreversetnosy: + Arfrever
messages: + msg108183
2010-06-18 20:46:54tareksetpriority: normal -> low
versions: - Python 2.5
2010-06-18 20:12:31matteo.vescovicreate