Build Python with -fno-semantic-interposition

The compiler flag has been added to CFLAGS_NODIST and
LDFLAGS_NODIST. This will compile the core interpreter
and the stdlib modules with -fno-semantic-interposition
but will not affect user build and rpm C extension modules
compiled by distutils.

This has the effect of speeding up the interpreter up to
27%, depending on the workload, with the drawback of disabling
the capability of using LD_PRELOAD to override symbols in
libpython.

https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
This commit is contained in:
Charalampos Stratakis 2019-12-03 19:39:22 +01:00 committed by Miro Hrončok
parent 4b316fdc3f
commit 141731d4d0
1 changed files with 7 additions and 3 deletions

View File

@ -17,7 +17,7 @@ URL: https://www.python.org/
#global prerel ... #global prerel ...
%global upstream_version %{general_version}%{?prerel} %global upstream_version %{general_version}%{?prerel}
Version: %{general_version}%{?prerel:~%{prerel}} Version: %{general_version}%{?prerel:~%{prerel}}
Release: 2%{?dist} Release: 3%{?dist}
License: Python License: Python
@ -667,14 +667,14 @@ topdir=$(pwd)
# Fedora packages utilizing %%py3_build will use them as well # Fedora packages utilizing %%py3_build will use them as well
# https://fedoraproject.org/wiki/Changes/Python_Extension_Flags # https://fedoraproject.org/wiki/Changes/Python_Extension_Flags
export CFLAGS="%{extension_cflags} -D_GNU_SOURCE -fPIC -fwrapv" export CFLAGS="%{extension_cflags} -D_GNU_SOURCE -fPIC -fwrapv"
export CFLAGS_NODIST="%{build_cflags} -D_GNU_SOURCE -fPIC -fwrapv" export CFLAGS_NODIST="%{build_cflags} -D_GNU_SOURCE -fPIC -fwrapv -fno-semantic-interposition"
export CXXFLAGS="%{extension_cxxflags} -D_GNU_SOURCE -fPIC -fwrapv" export CXXFLAGS="%{extension_cxxflags} -D_GNU_SOURCE -fPIC -fwrapv"
export CPPFLAGS="$(pkg-config --cflags-only-I libffi)" export CPPFLAGS="$(pkg-config --cflags-only-I libffi)"
export OPT="%{extension_cflags} -D_GNU_SOURCE -fPIC -fwrapv" export OPT="%{extension_cflags} -D_GNU_SOURCE -fPIC -fwrapv"
export LINKCC="gcc" export LINKCC="gcc"
export CFLAGS="$CFLAGS $(pkg-config --cflags openssl)" export CFLAGS="$CFLAGS $(pkg-config --cflags openssl)"
export LDFLAGS="%{extension_ldflags} -g $(pkg-config --libs-only-L openssl)" export LDFLAGS="%{extension_ldflags} -g $(pkg-config --libs-only-L openssl)"
export LDFLAGS_NODIST="%{build_ldflags} -g $(pkg-config --libs-only-L openssl)" export LDFLAGS_NODIST="%{build_ldflags} -fno-semantic-interposition -g $(pkg-config --libs-only-L openssl)"
# We can build several different configurations of Python: regular and debug. # We can build several different configurations of Python: regular and debug.
# Define a common function that does one build: # Define a common function that does one build:
@ -1569,6 +1569,10 @@ CheckPython optimized
# ====================================================== # ======================================================
%changelog %changelog
* Tue Dec 03 2019 Miro Hrončok <mhroncok@redhat.com> - 3.8.0-3
- Build Python with -fno-semantic-interposition for better performance
- https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
* Thu Nov 28 2019 Miro Hrončok <mhroncok@redhat.com> - 3.8.0-2 * Thu Nov 28 2019 Miro Hrončok <mhroncok@redhat.com> - 3.8.0-2
- Recommend python3-tkinter when tk is installed - Recommend python3-tkinter when tk is installed