From 7c1bddc0d4b2d7027b495856efd81250342b90c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Mon, 6 May 2024 11:41:41 +0200 Subject: [PATCH] Build Python with -O3 https://fedoraproject.org/wiki/Changes/Python_built_with_gcc_O3 Resolves: RHEL-49638 --- python39.spec | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/python39.spec b/python39.spec index d345900..49fe2d1 100644 --- a/python39.spec +++ b/python39.spec @@ -17,7 +17,7 @@ URL: https://www.python.org/ #global prerel ... %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} -Release: 3%{?dist} +Release: 4%{?dist} License: Python # Exclude i686 arch. Due to a modularity issue it's being added to the @@ -182,6 +182,15 @@ ExcludeArch: i686 %global py_INSTSONAME_optimized libpython%{LDVERSION_optimized}.so.%{py_SOVERSION} %global py_INSTSONAME_debug libpython%{LDVERSION_debug}.so.%{py_SOVERSION} +# The -O flag for the compiler, optimized builds +# https://fedoraproject.org/wiki/Changes/Python_built_with_gcc_O3 +%global optflags_optimized -O3 +# The -O flag for the compiler, debug builds +# -Wno-cpp avoids some warnings with -O0 +%global optflags_debug -O0 -Wno-cpp +# Remove the default -O2 flag, our flags are applied in %%build/%%install +%global __global_compiler_flags %(echo '%{__global_compiler_flags}' | sed 's/-O[[:digit:]]//') + # Disable automatic bytecompilation. The python3 binary is not yet be # available in /usr/bin when Python is built. Also, the bytecompilation fails # on files that test invalid syntax. @@ -1007,12 +1016,12 @@ BuildPython() { # See also: https://bugzilla.redhat.com/show_bug.cgi?id=1818857 BuildPython debug \ "--without-ensurepip --with-pydebug" \ - "-O0 -Wno-cpp" + "%{optflags_debug}" %endif # with debug_build BuildPython optimized \ "--without-ensurepip %{optimizations_flag}" \ - "" + "%{optflags_optimized}" # ====================================================== # Installing the built code: @@ -1111,14 +1120,14 @@ EOF %if %{with debug_build} InstallPython debug \ %{py_INSTSONAME_debug} \ - -O0 \ + "%{optflags_debug}" \ %{LDVERSION_debug} %endif # with debug_build # Now the optimized build: InstallPython optimized \ %{py_INSTSONAME_optimized} \ - "" \ + "%{optflags_optimized}" \ %{LDVERSION_optimized} # Install directories for additional packages @@ -2045,6 +2054,10 @@ fi # ====================================================== %changelog +* Thu Jul 18 2024 Charalampos Stratakis - 3.9.19-4 +- Build Python with -O3 +- https://fedoraproject.org/wiki/Changes/Python_built_with_gcc_O3 + * Thu Jul 18 2024 Charalampos Stratakis - 3.9.19-3 - Security fix for CVE-2024-4032 Resolves: RHEL-44094