ninja link failure

31 views
Skip to first unread message

Erik Smith

unread,
May 23, 2023, 2:21:43 PM5/23/23
to gn-dev
This not really a GN question but I thought someone might have an idea.  Ninja reports FAILED on a link command but with no error.  When I run the same g++ link command directly, it works.  The line is about 250K characters in size, which is under ARG_MAX.  I have to imagine that chromium link commands can get at least as large. 

erik

Erik Smith

unread,
Jun 6, 2023, 4:13:24 PM6/6/23
to gn-dev, Erik Smith
Update: my link line is too long and exceeds MAX_ARG_STRLEN on linux, which 131072 on my system.  I dug through the ninja source to discover it passes your command inline to /bin/sh with the -c option.  I replicated this outside of ninja and sh reports the error " Argument list too long".  For some reason, ninja doesn't show this output from sh.   I also found a thread in the ninja project with more details.  I suspect chromium has an approach that avoids this problem.

K. Moon

unread,
Jun 6, 2023, 4:29:15 PM6/6/23
to Erik Smith, gn-dev
A lot of build tools take what's called a "response file" instead of passing everything on the command line, precisely for this reason. Ninja has support for this, and GN will use it under the right circumstances (https://gn.googlesource.com/gn/+/main/docs/reference.md#var_response_file_contents).

Erik Smith

unread,
Jun 6, 2023, 6:50:06 PM6/6/23
to gn-dev, km...@chromium.org, gn-dev, Erik Smith
The link for response_file for something similar in actions, but the rspfile and rspfile_contents in the link tool were trivial to implement.  Thanks!
Reply all
Reply to author
Forward
0 new messages