From 76a4388ee1140abe8590de29f6cd7a2f43a4b61b Mon Sep 17 00:00:00 2001 From: Charalampos Stratakis Date: Thu, 25 Jul 2024 19:16:27 +0200 Subject: [PATCH] Properly propagate the optimization flags to C extensions Resolves: RHEL-49635 --- python3.11.spec | 16 ++++++++++------ tests/tests.yml | 7 +++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/python3.11.spec b/python3.11.spec index 62c405b..461d0c8 100644 --- a/python3.11.spec +++ b/python3.11.spec @@ -20,7 +20,7 @@ URL: https://www.python.org/ #global prerel ... %global upstream_version %{general_version}%{?prerel} Version: %{general_version}%{?prerel:~%{prerel}} -Release: 4%{?dist} +Release: 5%{?dist} License: Python @@ -151,8 +151,6 @@ License: Python # 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 @@ -747,6 +745,7 @@ BuildPython() { ConfName=$1 ExtraConfigArgs=$2 MoreCFlags=$3 + MoreCFlagsNodist=$4 # Each build is done in its own directory ConfDir=build/$ConfName @@ -786,7 +785,7 @@ BuildPython() { $ExtraConfigArgs \ %{nil} -%global flags_override EXTRA_CFLAGS="$MoreCFlags" CFLAGS_NODIST="$CFLAGS_NODIST $MoreCFlags" +%global flags_override EXTRA_CFLAGS="$MoreCFlags" CFLAGS_NODIST="$CFLAGS_NODIST $MoreCFlags $MoreCFlagsNodist" %if %{without bootstrap} # Regenerate generated files (needs python3) @@ -809,11 +808,13 @@ BuildPython() { # See also: https://bugzilla.redhat.com/show_bug.cgi?id=1818857 BuildPython debug \ "--without-ensurepip --with-pydebug" \ - "%{optflags_debug}" + "%{optflags_debug}" \ + "" %endif # with debug_build BuildPython optimized \ "--without-ensurepip %{optimizations_flag}" \ + "" \ "%{optflags_optimized}" # ====================================================== @@ -920,7 +921,7 @@ InstallPython debug \ # Now the optimized build: InstallPython optimized \ %{py_INSTSONAME_optimized} \ - "%{optflags_optimized}" \ + "" \ %{LDVERSION_optimized} # Install directories for additional packages @@ -1652,6 +1653,9 @@ CheckPython optimized # ====================================================== %changelog +* Thu Jul 25 2024 Charalampos Stratakis - 3.11.9-5 +- Properly propagate the optimization flags to C extensions + * Thu Jul 18 2024 Charalampos Stratakis - 3.11.9-4 - Build Python with -O3 - https://fedoraproject.org/wiki/Changes/Python_built_with_gcc_O3 diff --git a/tests/tests.yml b/tests/tests.yml index 8c8ce24..5ce9c4d 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -34,9 +34,12 @@ - debugtest: dir: python/selftest run: "VERSION={{ pybasever }} PYTHON=python{{ pybasever }}d X='-i test_check_probes' ./parallel.sh" - - optimizedflags: + - optimizedflags_self: dir: python/flags - run: "python{{ pybasever }} ./assertflags.py -O3" + run: "python{{ pybasever }} ./assertflags.py -O3 PY_BUILTIN_MODULE_CFLAGS PY_CFLAGS_NODIST PY_CORE_CFLAGS PY_STDMODULE_CFLAGS" + - optimizedflags_3rd: + dir: python/flags + run: "python{{ pybasever }} ./assertflags.py -O2 CFLAGS PY_CFLAGS" - debugflags: dir: python/flags run: "python{{ pybasever }}d ./assertflags.py -O0"