From 20c8e5f027139175f322395d86d0c9886c81fcfbaca55687e0c5201a6acf710a Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 4 Nov 2025 10:09:03 +0100 Subject: [PATCH] Update --- memory-constraints.changes | 5 +++++ memory-constraints.macros | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/memory-constraints.changes b/memory-constraints.changes index 9df30c7..e4f8e71 100644 --- a/memory-constraints.changes +++ b/memory-constraints.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Nov 3 07:47:52 UTC 2025 - Andreas Schwab + +- Never use more than the configured jobs + ------------------------------------------------------------------- Thu Jan 9 11:29:51 UTC 2025 - Guillaume GARDET diff --git a/memory-constraints.macros b/memory-constraints.macros index 54385c7..f5ae2b8 100644 --- a/memory-constraints.macros +++ b/memory-constraints.macros @@ -7,7 +7,9 @@ # m: memory limit in MBs per core; default is 1000 %limit_build(m:) \ - _threads="`/usr/bin/getconf _NPROCESSORS_ONLN`" \ + _threads="$(/usr/bin/getconf _NPROCESSORS_ONLN)" \ + _jobs="%{?jobs}%{!?jobs:${RPM_BUILD_NCPUS:-$_threads}}" \ + test "$_threads" -gt "$_jobs" && _threads=$_jobs \ _core_memory="%{-m:%{-m*}}%{!-m:1000}" \ echo "Available memory:" \ cat /proc/meminfo \ @@ -22,7 +24,7 @@ test "$_threads" -gt "$max_jobs" && _threads="$max_jobs" && echo "Warning: Reducing number of jobs to $max_jobs because of memory limits" \ test "$_threads" -le 0 && _threads=1 && echo "Warning: Do not use the parallel build at all because of memory limits" \ fi \ - %global jobs $([[ -n $_threads ]] && echo $_threads || echo "`/usr/bin/getconf _NPROCESSORS_ONLN`") \ - %global _smp_mflags $([[ -n $_threads ]] && echo "-j$_threads" || echo "-j`/usr/bin/getconf _NPROCESSORS_ONLN`") \ - %global _smp_build_ncpus $([[ -n $_threads ]] && echo "$_threads" || echo "`/usr/bin/getconf _NPROCESSORS_ONLN`") \ + %global jobs $([[ -n $_threads ]] && echo "$_threads" || echo "$_jobs") \ + %global _smp_mflags $([[ -n $_threads ]] && echo "-j$_threads" || echo "-j$_jobs") \ + %global _smp_build_ncpus $([[ -n $_threads ]] && echo "$_threads" || echo "$_jobs") \ %{nil} -- 2.51.1