diff options
author | stratakis <cstratak@redhat.com> | 2018-12-19 17:19:01 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2018-12-19 17:19:01 (GMT) |
commit | cf10a750f4b50b6775719cfb17bee00bc3a9c60b (patch) | |
tree | b01cd3a429404cf2a2d58d8cfb35676c8969f5f6 /setup.py | |
parent | 55cc34500e5abbfedb89adc95e3f94d53c544933 (diff) | |
download | cpython-cf10a750f4b50b6775719cfb17bee00bc3a9c60b.zip cpython-cf10a750f4b50b6775719cfb17bee00bc3a9c60b.tar.gz cpython-cf10a750f4b50b6775719cfb17bee00bc3a9c60b.tar.bz2 |
bpo-35257: Avoid leaking LTO linker flags into distutils (GH-10900)
When compiling 3rd party C extensions, the linker flags used by the
compiler for the interpreter and the stdlib modules, will get
leaked into distutils. In order to avoid that, the PY_CORE_LDFLAGS
and PY_LDFLAGS_NODIST are introduced to keep those flags separated.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -18,11 +18,16 @@ from distutils.spawn import find_executable cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ -# Add special CFLAGS reserved for building the interpreter and the stdlib -# modules (Issue #21121). -cflags = sysconfig.get_config_var('CFLAGS') -py_cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') -sysconfig.get_config_vars()['CFLAGS'] = cflags + ' ' + py_cflags_nodist +# Set common compiler and linker flags derived from the Makefile, +# reserved for building the interpreter and the stdlib modules. +# See bpo-21121 and bpo-35257 +def set_compiler_flags(compiler_flags, compiler_py_flags_nodist): + flags = sysconfig.get_config_var(compiler_flags) + py_flags_nodist = sysconfig.get_config_var(compiler_py_flags_nodist) + sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist + +set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST') +set_compiler_flags('LDFLAGS', 'PY_LDFLAGS_NODIST') class Dummy: """Hack for parallel build""" |