A preliminary analysis of make: argument list too long

Source: Internet
Author: User

A colleague encountered a problem during loadmodule compilation.

Gmake: execvp:/bin/sh: argument list too long Gmake: *** [. O] Error 127

This situation has not been encountered before. It was only after Google that it was known that this was a limitation of OS Kernal.

In some operating systems, it is definedArg_max or ncargs is used to define the maximum length of parameters in OS.

When this problem occurs, we should pay attention to argv [] and envp [], that is, the parameters themselves and the environment variables. You can use env to view environment variables. If the Env length is too long, you can consider deleting unnecessary environment variables. In fact, you can use the following command to estimate the length of the process that can be used for argrment:

Expr 'getconf arg_max '-'env | WC-C'-'env | WC-L' \ * 4-2048

Among them, 2048 is the buffer recommended for POSIX to ensure that the process can safely modify the environment variable.

Because arg_max/ncargs is used as the kernel parameter, modification is not easy. At least you need the root permission...

For example, in Aix, run chdev-l sys0-A ncargs = newvalue to specify the new length.


This is a problem in IDE compilation. In fact, it may be a headache and not transparent during analysis. Later, I changed the command line compilation and OK (MAGIC, speechless ing)

You have not tried modifying kernel parameters. If you have time, please try ^_^.

PS:

if a problem occurs only in shell or our Program , you can split the parameter, or use xargs to pass Parameters.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.