Skip to content

Commit

Permalink
pythongh-89536: Use ThinLTO policy if possible (pythongh-96766)
Browse files Browse the repository at this point in the history
  • Loading branch information
corona10 authored Sep 16, 2022
1 parent 16c33a9 commit e47b96c
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ also be used to improve performance.
.. versionadded:: 3.11
To use ThinLTO feature, use ``--with-lto=thin`` on Clang.

.. versionchanged:: 3.12
Use ThinLTO as the default optimization policy on Clang if the compiler accepts the flag.

.. cmdoption:: --enable-bolt

Enable usage of the `BOLT post-link binary optimizer
Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ Build Changes
``va_start()`` is no longer called with a single parameter.
(Contributed by Kumar Aditya in :gh:`93207`.)

* CPython now uses the ThinLTO option as the default link time optimization policy
if the Clang compiler accepts the flag.
(Contributed by Dong-hee Na in :gh:`89536`.)


C API Changes
=============
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CPython now uses the ThinLTO option as the default policy if the Clang
compiler accepts the flag. Patch by Dong-hee Na.
82 changes: 79 additions & 3 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1863,8 +1863,15 @@ if test "$Py_LTO" = 'true' ; then
# Any changes made here should be reflected in the GCC+Darwin case below
if test $Py_LTO_POLICY = default
then
LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto"
# Check that ThinLTO is accepted.
AX_CHECK_COMPILE_FLAG([-flto=thin],[
LTOFLAGS="-flto=thin -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto=thin"
],[
LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto"
]
)
else
LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
LTOCFLAGS="-flto=${Py_LTO_POLICY}"
Expand All @@ -1873,7 +1880,8 @@ if test "$Py_LTO" = 'true' ; then
*)
if test $Py_LTO_POLICY = default
then
LTOFLAGS="-flto"
# Check that ThinLTO is accepted
AX_CHECK_COMPILE_FLAG([-flto=thin],[LTOFLAGS="-flto=thin"],[LTOFLAGS="-flto"])
else
LTOFLAGS="-flto=${Py_LTO_POLICY}"
fi
Expand Down

0 comments on commit e47b96c

Please sign in to comment.