Skip to content

Commit

Permalink
Make CPU and thread-related macros available on all platforms
Browse files Browse the repository at this point in the history
%_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: rpm-software-management#2265
  • Loading branch information
pmatilai committed Nov 8, 2022
1 parent 3d56ca2 commit 5049fc7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 16 additions & 0 deletions macros.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 0 additions & 16 deletions platform.in
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down

0 comments on commit 5049fc7

Please sign in to comment.