From 88b5ff75f543acac18f6d8b0582980010bd831c9 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Nov 01 2021 22:54:35 +0000 Subject: [PATCH 1/2] Remove outdated SMP language Since most everything is SMP these days, clean up the language in the Parallel Make section. --- diff --git a/guidelines/modules/ROOT/pages/index.adoc b/guidelines/modules/ROOT/pages/index.adoc index 3ea19f4..323ec05 100644 --- a/guidelines/modules/ROOT/pages/index.adoc +++ b/guidelines/modules/ROOT/pages/index.adoc @@ -2331,18 +2331,8 @@ Whenever possible, invocations of `+make+` should be done as %make_build .... -This generally speeds up builds and especially on SMP machines. - -Do make sure, however, that the package builds cleanly this way -as some make files do not support parallel building. -Therefore you should consider adding - -.... -%_smp_mflags -j3 -.... - -to your `+~/.rpmmacros+` file -- even on UP machines -- -as this will expose most of these errors. +This will pass appropriate flags to build in parallel +and set useful verbosity flags. == Scriptlets From f98fddec7fd2fd1302f41524631015b172dd6d59 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Nov 01 2021 23:37:10 +0000 Subject: [PATCH 2/2] Document %constrain_build --- diff --git a/guidelines/modules/ROOT/pages/index.adoc b/guidelines/modules/ROOT/pages/index.adoc index 323ec05..c690e40 100644 --- a/guidelines/modules/ROOT/pages/index.adoc +++ b/guidelines/modules/ROOT/pages/index.adoc @@ -2334,6 +2334,31 @@ Whenever possible, invocations of `+make+` should be done as This will pass appropriate flags to build in parallel and set useful verbosity flags. +=== Constraining Build Parallelism + +The `%constrain_build` macro can be used near the top of the spec file +to constrain build parallelism. +When called with no arguments, the CPU count will be reduced to one. +The `+-c+` option will set the CPU count to a given value: + + %constrain_build -c 4 + +will force the build to use at most four CPUs. + +The `+-m+` option allows you to specify the amount of memory +in megabytes which a single build thread takes. +The macro will divide the total amount of memory in the system +by this value and set the CPU count to the result (rounded down). +On a machine with 32GB of memory: + + %constrain_build -m 10000 + +will set the CPU count to three. + +This macro will influence anything which considers the value of +`%_smp_build_ncpus` including +`%make_build`, `%cmake_build` and `%meson_build`. + == Scriptlets Great care should be taken when using scriptlets in Fedora packages.