[Top][All Lists]

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

Re: GNU enhancement -- $(xargs cmd, list)

From: Reid Madsen
Subject: Re: GNU enhancement -- $(xargs cmd, list)
Date: Mon, 6 Nov 2000 19:42:10 -0600 (CST)

 > Date: 6 Nov 2000 16:56:30 -0600
 > From: Reid Madsen <address@hidden>
 > I also thought about using the _POSIX_ARG_MAX and ARG_MAX symbols to 
 > determine
 > when the xargs approach was really needed.  If the command line is within
 > limits, then
 >         $(xargs cmd, list)
 > would expand to:
 >         cmd list
 > Do you believe this is doable/portable?
 > Reid
 > FYI, a quick perusal of our systems shows:
 >         POSIX_ARG_MAX   ARG_MAX
 >         -------------   -------
 > Solaris         4096    1MB
 > HP              4096    2MB
 > AIX             4096    24576   Pathetic!
 > OSF             4096    38912   Pathetic!
 > NT              4096    14500   Pathetic ** 2 !
 > Gotta love those 2-4 byte per arg limits on AIX, OSF, and NT.

After experimenting with this on Solaris for about 3 hours, I've come to the
conclusion that this is way to complicated.  The 'exec' man page states that
the error E2BIG is returned when the sum of the command length and environment
length exceeds ARG_MAX.  So, armed with that information I when out and
created a Makefile with enough big arguments to push it right up to the edge.
Adding a single character would case make to fail with:

        make: execvp: num_args: Arg list too long

However the 'edge' was nowhere close to the size of the command line +
environment.  It's off by about 100K.  Yuck!

So, instead, I've decided that in addtion to the $(XARGS) variable that
GNUmake should also define a $(XARGS_LEN) variable.  Which will be used to
measure the length of the command line.  When less the $(XARGS_LEN), then a
normal command is launched, otherwise xargs is launched as"

        xargs -s $(XARGS_LEN) cmd << tmpfile

In our build process, based on IMAKE, we can set XARGS_LEN differently for the
different platforms we build on.  IMO, this is probably the most flexible.

If you have a better idea, I'd be glad to hear it.


Reid Madsen                             address@hidden                      
Senior Member, Tech. Staff              (972) 536-3261 (Desk)
I2 Technologies                         (214) 850-9613 (Cellular)
Making incrementally (without 'clean') since May 18, 2000.
Long live incremental make!

reply via email to

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