From 5049fc701561b258b722b3400460d8828ce9e64e Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Mon, 7 Nov 2022 10:41:34 +0200 Subject: [PATCH] Make CPU and thread-related macros available on all platforms %_smp_mflags and the related macros that it grew around itself used to be platform specific as they relied on external tooling (eg getconf for getting processor count), but since rpm 4.15 this has been backed by the built-in %{getncpus} macro which is available on all platforms, so there's zero reason to duplicate this stuff on all platform files. Fixes: #2265 --- macros.in | 16 ++++++++++++++++ platform.in | 16 ---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/macros.in b/macros.in index 7f13bf490e..a86f2b1964 100644 --- a/macros.in +++ b/macros.in @@ -700,6 +700,22 @@ package or when debugging this package.\ # Macro to fix broken permissions in sources %_fixperms %{__chmod} -Rf a+rX,u+w,g-w,o-w +# Maximum number of CPU's to use when building, 0 for unlimited. +#%_smp_ncpus_max 0 + +%_smp_build_ncpus %([ -z "$RPM_BUILD_NCPUS" ] \\\ + && RPM_BUILD_NCPUS="%{getncpus}"; \\\ + ncpus_max=%{?_smp_ncpus_max}; \\\ + if [ -n "$ncpus_max" ] && [ "$ncpus_max" -gt 0 ] && [ "$RPM_BUILD_NCPUS" -gt "$ncpus_max" ]; then RPM_BUILD_NCPUS="$ncpus_max"; fi; \\\ + echo "$RPM_BUILD_NCPUS";) + +%_smp_mflags -j%{_smp_build_ncpus} + +# Maximum number of threads to use when building, 0 for unlimited +#%_smp_nthreads_max 0 + +%_smp_build_nthreads %{_smp_build_ncpus} + #============================================================================== # ---- Scriptlet template templates. # Global defaults used for building scriptlet templates. diff --git a/platform.in b/platform.in index cda94f1803..1bd312669d 100644 --- a/platform.in +++ b/platform.in @@ -48,22 +48,6 @@ %_defaultdocdir %{_datadir}/doc -# Maximum number of CPU's to use when building, 0 for unlimited. -#%_smp_ncpus_max 0 - -%_smp_build_ncpus %([ -z "$RPM_BUILD_NCPUS" ] \\\ - && RPM_BUILD_NCPUS="%{getncpus}"; \\\ - ncpus_max=%{?_smp_ncpus_max}; \\\ - if [ -n "$ncpus_max" ] && [ "$ncpus_max" -gt 0 ] && [ "$RPM_BUILD_NCPUS" -gt "$ncpus_max" ]; then RPM_BUILD_NCPUS="$ncpus_max"; fi; \\\ - echo "$RPM_BUILD_NCPUS";) - -%_smp_mflags -j%{_smp_build_ncpus} - -# Maximum number of threads to use when building, 0 for unlimited -#%_smp_nthreads_max 0 - -%_smp_build_nthreads %{_smp_build_ncpus} - #============================================================================== # ---- Build policy macros. #