Re: Re: Autodetect processing units with -j

wrotycz <[email protected]> Wed, 02 Jul 2025 00:03:34 +0200
Newsgroups gmane.comp.gnu.make.bugs
Message-ID <[email protected]>
See the last 5 paragraphs, starting with:   The MAKEFLAGS variable can also be useful if you want to have certain  options, such as ‘-k’ (see Summary of Options), set each time you run  make.    Tried to get what the `MAKEFLAGS&#39; is but documentation, not manual is not very helpful. Info is better. I read it and still didn&#39;t get that as it seemed somewhat complex if not convoluted.  So I made a Makefile and this variable is neither simple nor easy,   ~~~  $ cat &lt;&lt; EOF &gt; Makefile  all:  @echo MAKEFLAGS=$(MAKEFLAGS)  EOF   $ make -n -k -j  echo MAKEFLAGS=nkj  $ make -n -k -j CC=gcc  echo MAKEFLAGS=nkj -- CC=gcc  $ make -n -k -j3  echo MAKEFLAGS=nk --jobserver-fds=3,4 -j  ~~~    &gt; If one wants to add a default value because they know it will always  &gt; work with their system they can easily add this to their ~/.profile:  &gt;     export GNUMAKEFLAGS=&#34;$((2 * `nproc`))&#34;   Don&#39;t like it.  Why would one want to &#39;taint&#39; `.profile&#39; or any other such &#39;intimate&#39; file?   I would rather see it in ~/.config/gmake.conf or similar (name; in $XDG_CONFIG_HOME), where it was intended to control this particular program (here make), rather than pytting anything in `.profile&#39;.  And it would be much easier if it looked like this:  ~~~  echo -n -k -j3 &gt; ~/.config/gmake.conf  $ make  echo MAKEFLAGS=-n -k -j3  ~~~  where that would be prepended to command line resulting in control of &#39;default&#39; command line options and overwriting them with command line itself.   ~~~  echo -n -k -j3 &gt; ~/.config/gmake.conf  $ make -j4  echo MAKEFLAGS=-n -k -j4  ~~~   That&#39;s still just a prostethics for autodetect.    Speaking of autodetect, with big compilations, like compiler or binutils or similar, I don&#39;t use -j$(nproc), specially -j$((`nproc`*2)) as too many times it become unresponsive and without free thead couldn&#39;t even be tamed.  Since few slaps like that I use -j$((`nproc`-1)) even for a cost of slight slow down, as it&#39;s still less (cost/time) than rebooting system.  Still I use it only when expect to be long session, longer than few minutes, but that&#39;s OK - with rare cases like that I can spend two seconds typing more.    PS.  Make&#39;s git repo could be helpful - make a branch with the feature and let it to be tested. This way you can gather useful information from users and be prepared to easy merge in case it&#39;s accepted.