File gh-145802-atomic-profile-update-for-PGO.patch of Package python315

From dfb0a1a7f16430fa34e886d8fbe1991cb7a06e51 Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Wed, 11 Mar 2026 11:55:36 +0100
Subject: [PATCH] gh-145801: Use gcc -fprofile-update=atomic for PGO builds

When Python build is optimized by PGO, use GCC
-fprofile-update=atomic option to use atomic operations when updating
profile information. This option reduces the risk of gcov Data Files
(.gcda) corruption which can cause random GCC crashes.
---
 Misc/NEWS.d/next/Build/2026-03-11-11-58-42.gh-issue-145801.iCXa3v.rst |    4 ++++
 configure                                                             |    2 +-
 configure.ac                                                          |    2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 Misc/NEWS.d/next/Build/2026-03-11-11-58-42.gh-issue-145801.iCXa3v.rst

Index: Python-3.15.0a7/Misc/NEWS.d/next/Build/2026-03-11-11-58-42.gh-issue-145801.iCXa3v.rst
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ Python-3.15.0a7/Misc/NEWS.d/next/Build/2026-03-11-11-58-42.gh-issue-145801.iCXa3v.rst	2026-03-11 14:40:47.055558773 +0100
@@ -0,0 +1,4 @@
+When Python build is optimized by PGO, use GCC ``-fprofile-update=atomic``
+option to use atomic operations when updating profile information. This option
+reduces the risk of gcov Data Files (.gcda) corruption which can cause random
+GCC crashes. Patch by Victor Stinner.
Index: Python-3.15.0a7/configure
===================================================================
--- Python-3.15.0a7.orig/configure	2026-03-10 13:31:15.000000000 +0100
+++ Python-3.15.0a7/configure	2026-03-11 14:40:47.059323607 +0100
@@ -9083,7 +9083,7 @@
     fi
     ;;
   gcc)
-    PGO_PROF_GEN_FLAG="-fprofile-generate"
+    PGO_PROF_GEN_FLAG="-fprofile-generate -fprofile-update=atomic"
     PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
     LLVM_PROF_MERGER="true"
     LLVM_PROF_FILE=""
Index: Python-3.15.0a7/configure.ac
===================================================================
--- Python-3.15.0a7.orig/configure.ac	2026-03-11 14:40:40.007249549 +0100
+++ Python-3.15.0a7/configure.ac	2026-03-11 14:40:47.061622097 +0100
@@ -2084,7 +2084,7 @@
     fi
     ;;
   gcc)
-    PGO_PROF_GEN_FLAG="-fprofile-generate"
+    PGO_PROF_GEN_FLAG="-fprofile-generate -fprofile-update=atomic"
     PGO_PROF_USE_FLAG="-fprofile-use -fprofile-correction"
     LLVM_PROF_MERGER="true"
     LLVM_PROF_FILE=""
openSUSE Build Service is sponsored by