New submission from STINNER Victor <[email protected]>:
When a C extension is built by distutils,
distutils.sysconfig.customize_compiler() is used to configure compiler flags.
Extract of the code:
(cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
...
if 'CFLAGS' in os.environ:
cflags = opt + ' ' + os.environ['CFLAGS']
ldshared = ldshared + ' ' + os.environ['CFLAGS']
if 'CPPFLAGS' in os.environ:
cpp = cpp + ' ' + os.environ['CPPFLAGS']
cflags = cflags + ' ' + os.environ['CPPFLAGS']
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
...
If the CFLAGS environment variable is set, the 'CFLAGS' configuration variable
is overriden with the 'OPT' configuration variable: cflags = opt + ...
This bug has been fixed since 2013 in Fedora and RHEL by this patch:
https://src.fedoraproject.org/rpms/python2/blob/master/f/00168-distutils-cflags.patch
RHEL bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=849994
I converted that patch to a pull request.
----------
components: Build
messages: 337468
nosy: vstinner
priority: normal
severity: normal
status: open
title: distutils.sysconfig.customize_compiler() overrides CFLAGS var with OPT
var if CFLAGS env var is set
versions: Python 2.7, Python 3.7, Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36235>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com