This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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

Created on 2010-06-18 20:12 by matteo.vescovi, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg108136 - (view) Author: Matteo Vescovi (matteo.vescovi) Date: 2010-06-18 20:12

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
msg108183 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) 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.
Date User Action Args
2022-04-11 14:57:02adminsetgithub: 53277
2018-05-15 21:30:37eitan.adlersetnosy: + eitan.adler
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