bug-make
[Top][All Lists]
Advanced

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

Re: Order of expansion of recipe lines


From: Paul Smith
Subject: Re: Order of expansion of recipe lines
Date: Mon, 14 Mar 2016 15:30:50 -0400

On Mon, 2016-03-14 at 11:55 -0700, Zoltan wrote:
> > I was looking through the parsing code a week ago.  As of 4.1 it treats ${ 
> > and
> > $( as meaning exactly the same thing.  In our build we use the convention 
> > $()
> > for macro calls and ${} for variable expansions, but the opposite could be
> > true (or no convention) in other builds.
> 
> Understood...but there's no behavioral "acrobatics" required here.  Regardless
> of whether '$$(' or '$${' references a function or a variable (aka macro), the
> currently documented behavior with .SECONDEXPANSION turned on is to convert
> the $$ into $ to delay the expansion until execution time. The "hole" in the
> implementation apparently is that this does not apply to recipe lines, and
> until this current proposal, it has never had to.

I think this is not the right way to look at it.  SECONDEXPANSION
delays escaped prerequisite content so that they are expanded when the
recipe is about to be run, instead of when the makefile is read in.

The behavior I'm talking about already happens only when the recipe is
about to run, so it's not the same thing.

Plus we were able to get away with adding SECONDEXPANSION because
prerequisites containing the literal character '$' are very rare (at
least on UNIX and Windows) so preexisting makefiles that used '$$' in
the prerequisites list and had to change to '$$$$' were rare, and you
had to enable a new feature (SECONDEXPANSION) to get the new behavior
anyway.

However, _recipes_ that use literal '$' characters (and hence right now
use '$$') are everywhere, in almost every makefile ever created, and
many makefiles already enable SECONDEXPANSION.  SECONDEXPANSION doesn't
apply on a per-target basis: once enabled it's enabled for the entire
rest of the makefile (and all included makefiles).

In the shell '$foo' is a variable reference (must be written '$$foo' in
a recipe), '${foo}' is also a variable reference (must be written
'$${foo}' in a recipe), and $(foo) is a command replacement (new way of
writing backticks: `foo`) and must be written '$$(foo)' in a recipe.

All of these are VERY common and would have to be changed to '$$$$foo',
'$$$${foo}', and '$$$$(foo)' if SECONDEXPANSION was enabled.

I can hardly begin to imagine the havoc such a change would create :).

And, I don't think this change warrants some brand new token be
introduced to choose between the two behaviors.  Either it's fine to
have only the new behavior and not need the old behavior at all, or
else we shouldn't make the change.



reply via email to

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