help-make
[Top][All Lists]
Advanced

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

Re: [Question] Set a variable while building a specific target


From: Paul Smith
Subject: Re: [Question] Set a variable while building a specific target
Date: Sat, 22 May 2021 14:12:35 -0400
User-agent: Evolution 3.36.4-0ubuntu1

On Sat, 2021-05-22 at 23:58 +0900, Masahiro Yamada wrote:
> On Sat, May 22, 2021 at 10:33 PM Paul Smith <psmith@gnu.org> wrote:
> 
> > On Sat, 2021-05-22 at 21:13 +0900, Masahiro Yamada wrote:
> > >   - 'make vmlinux modules' builds __common with
> > >      BUILDING_VMLINUX=y and BUILDING_MODULES=y
> > > I know the example above does not work like that.
> 
> I do not want to run the common part multiple times.
> I want to avoid race in parallel builds  (see below).

I see, I misread what you wanted as wanting to build __common once with
one variable set and again with the other variable set.  You want to
build once with both variables set.

Right, that cannot work because these settings are not "cumulative";
while make is building one goal and its prerequisites (including
__common) it will have the variable set for that goal.  Once that goal
is finished building and make starts on the next goal, it will no
longer have the first variable set but will have the other variable
set; either way, this time when it goes to build the __common
prerequisite it sees it's already built and doesn't need to build it
again.

There is no way to do what you want using target-specific variables.

I can't think of a better way to do it than what you're doing.  The
problem you have is that you are trying to use information that make
fundamentally does not have.

What you want to say is that, if make will walk both of the vmlinux or
modules nodes in the dependency graph, then when it walks the
prerequisites of the FIRST one it should set the variables for BOTH of
them.

But that's not how make works: make walks the graph one time and it has
no knowledge of what nodes it might or might not walk in the future.
 It's not like make generates a complete plan of what nodes it will
visit first, then visits them: it just starts with the first one and
keeps going until there are no more nodes to visit.

If there were a way to defer the build of the __common prerequisite
until the LAST time it was needed rather than the FIRST time it was
needed, you could try to accumulate the variables.  But of course, you
cannot do that: make always builds prerequisites the first time it sees
them; it cannot know whether the current use of a prerequisite is the
last one, or not.




reply via email to

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