[Python-checkins] bpo-38980: Add -fno-semantic-interposition when building with optimizations (GH-22862)

pablogsal webhook-mailer at python.org
Wed Oct 21 17:46:57 EDT 2020


https://github.com/python/cpython/commit/b451b0e9a772f009f4161f7a46476190d0d17ac1
commit: b451b0e9a772f009f4161f7a46476190d0d17ac1
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2020-10-21T22:46:52+01:00
summary:

bpo-38980: Add -fno-semantic-interposition when building with optimizations (GH-22862)

files:
A Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst
M Doc/whatsnew/3.10.rst
M configure
M configure.ac

diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index e275a7cb4573f..e464be6eb7e95 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -256,6 +256,14 @@ Optimizations
   It is about 36% faster now.  (Contributed by Pablo Galindo and Yury Selivanov
   in :issue:`42093`.)
 
+* When building Python with ``--enable-optimizations`` now
+  ``-fno-semantic-interposition`` is added to both the compile and link line.
+  This speeds builds of the Python interpreter created with ``--enable-shared``
+  with ``gcc`` by up to 30%. See `this article
+  <https://developers.redhat.com/blog/2020/06/25/red-hat-enterprise-linux-8-2-brings-faster-python-3-8-run-speeds/>`_
+  for more details. (Contributed by Victor Stinner and Pablo Galindo in
+  :issue:`38980`)
+
 Deprecated
 ==========
 
diff --git a/Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst b/Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst
new file mode 100644
index 0000000000000..c9d34cf12c292
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2020-10-21-18-31-54.bpo-38980.xz7BNd.rst
@@ -0,0 +1,3 @@
+Add ``-fno-semantic-interposition`` to both the compile and link line when
+building with ``--enable-optimizations``. Patch by Victor Stinner and Pablo
+Galindo.
diff --git a/configure b/configure
index 88b78947767fa..df7118f68d3bb 100755
--- a/configure
+++ b/configure
@@ -6482,6 +6482,14 @@ if test "$Py_OPT" = 'true' ; then
   DEF_MAKE_ALL_RULE="profile-opt"
   REQUIRE_PGO="yes"
   DEF_MAKE_RULE="build_all"
+  case $CC in
+    *gcc*)
+      CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
+      LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
+      ;;
+  esac
+
+
 else
   DEF_MAKE_ALL_RULE="build_all"
   REQUIRE_PGO="no"
diff --git a/configure.ac b/configure.ac
index 6ffe90a4c426c..c63c1e88a2302 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1318,6 +1318,14 @@ if test "$Py_OPT" = 'true' ; then
   DEF_MAKE_ALL_RULE="profile-opt"
   REQUIRE_PGO="yes"
   DEF_MAKE_RULE="build_all"
+  case $CC in
+    *gcc*)
+      CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
+      LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
+      ;;
+  esac
+
+
 else
   DEF_MAKE_ALL_RULE="build_all"
   REQUIRE_PGO="no"



More information about the Python-checkins mailing list