LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Argument list too long (https://www.linuxquestions.org/questions/linux-kernel-70/argument-list-too-long-922171/)

ekelly30 01-05-2012 04:33 AM

Argument list too long
 
I am having some issues when trying to run quite a long compile command from a makefile.
The command is within the bounds of ARG_MAX as defined in /usr/include/linux/limits.h and will run fine if I run the command in the terminal by itself, but when it is run from the makefile I get the error:

gcc/mipsel-linux-uclibc/4.4.5/cc1: execv: Argument list too long

I am using:
kernel: 2.6.9-34.ELsmp
make: GNU Make 3.81

Any idea of where to begin with solving this issue would be much appreciated.

gary185 01-05-2012 02:28 PM

this is the only thing i can think of --

is there a deep directory structure that is generating lots of long path designations?
if so can you flatten the directory structure to get rid of the long path names ?

Valery Reznic 01-06-2012 04:31 AM

Quote:

Originally Posted by ekelly30 (Post 4566685)
I am having some issues when trying to run quite a long compile command from a makefile.
The command is within the bounds of ARG_MAX as defined in /usr/include/linux/limits.h and will run fine if I run the command in the terminal by itself, but when it is run from the makefile I get the error:

gcc/mipsel-linux-uclibc/4.4.5/cc1: execv: Argument list too long

I am using:
kernel: 2.6.9-34.ELsmp
make: GNU Make 3.81

Any idea of where to begin with solving this issue would be much appreciated.

ARG_MAX limit not command's arguments length, but a sum of command's arguments length and all environment variables.

If you can to clear up unused environment variables may be it'll help.

ekelly30 01-06-2012 04:50 AM

I had thought of that also, but unfortunately it's part of a very large project and at the moment changing the file structure is not at all possible. Thank you anyway.

EDIT:
Valery, I only seen your response after I posted this one.
I called printenv to see the list of environment variables. Even after summing the length of this along with the length of the command, I am well within the bounds of ARG_MAX.

The command is 18563 characters. The environment variables 1002. Well within the 131072 bytes limit.

It is however significantly longer than most of the other commands in the project. I've noticed some duplicate arguments and I will see what I can do about removing these.


EDIT2:
I just had a thought, do makefiles temporarily store all of their variables as environment variables? As this could definitely push it over the limit if so.

gary185 01-06-2012 09:19 PM

i think you can up that 131072 to 524032

chdev -l sys0 -a ncargs=128


this should make ARG_MAX 128 * 4096

gary185 01-06-2012 09:27 PM

also if the make system is exporting messages that is uses as warnings or whatever as environmental variables.

ekelly30 01-09-2012 04:57 AM

Gary, I've done some research (http://www.in-ulm.de/~mascheck/various/argmax/) and it suggests the command you give is not a general linux command but for AIX.

I am apprehensive about making changes to the system if I can avoid it, as this is on a shared machine that is part of a very large project.

As for your last post, I am not sure what you mean.

Valery Reznic 01-09-2012 05:14 AM

Quote:

Originally Posted by ekelly30 (Post 4567777)
I had thought of that also, but unfortunately it's part of a very large project and at the moment changing the file structure is not at all possible. Thank you anyway.

EDIT:
Valery, I only seen your response after I posted this one.
I called printenv to see the list of environment variables. Even after summing the length of this along with the length of the command, I am well within the bounds of ARG_MAX.

The command is 18563 characters. The environment variables 1002. Well within the 131072 bytes limit.

It is however significantly longer than most of the other commands in the project. I've noticed some duplicate arguments and I will see what I can do about removing these.


EDIT2:
I just had a thought, do makefiles temporarily store all of their variables as environment variables? As this could definitely push it over the limit if so.

When make caller recursively, part of the information passed in environment variables. But makefile has target .EXPORT_ALL_VARIABLES then, well all makefile variables are exported as environment variables

ekelly30 01-09-2012 07:35 AM

Quote:

Originally Posted by Valery Reznic (Post 4570055)
When make caller recursively, part of the information passed in environment variables. But makefile has target .EXPORT_ALL_VARIABLES then, well all makefile variables are exported as environment variables

I do not believe that is used. But there are a large number of long variables, which are exported.

According to this link: http://www.in-ulm.de/~mascheck/various/argmax/
The maximum length of arguments is set to 1/4 of the stack size. I have tried the build on two different machines. One machine works, the other does not. They both appear to have the same stack size according to ulimit -s. However they have different ARG_MAX values according to getconf ARG_MAX. But according to the link above, this is a legacy value that is no longer used in this version of linux.

I am not sure which value to believe.

Valery Reznic 01-09-2012 08:12 AM

Quote:

Originally Posted by ekelly30 (Post 4570141)
I do not believe that is used. But there are a large number of long variables, which are exported.

According to this link: http://www.in-ulm.de/~mascheck/various/argmax/
The maximum length of arguments is set to 1/4 of the stack size. I have tried the build on two different machines. One machine works, the other does not. They both appear to have the same stack size according to ulimit -s. However they have different ARG_MAX values according to getconf ARG_MAX. But according to the link above, this is a legacy value that is no longer used in this version of linux.

I am not sure which value to believe.

And both of your machine have same kernel version? By the way, what kernel do you use?

ekelly30 01-09-2012 08:22 AM

On the successful machine:
2.6.32.26-175.fc12.i686.PAE

On the failing machine:
2.6.9-34.ELsmp

Does the 2.6.9 suggest that this is prior to the changes from ARG_MAX to 1/4 of the stack?

Valery Reznic 01-09-2012 10:46 AM

Quote:

Originally Posted by ekelly30 (Post 4570166)
On the successful machine:
2.6.32.26-175.fc12.i686.PAE

On the failing machine:
2.6.9-34.ELsmp

Does the 2.6.9 suggest that this is prior to the changes from ARG_MAX to 1/4 of the stack?

2.6.9 is very old kernel (IMO something about Fedora Core 3) I am pretty sure this kernel was released well before switch to 1/4 of stack for arg + env


All times are GMT -5. The time now is 04:32 AM.