Re: [kvm-unit-tests PATCH 2/2] powerpc/ppc64: Makefile cleanup

Andrew Jones
2016-05-10T09:21:48Z

On Tue, May 10, 2016 at 10:42:05AM +0200, Thomas Huth wrote:
> On 10.05.2016 09:44, Laurent Vivier wrote:
> >
> > On 10/05/2016 08:35, Andrew Jones wrote:
> >> On Tue, May 10, 2016 at 08:19:36AM +0200, Thomas Huth wrote:
> >>> On 09.05.2016 16:01, Andrew Jones wrote:
> >>>> This does the same cleanup as 'x86: Makefile refine'
> >>>>
> >>>> Signed-off-by: Andrew Jones <drjones@redhat.com>
> >>>> ---
> >>>> powerpc/Makefile.common | 13 ++++---------
> >>>> 1 file changed, 4 insertions(+), 9 deletions(-)
> >>>>
> >>>> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
> >>>> index 4449aec616853..60d545c98e38c 100644
> >>>> --- a/powerpc/Makefile.common
> >>>> +++ b/powerpc/Makefile.common
> >>>> @@ -22,6 +22,9 @@ CFLAGS += -I lib -I lib/libfdt
> >>>> CFLAGS += -Wa,-mregnames
> >>>> CFLAGS += -fpie
> >>>>
> >>>> +# We want to keep intermediate files: %.elf and %.o
> >>>> +.PRECIOUS: %.elf %.o
> >>>
> >>> If you just want to keep intermediate files, wouldn't it be better to
> >>> use .SECONDARY instead of .PRECIOUS? .PRECIOUS seems to contain some
> >>> more magic that comes into action when make is killed by a signal... not
> >>> sure if we want to have that here?
> >>
> >> I should extend the commit message to explain that. Wei Yang found
> >> (and I confirmed) that .SECONDARY doesn't seem to work[*] - we tried it,
> >> but the intermediate files still got removed. We both agree it would be
> >> the more appropriate choice though. Did you have better luck with it?
>
> I also only had a look at the info pages of make, to understand what
> PRECIOUS is doing (since I didn't know that command yet), and so I
> stumbled upon SECONDARY which sounded like a better match.
> But I now gave it a try, and it also does not work here.
> According to some comments on stackoverlow.com, SECONDARY does not work
> with patterns. This is also indirectly documented in the info page of
> make. For PRECIOUS, it says:
>
> "You can also list the target pattern of an implicit rule (such as
> `%.o') as a prerequisite file of the special target `.PRECIOUS' to
> preserve intermediate files created by rules whose target patterns
> match that file's name."
>
> But that paragraph is missing for SECONDARY, i.e. indicating that this
> does not work there.

Ah, yes. I agree with your interpretation of the [lack of] documentation
:-)

>
> > I don't understand why you want to keep intermediate files. If they have
> > to be kept, they should be primary targets.
> >
> > It seems for, at least ppc64, we don't need the .PRECIOUS.
>
> They could be useful for debugging purposes, e.g. for running "objdump"
> on them... ?
>
> Anyway, I think you can at least remove the "%.elf" from the PRECIOUS
> line, since the elf files are our primary target on powerpc and thus do
> not have to be listed here.

Indeed. I copy-pasted from the arm patch with my brain turned off.

I'll send a v2 of this series documenting in a comment the reason
PRECIOUS over SECONDARY was chosen, and drop elf from the ppc patch.

Thanks,
drew

>
> Thomas
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html