Skip to content

Commit ae60fa3

Browse files
committed
bpo-38980: Add -fno-semantic-interposition when building with optimizations
1 parent c7437e2 commit ae60fa3

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

Doc/whatsnew/3.10.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ Optimizations
256256
It is about 36% faster now. (Contributed by Pablo Galindo and Yury Selivanov
257257
in :issue:`42093`.)
258258

259+
* When building Python with ``--enable-optimizations`` now
260+
`-fno-semantic-interposition` is added to both the compile and link line.
261+
This speeds builds of the Python interpreter created with ``--enable-shared``
262+
with ``gcc`` by up to 30%. See `this article
263+
<https://developers.redhat.com/blog/2020/06/25/red-hat-enterprise-linux-8-2-brings-faster-python-3-8-run-speeds/>`_
264+
for more details. (Contributed by Victor Stinner and Pablo Galindo in
265+
:issue:`38980`)
266+
259267
Deprecated
260268
==========
261269

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add ``-fno-semantic-interposition`` to both the compile and link line when
2+
building with ``--enable-optimizations``. Patch by Victor Stinner and Pablo
3+
Galindo.

configure

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6482,6 +6482,14 @@ if test "$Py_OPT" = 'true' ; then
64826482
DEF_MAKE_ALL_RULE="profile-opt"
64836483
REQUIRE_PGO="yes"
64846484
DEF_MAKE_RULE="build_all"
6485+
case $CC in
6486+
*gcc*)
6487+
CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
6488+
LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
6489+
;;
6490+
esac
6491+
6492+
64856493
else
64866494
DEF_MAKE_ALL_RULE="build_all"
64876495
REQUIRE_PGO="no"

configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,6 +1318,14 @@ if test "$Py_OPT" = 'true' ; then
13181318
DEF_MAKE_ALL_RULE="profile-opt"
13191319
REQUIRE_PGO="yes"
13201320
DEF_MAKE_RULE="build_all"
1321+
case $CC in
1322+
*gcc*)
1323+
CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
1324+
LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
1325+
;;
1326+
esac
1327+
1328+
13211329
else
13221330
DEF_MAKE_ALL_RULE="build_all"
13231331
REQUIRE_PGO="no"

0 commit comments

Comments
 (0)