From: Rafael Sadowski Subject: Re: cmake.port.mk: limit max number of autogen moc/uic processes To: Jeremie Courreges-Anglas Cc: ports@openbsd.org, landry@openbsd.org Date: Thu, 2 May 2024 18:05:28 +0200 On Wed May 01, 2024 at 08:54:44PM GMT, Jeremie Courreges-Anglas wrote: > > Some projects use cmake_autogen to generate moc/uic/rcc jobs. The max > number of parallel jobs to run is AUTOGEN_PARALLEL[0], itself > initialized by CMAKE_AUTOGEN_PARALLEL. By default it's empty, which > means cmake_autogen will start up to $ncpus jobs on the system. Those > $ncpus are children of the cmake_autogen process and aren't accounted > in the global pool of ${MAKE_JOBS} jobs. So if you build an affected > port with MAKE_JOBS=1 on a 16 cores machine, you end up with 1 > cmake_autogen job + 16 moc/uic jobs = 17 jobs. That's not nice as we > may have other ports building in parallel. > > The diff below attempts to limit the max number of autogen jobs to > ${MAKE_JOBS}, so that the max number of jobs running at any time > doesn't exceed 2 * ${MAKE_JOBS}. Looks like there is no way to get > exactly ${MAKE_JOBS} jobs in total, but hopefully the behavior should > now be saner. > > Issue spotted while looking at qgis. Thoughts? ok? > > [0] https://cmake.org/cmake/help/latest/prop_tgt/AUTOGEN_PARALLEL.html > [1] https://cmake.org/cmake/help/latest/variable/CMAKE_AUTOGEN_PARALLEL.html I didn't know that we could also control this! Great finding! Tested with digikam and it looks like "/usr/local/bin/cmake -E cmake_autogen" uses the correct ${MAKE_JOBS} jobs. > > > Index: cmake.port.mk > =================================================================== > RCS file: /home/cvs/ports/devel/cmake/cmake.port.mk,v > diff -u -p -r1.84 cmake.port.mk > --- cmake.port.mk 29 Jul 2023 11:53:23 -0000 1.84 > +++ cmake.port.mk 1 May 2024 18:49:32 -0000 > @@ -13,6 +13,10 @@ CONFIGURE_ENV += MODCMAKE_USE_SHARED_LIB > MAKE_ENV += MODCMAKE_USE_SHARED_LIBS=yes > .endif > > +# Limit the number of moc/uic processes started by cmake_autogen > +# (default: number of CPUs on the system) > +CONFIGURE_ARGS += -DCMAKE_AUTOGEN_PARALLEL=${MAKE_JOBS} > + > USE_NINJA ?= Yes > > .if ${USE_NINJA:L} == "yes" Could we add it above, please? "CONFIGURE_ARGS :=>-------DCMAKE_ADDR2LINE:FILEPATH=/usr/bin/addr2line" Otherwise OK rsadowski