Re: Very long SRCS list with unusually long src/ prefix

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Thu, 05 Feb 2004 07:54:06 -0700 (MST)
In message: <20040206012805.N8113_at_gamplex.bde.org>
            Bruce Evans <bde_at_zeta.org.au> writes:
: This seems to run echo once for each file separately.  It should be deemed
: inefficient :-).

When Timing Solutions hit the problem, we tried a lot of different
things and found that this was the only one that would actually work.
We tried a whole lot of different ways to do this, and all of them
were found wanting.  The hard part was getting things passed to the
shell in small enough chunks to be useful.  If something better can be
done, I'd love to hear it.

: I can't see anything better using current make features.  The make -V hack
: doesn't work with local variables.

True.  We hit that right away.  That was one of the clever hacks that
we thought about.

: This and some other things would be easier and more efficient if make
: had a builtin echo.  Then we could just use "builtin_echo ${.ALLSRC:M*.[cS]}
: | mkdep ..." in the rules below, and the make -V hack would not be needed
: in kern.post.mk.

That would be cool.  We'd tried to come up with a patch that didn't
require hacks to make.  One could also have a builtin xargs as well
that would someway deal with dicing and slicing things up into the
right-sized chunks.  We discussed adding calls to realpath, which in
our case would have shortened the strings just enough to make it work
w/o xargs, but that was also rejected because each additional
character of the base path length added like 500 characters to the
libc mkdep command line.

We also thought about just raising the limit in the kernel, but
quickly discovered that they were small to make exec more efficient.

: %  ${DEPENDFILE}: ${DPSRCS}
: %  	rm -f ${DEPENDFILE}
: %  .if !empty(DPSRCS:M*.[cS])
: % -	${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
: % -	    ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*} \
: % -	    ${.ALLSRC:M*.[cS]}
: % +	(cd ${.CURDIR}; ${MAKE} _mkdep_cS) | xargs env \
: % +	    ${MKDEPCMD} -f ${DEPENDFILE} -a ${MKDEP} \
: % +	    ${CFLAGS:M-nostdinc*} ${CFLAGS:M-[BID]*}
: 
: make uses a real shell, so the env shouldn't be needed.

The problem is that the expansion of MKDEPCMD.  It may expand to
"FOO=bar mkdepcmd" so the xargs doesn't do the right thing; It tries
to exec FOO=bar.  The env is needed so that it will properly expand
things in that case.  We hit this early in our attempts at Timing
Solutions to come up with a good fix lead to tossing an 'env' in
there.

Warner
Received on Thu Feb 05 2004 - 05:54:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:41 UTC