[comp.unix.internals] Arg list too big

smitty@essnj1.ESSNJAY.COM (Hibbard T. Smith JR) (03/13/91)

I've been trying to get the gnu project's Make (3.58) running on an Interactive
2.2 system.  It runs fine and offers many nice features.  Here comes the 
problem:

When trying to use it to control the build of the X11r4 distribution, I get an
error when do make depend in lib/X.  The command make builds looks like:

  ../.././util/makedepend/makedepend -s "# DO NOT DELETE #" -I../../. -I. -- *.c

This elicits an error message that looks like:

	sh: ../.././util/makedepend/makedepend: arg list too long

This same script and makefile work fine with regular ATT make.  There are
252 c files in the directory, and the makefile has done a cd into it, so the
file names are short and sweet.  No paths attached to each one.

This is being done with an execve call to exec the shell, and the envp points
to a fairly large environment.  The arguments are being passed with the "-c"
option to the shell.  The error appears to be coming from the shell, and 
happens with /bin/sh or bash.

I know that the exec system calls can only pass 5120 (10240) bytes.  This 
argument is only *.c when passed by the exec.  

Does the shell impose a limit on what can be passed by the"-c" option?

When is the *.c expanded?  Before or after it gets to the shell?  I thought
the shell did the expansion, in which case the argument list to the shell
is only *.c.

Does the original sh expand the argument and then pass the expande list to
a second shell because of the "-c" argument?

This has me very confused, and I'd appreciate any help I can get.

Reply by mail, or if there's enough interest, post to comp.unix.internals.

-- 
		Smitty
-------------------------------------------
Hibbard T. Smith JR                 smitty@essnj1.ESSNJAY.COM	
ESSNJAY Systems Inc.                uunet!hsi!essnj1!smitty

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (03/15/91)

In article <805@essnj1.ESSNJAY.COM>, smitty@essnj1.ESSNJAY.COM (Hibbard T. Smith JR) writes:
>   ../.././util/makedepend/makedepend -s "# DO NOT DELETE #" -I../../. -I. -- *.c

> 	sh: ../.././util/makedepend/makedepend: arg list too long

> I know that the exec system calls can only pass 5120 (10240) bytes.
> This argument is only *.c when passed by the exec.

The exec make does, yes.  On the other hand, when sh goes to exec
../.././util/makedepend/makedepend, it has to pass the whole list of
filenames to it.

> When is the *.c expanded?  Before or after it gets to the shell?  I
> thought the shell did the expansion, in which case the argument list
> to the shell is only *.c.

Right.  Make passes the whole line to sh.  sh then has to expand the
*.c and pass the result to makedepend.  I feel certain the complaint is
produced at this point.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

montnaro@spyder.crd.ge.com (Skip Montanaro) (03/19/91)

We had similar problems on SGIs and Stellars. The culprit in our case was
too much in the environment (the makefiles for our object-oriented
development system generate lots of make variable), not to many filenames. I
don't know if the 10240 byte limit applies to the sum of the filenames and
the environment, or to them separately, but in these days of multi-megabyte
systems, it seems ludicrous for it to be that small.

--
Skip (montanaro@crdgw1.ge.com)

torek@elf.ee.lbl.gov (Chris Torek) (03/20/91)

In article <MONTNARO.91Mar18210346@spyder.crd.ge.com>
montanaro@crdgw1.ge.com (Skip Montanaro) writes:
>I don't know if the 10240 byte limit applies to the sum of the filenames and
>the environment, or to them separately,

It applies to the sum.  Note that the 1024 pointers / 10240 bytes limit
was doubled (2048/20480) in 4.3BSD or 4.3tahoe, but is still wrong.

>but in these days of multi-megabyte systems, it seems ludicrous for it
>to be that small.

Indeed.  It *will* go away, at some point.  Just yesterday I had a little
friendly chat about the current kern_exec.c.... (`why are you carrying
that baseball bat?') :-)
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek@ee.lbl.gov