Re: [bug #62706] Restrict second expansion to targets which are being built.

2022-07-05 Thread Dmitry Goncharov
On Tue, Jul 5, 2022 at 12:34 PM Edward Welbourne  wrote:
> was thinking of the fact that, if you'd started with
>
> all: $$(info 2nd expansion for all) hello.tsk bye.tsk; echo built both
>
> then its info would appear first, although its rule would be run last.

That's correct. $$(info 2nd expansion for all) is secondary expanded
before the prerequisites of hello.tsk and bye.tsk are secondary
expanded.

> I suppose that's unchanged by this patch, though,

Not changed.
This conversation made me realize that the description in the ticker
is not adequate. i'm going to update it. Thanks.

regards, Dmitry



Re: [bug #62706] Restrict second expansion to targets which are being built.

2022-07-05 Thread Edward Welbourne
On Tue, Jul 5, 2022 at 5:19 AM Edward Welbourne  wrote:
>>  I would have expected the order to be the exact reverse of the
>> order of building:

Dmitry Goncharov (5 July 2022 14:29) replied:
> i guess, an example will make it more clear.
>
> $ cat makefile
> .SECONDEXPANSION:
> all: hello.tsk bye.tsk
> hello.tsk: $$(info 2nd expansion of prereqs of $$@); $(info $@)
> bye.tsk: $$(info 2nd expansion of prereqs of $$@); $(info $@)

ah, right - between prerequisites at a given depth, second-expansion now
happens in the same order as execution of their rules, fair enough.  I
was thinking of the fact that, if you'd started with

all: $$(info 2nd expansion for all) hello.tsk bye.tsk; echo built both

then its info would appear first, although its rule would be run last.
I suppose that's unchanged by this patch, though,

Eddy.



Re: [bug #62706] Restrict second expansion to targets which are being built.

2022-07-05 Thread Dmitry Goncharov
On Tue, Jul 5, 2022 at 5:19 AM Edward Welbourne  wrote:
>  I would have expected the order to be the exact reverse of the
> order of building:

i guess, an example will make it more clear.

$ cat makefile
.SECONDEXPANSION:
all: hello.tsk bye.tsk
hello.tsk: $$(info 2nd expansion of prereqs of $$@); $(info $@)
bye.tsk: $$(info 2nd expansion of prereqs of $$@); $(info $@)
$ # this is patched make
$ ~/src/make/l64/make
2nd expansion of prereqs of hello.tsk
hello.tsk
2nd expansion of prereqs of bye.tsk
bye.tsk
make: Nothing to be done for 'all'.
$ # this is make-4.3
$ make
2nd expansion of prereqs of bye.tsk
2nd expansion of prereqs of hello.tsk
hello.tsk
bye.tsk
make: Nothing to be done for `all'.
$


You can see that make-4.3 builds 'hello.tsk' before building
'bye.tsk'. The order of secondary expanding prerequisites is the
opposite, first the prerequisites of 'bye.tsk' are expanded, then the
prerequisites of 'hello.tsk'.

The proposed behavior is to secondary expand the prerequisites of
'hello.tsk", build 'hello.tsk', secondary expand the prerequisites of
'bye.tsk', build 'bye.tsk'.

regards, Dmitry



Re: [bug #62706] Restrict second expansion to targets which are being built.

2022-07-05 Thread Edward Welbourne
Dmitry Goncharov (5 July 2022 01:42) wrote (inter alia):
> 2. Causes all prerequisites to be second expanded in the same order
> they are being built.

Really ?  I would have expected the order to be the exact reverse of the
order of building:

src = main.c
hdr = lib.h
prog: $$(src); $(CC) -o $@ $<
main.c: $$(hdr)

surely has to evaluate $$(src) to discover that prog depends on main.c,
and only after it's discovered that will it evaluate $$(hdr); but if
there were a rule to make main.c from lib.h that rule would be evaluated
before the rule for prog.

> This fixes byte order dependent order of second expanding
> prerequisites. See sv 62175.

That, at least, should be the case either way.

Eddy.