Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins/Makefile: use files to avoid hitting ARG_MAX during build #775

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MatthewCroughan
Copy link

When adding more modules to the build, ar will be passed far more .o files as arguments on the command line than the limits specified by most host kernels by default, which will cause the build to fail with /bin/bash: Argument list too long

Using xargs can show you what these limits are on POSIX systems, e.g:

$ xargs --show-limits
Your environment variables take up 6774 bytes
POSIX upper limit on argument length (this system): 2088330
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2081556
Size of command buffer we are actually using: 131072
Maximum parallelism (--max-procs must be no greater): 2147483647

When adding more modules to the build, ar will be passed far more .o files as
arguments on the command line than the limits specified by most host kernels by
default, which will cause the build to fail with "/bin/bash: Argument list too long"

Using xargs can show you what these limits are on POSIX
systems, e.g:

$ xargs --show-limits
Your environment variables take up 6774 bytes
POSIX upper limit on argument length (this system): 2088330
POSIX smallest allowable upper limit on argument length (all systems): 4096
Maximum length of command we could actually use: 2081556
Size of command buffer we are actually using: 131072
Maximum parallelism (--max-procs must be no greater): 2147483647
@falkTX
Copy link
Contributor

falkTX commented Dec 17, 2024

are you actually hitting this limit?

I dont understand what you are trying to do with the "file > " syntax

@MatthewCroughan
Copy link
Author

Yeah, if you just add a few more submodules and compile a headless build, it will result in a string length far too large to work, ultimately throwing that bash error, due to the max argument size in the host kernel.

I dont understand what you are trying to do with the "file > " syntax

The file syntax thing confused me as well, but it's a feature of Make that I discovered in fixing this https://www.gnu.org/software/make/manual/html_node/File-Function.html

All we're doing is putting PLUGIN_OBJS, into a file, so that ar crs can read it from this file (something it supports), instead of trying to pass a 2MB~ string to the ar command via bash, which runs into these limits.

@multivac61
Copy link

It fails on mac due to inconsistencies between the GNU and BSD versions of make and ar (binutils). I can confirm when using GNU versions, this PR builds on my local mac machine.

@falkTX
Copy link
Contributor

falkTX commented Dec 18, 2024

we cant assume the GNU version. Cardinal builds on BSD too which has the same situation

@MatthewCroughan
Copy link
Author

Does that mean that BSD ar and make cannot read lists of args from files? If so, I don't see how this is going to be resolved on those platforms

@MatthewCroughan
Copy link
Author

We should be able to use cat | xargs | ar but first PLUGIN_OBJS needs to get into a file, which is the thing that Make on BSD doesn't support

@MatthewCroughan
Copy link
Author

@falkTX I dare not ask what happens on Haiku. Where is your Haiku CI? :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants