[Slackbuilds-users] make -j${NUMJOBS} discussion

Jeremy Hansen jebrhansen+SBo at gmail.com
Mon Apr 4 08:41:38 UTC 2022


On Sun, Apr 3, 2022, 5:44 PM Slackbuilds <sbo at linuxgalaxy.org> wrote:

> On 4/3/22 11:59, B. Watson wrote:
> > How about you do this instead?
> >
> > if [ -z "$MAKEFLAGS" ]; then
> >    NUMJOBS="${NUMJOBS:-1}"
> >    export MAKEFLAGS="-j$NUMJOBS"
> > fi
> > make
> >
> > ...that way, your builds work the way you want: they respect NUMJOBS
> > if MAKEFLAGS isn't set... but they'll still work the way everyone else
> > wants: people who already use MAKEFLAGS will still get the expected
> > results.
>
> I'm still not convinced that globally setting MAKEFLAGS won't have
> unintended consequences. I keep seeing in the make docs that the
> toplevel make creates/sets MAKEFILE for sub-makes, but isn't clear in
> what happens if MAKEFILES is already set, unless upstream source adds
> that logic.
>
> Setting 'make -j$NUMJOBS' seems a safer path, and is what Pat does in
> Slackware source.
>

This had been discussed on LQ and it was found that make is smart enough to
talk with its own sub-makes to ensure no more than the max number of jobs
can take place (specifically post #23, which is mine).

https://www.linuxquestions.org/questions/slackware-14/multi-thread-builds-via-sbopkg-slackbuilds-4175684827/

The only time it doesn't happen is if a makefile is poorly made as
demonstrated by pan64. However, I've had a global MAKEFLAGS set with only
what essentially sets -j17 in there since 2017 and I've never seen build
issues from it.

So, while theoretical, global MAKEFLAGS can cause issues with a poorly made
MAKEFILE, it seems they are extremely uncommon (if they exist at all).

NOTE: This is not to say we shouldn't have NUMJOBS in SlackBuilds (I don't
really have a preference), but just to say that setting -jXX in a global
MAKEFLAGS is unlikely to cause any issues in practice.

Here's the content of my /etc/profile.d/make-exports.sh. I have it do the
number of CPUs the kernel sees + 1 (this will include total threads, at
least on AMD systems).

export MAKEFLAGS="-j$(expr $(nproc) + 1)"

Jeremy

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.slackbuilds.org/pipermail/slackbuilds-users/attachments/20220404/a5192f22/attachment.htm>


More information about the SlackBuilds-users mailing list