help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: determining whether -jN was used


From: DSB
Subject: Re: determining whether -jN was used
Date: Fri, 24 May 2024 11:24:17 -0400

Thanks Paul, that's part way to the solution but I couldn't find a way to
make it work generically. The good news is that it's fixed internally for
4.4.1, the bad news is that finding a solution that translates to older
versions is hard at least for me. I was able to come up with a Linux-only
solution which is good enough for my use case. It's shown here in case
useful for anyone else:

# Determine whether a -j flag was used explicitly. Do not remove the space
in "-j ".
jval := $(filter -j%,$(subst -j ,-j,$(shell tr '\0' ' '
</proc/$$PPID/cmdline)))

I'm only interested in $(jval) as a boolean but it does seem to derive the
numeric value pretty reliably.

FWIW my use case is undoing old hacks which force -j in recursive use and
lead to "jobserver unavailable" and "jobserver reset" messages. Deriving -j
is needed for transitional compatibility.

David

On Thu, May 23, 2024 at 12:21 PM Paul Smith <psmith@gnu.org> wrote:

> On Thu, 2024-05-23 at 11:34 -0400, DSB wrote:
> > "To access the pipe you must parse the 'MAKEFLAGS' variable and look
> > for the argument string '--jobserver-auth=R,W'"
>
> I don't have time to test this right now but I think in 4.2 you have to
> look at the shell variable, not the makefile variable.
>
> E.g.
>
>    $(info $(shell echo $$MAKEFLAGS))
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]