]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Revert "gh-130048: Reintroduce full LTO as default on Clang (GH-130049)" (#130088)
authorKen Jin <kenjin@python.org>
Thu, 13 Feb 2025 17:27:19 +0000 (01:27 +0800)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2025 17:27:19 +0000 (17:27 +0000)
This reverts commit 34c06ccc4c6c21935b46302935f3df24b00daa2c.

Doc/using/configure.rst
Doc/whatsnew/3.14.rst
Misc/NEWS.d/next/Build/2025-02-12-19-51-19.gh-issue-130048.kHNkzP.rst [deleted file]
configure
configure.ac

index e7116d55815679d1f9c81613402713cc7baef379..72912cea2f0c28ebc471fb428dc5a11b1825bdc2 100644 (file)
@@ -575,9 +575,6 @@ also be used to improve performance.
    .. versionchanged:: 3.12
       Use ThinLTO as the default optimization policy on Clang if the compiler accepts the flag.
 
-   .. versionchanged:: next
-      Revert to using full LTO as the default optimization policy on Clang.
-
 .. option:: --enable-bolt
 
    Enable usage of the `BOLT post-link binary optimizer
index 8e4b617181fd99ef5156d6244e3e0db4c99b215e..ece5afd4597ab8d3005415eb11981d22a16ffef2 100644 (file)
@@ -1279,10 +1279,6 @@ Build changes
 * GNU Autoconf 2.72 is now required to generate :file:`configure`.
   (Contributed by Erlend Aasland in :gh:`115765`.)
 
-* CPython now uses Full LTO as the default link time optimization policy
-  on Clang. This reverts an earlier change in CPython 3.12.
-  (Contributed by Ken Jin in :gh:`130049`.)
-
 .. _whatsnew314-pep761:
 
 PEP 761: Discontinuation of PGP signatures
diff --git a/Misc/NEWS.d/next/Build/2025-02-12-19-51-19.gh-issue-130048.kHNkzP.rst b/Misc/NEWS.d/next/Build/2025-02-12-19-51-19.gh-issue-130048.kHNkzP.rst
deleted file mode 100644 (file)
index 2344325..0000000
+++ /dev/null
@@ -1 +0,0 @@
-CPython now uses Full LTO as the default link time optimization policy on Clang. This reverts an earlier change in CPython 3.12.
index bebc8bc1a34f9be249a36dbedc8edf3949ea349e..453b0123ded0a4fced492e20b16624c8484bf699 100755 (executable)
--- a/configure
+++ b/configure
@@ -8766,8 +8766,55 @@ printf "%s\n" "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
           # 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.
+            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -flto=thin" >&5
+printf %s "checking whether C compiler accepts -flto=thin... " >&6; }
+if test ${ax_cv_check_cflags___flto_thin+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e)
+  ax_check_save_flags=$CFLAGS
+  CFLAGS="$CFLAGS  -flto=thin"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ax_cv_check_cflags___flto_thin=yes
+else case e in #(
+  e) ax_cv_check_cflags___flto_thin=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+  CFLAGS=$ax_check_save_flags ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___flto_thin" >&5
+printf "%s\n" "$ax_cv_check_cflags___flto_thin" >&6; }
+if test "x$ax_cv_check_cflags___flto_thin" = xyes
+then :
+
+              LTOFLAGS="-flto=thin -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
+              LTOCFLAGS="-flto=thin"
+
+else case e in #(
+  e)
+              LTOFLAGS="-flto -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
+              LTOCFLAGS="-flto"
+
+             ;;
+esac
+fi
+
           else
             LTOFLAGS="-flto=${Py_LTO_POLICY} -Wl,-export_dynamic -Wl,-object_path_lto,\"\$@\".lto"
             LTOCFLAGS="-flto=${Py_LTO_POLICY}"
@@ -8776,7 +8823,48 @@ printf "%s\n" "$as_me: llvm-ar found via xcrun: ${LLVM_AR}" >&6;}
         *)
           if test $Py_LTO_POLICY = default
           then
-            LTOFLAGS="-flto"
+            # Check that ThinLTO is accepted
+            { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -flto=thin" >&5
+printf %s "checking whether C compiler accepts -flto=thin... " >&6; }
+if test ${ax_cv_check_cflags___flto_thin+y}
+then :
+  printf %s "(cached) " >&6
+else case e in #(
+  e)
+  ax_check_save_flags=$CFLAGS
+  CFLAGS="$CFLAGS  -flto=thin"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  ax_cv_check_cflags___flto_thin=yes
+else case e in #(
+  e) ax_cv_check_cflags___flto_thin=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+  CFLAGS=$ax_check_save_flags ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___flto_thin" >&5
+printf "%s\n" "$ax_cv_check_cflags___flto_thin" >&6; }
+if test "x$ax_cv_check_cflags___flto_thin" = xyes
+then :
+  LTOFLAGS="-flto=thin"
+else case e in #(
+  e) LTOFLAGS="-flto" ;;
+esac
+fi
+
           else
             LTOFLAGS="-flto=${Py_LTO_POLICY}"
           fi
index e1e335a4d4b2a1b50ac0578b4bc7ee747d723681..234ae90616af623304d273b9f259089f71af8478 100644 (file)
@@ -1986,8 +1986,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}"
@@ -1996,7 +2003,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