[bug#60535] [PATCH] depend2: switch echo|sed to automatic vars

Mike Frysinger <[email protected]> Wed, 11 Jan 2023 22:36:53 -0500
Newsgroups gmane.comp.sysutils.automake.patches
Message-ID <Y7+AVbcSZVZoNudU@vapier>
On 05 Jan 2023 16:47, Karl Berry wrote:
> Please excuse my curmudgeonness, but it's not clear to me that avoiding
> sed is worth these hassles in working around the implementation-specific
> bugs in the automatic variables. Especially if we have to invoke a shell
> and various commands anyway, how about keeping things as they are? -k

i don't quite buy the argument of "we've got a lot of per-object overhead,
so what's a little bit more".  we should be trying to minimize overhead of
generated code as much as possible.  forking a subshell to fork sed just to
munge a string that we can have make itself generate is pure overhead.

but you're appealing to avoiding hassle.  to that end, i'll point out the
current depdir logic is already in an unhealthy state: we're generating
similar logic 3 times with automake-processed conditionals depending on 3
runtime settings:
?!GENERIC?              %VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
?!GENERIC?              %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
?GENERIC??!SUBDIROBJ?   %VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE%
?GENERIC??!SUBDIROBJ?   %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
?GENERIC??SUBDIROBJ?    %VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
?GENERIC??SUBDIROBJ?    %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE% &&\
?GENERIC??SUBDIROBJ?    $(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po

this directly translates to overhead in the generated Makefile.in:
.c.o:
@am__fastdepCC_TRUE@                $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@                $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@                $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@   $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@               $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<

switching to make variables will allow us to collapse these.  i'm fairly
confident i can at least collapse the last 5 lines ?GENERIC? into 2 lines.
-mike
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmO/gFAACgkQQWM7n+g3
9YFfCg//QPSbrfaNkDMUEMW6ggzKb6Eaaet0h1MfmTqR51o3/tBSNK+dDyICSWNE
d+laLGBSQq0KUikaB9kGypl65Ju68MNQbyYiX2tVgYGBKBbldZWGcqqUqkaplaxL
u4BSLmSnTONU3HOaWRmz6UpGxDcCxqZ0gD/VA5ZuN09GM8pRgbG7/qK5jqERBA/v
HDakCvQyF6/jSdPYkFZ1KsBSZ6wFwrtKyv3stwX1hstWfHoFxclFE7j0IQcCO17U
R03v2tfcCBvfNs7pVaCb2EFLEQC1nphc3vvhDwXMxRi8zVTbd1EQ6BGmvPvtmFAM
SG4QrIWu62XhHQXdK7beMH6fX39BfW9tHkBcVhCQyzK+seshwg3DaG27QLxUjKLK
CLp8e481cVhbQnQZuzSryIBfdI+JiTuSLokqCoQ4Eq6gVZO7t+BvJ6NKWHqAI+li
p2GBsrXi/SdplxijNS/gq7GTjBOfDhEa+radTItavYq2UY0v0qcx09Si6hYAlmWZ
f36p5MULU3Z9CVtuJ53x84TsmkYTkCToCSNH9s2b8WhIPcIOJ6Hy7turG8466duG
2ve0ZsA/XNAY8r0JTvubvGGOX2uKi9w+y2ScBT8j9KqQCjXLK5vSilPwWvD2ioMZ
pqfLx2KO7sgLNw6pgcsM+LHTefsvUhKb7AqMKHzkLtaFRzqxIZg=
=bZRe
-----END PGP SIGNATURE-----