#1130 Document %constrain_build
Closed 9 months ago by tibbs. Opened 2 years ago by tibbs.
tibbs/packaging-committee constrain  into  master

@@ -2331,18 +2331,33 @@ 

  %make_build

  ....

  

- This generally speeds up builds and especially on SMP machines.

+ This will pass appropriate flags to build in parallel

+ and set useful verbosity flags.

  

- 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

+ === Constraining Build Parallelism

  

- ....

- %_smp_mflags -j3

- ....

+ 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.

  

- to your `+~/.rpmmacros+` file -- even on UP machines --

- as this will expose most of these errors.

+ This macro will influence anything which considers the value of

+ `%_smp_build_ncpus` including

+ `%make_build`, `%cmake_build` and `%meson_build`.

  

  == Scriptlets

  

This adds a small subsection to the section on parallel make which documents the %constrain_build macro.

Currently this macro exists in rawhide, but after testing I will backport it through Fedora and EPEL. (It uses features from RPM 4.17 so this does require a little work.) So this shouldn't be merged right now.

As an aside, I'm curious as to which buildsystems this doesn't affect. I'm pretty sure it doesn't change what %pyproject_wheel does. I think Perl just uses %make_build. Rust seems to incorporate %_smp_mflags, as does ninja, so they should work. should work. I've no idea at all about go.

%pyproject_wheel by default does nothing parallel. If the build backends build stuff in parallel, there is currently no way to pass options to it.

I assumed that under the hood it could end up building native code extensions from source, but I've no idea at all how that build happens or whether it would use any parallelism. If we can't pass options down to it then it's nothing to worry about. If that becomes possible in future then I assume it would use %_smp_mflags under the hood and that would simply work automatically.

Yes, this was created to address the issues Panu had.

I just closed 1094 in favor of this one.

Closing this because in the end RPM upstream did something different.

Pull-Request has been closed by tibbs

9 months ago
Metadata