Repository navigation
Description
ATTENTION! Please read and follow:
- if this is a question about how to build / test / query / deploy using Bazel, or a discussion starter, send it to [email protected]
- if this is a bug or feature request, fill the form below as best as you can.
Description of the problem / feature request:
I got the error "gcc: error trying to exec '/usr/lib/gcc/x86_64-linux-gnu/7/collect2': execv: Argument list too long" when I run "bazel build ..."
The whole information:
$ bazel build --sandbox_debug ...
(22:29:30) INFO: Invocation ID: 81b9df42-6028-4650-9862-022a8db7bba3
(22:29:31) INFO: Current date is 2020-09-29
(22:29:34) INFO: Analyzed 17 targets (372 packages loaded, 27048 targets configured).
(22:29:34) INFO: Found 17 targets...
(22:29:37) ERROR: /root/dataset-process-service/BUILD:64:10: Linking of rule '//:server' failed (Exit 255) process-wrapper failed: error executing command
(cd /ramdisk/bazel-sandbox.fc533df1d383afd79dd50dcd563daad2b4e6fef6d029b079e883f99e3b3f6d89/processwrapper-sandbox/302/execroot/__main__ && \
exec env - \
LD_LIBRARY_PATH=/usr/local/cuda/lib64 \
PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
PWD=/proc/self/cwd \
TMPDIR=/tmp \
/root/.cache/bazel/_bazel_root/install/9284ab122d640dc4b037dd07fbb89f52/process-wrapper '--timeout=0' '--kill_delay=15' /usr/bin/gcc @bazel-out/k8-opt/bin/server-2.params)
gcc: error trying to exec '/usr/lib/gcc/x86_64-linux-gnu/7/collect2': execv: Argument list too long
(22:29:37) INFO: Elapsed time: 6.347s, Critical Path: 0.62s
(22:29:37) INFO: 0 processes.
(22:29:37) FAILED: Build did NOT complete successfully
I check the parameters file and the information is as follows:
$ ls -l bazel-out/k8-opt/bin/server-2.params
-r-xr-xr-x 1 root root 364875 Sep 29 20:59 bazel-out/k8-opt/bin/server-2.params
$ cat bazel-out/k8-opt/bin/server-2.params | wc -l
3465
Feature requests: what underlying problem are you trying to solve with this feature?
I do some research and I think it is related to the kernel parameters.
https://unix.stackexchange.com/questions/451486/how-to-cause-argument-list-too-long-error
https://www.in-ulm.de/~mascheck/various/argmax/
But I don't want to rebuild the kernel.
Can we change the gcc shell command to avoid this?
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I think when the "server-2.params" is large enough, it can be reproduced.
What operating system are you running Bazel on?
x86, ubuntu 18.04
What's the output of bazel info release?
$ bazel info release
(22:24:14) INFO: Invocation ID: fc7eb5d6-cc4d-4c6e-9a4e-32e3e1c46eb0
release 3.3.1
If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.
Replace this line with your answer.
What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?
Replace this line with your answer.
Have you found anything relevant by searching the web?
Replace these lines with your answer.
Places to look:
- StackOverflow: http://stackoverflow.com/questions/tagged/bazel
- GitHub issues: https://github.com/bazelbuild/bazel/issues
- email threads on https://groups.google.com/forum/#!forum/bazel-discuss
Any other information, logs, or outputs that you want to share?
Replace these lines with your answer.
If the files are large, upload as attachment or provide link.
Activity
benjaminp commentedon Sep 29, 2020
This is a GCC bug that was fixed in GCC 9.
oquenchil commentedon Oct 5, 2020
Thank you Benjamin.
ling2yt commentedon Oct 9, 2020
Sorry for the late response. I updated to gcc-9 and got the same error.
(00:31:48) INFO: From Compiling proto/dataset_migrator_service.pb.cc:
In file included from /usr/include/string.h:494,
from /usr/include/c++/9/cstring:42,
from external/com_google_protobuf/src/google/protobuf/io/coded_stream.h:118,
from bazel-out/k8-opt/bin/proto/dataset_migrator_service.pb.h:23,
from bazel-out/k8-opt/bin/proto/dataset_migrator_service.pb.cc:4:
In function 'void* memset(void*, int, size_t)',
inlined from 'void v1alpha2::services::MigrateRequest_ConfigureMigrator::SharedCtor()' at bazel-out/k8-opt/bin/proto/dataset_migrator_service.pb.cc:1440:11,
inlined from 'v1alpha2::services::MigrateRequest_ConfigureMigrator::MigrateRequest_ConfigureMigrator(google::protobuf::Arena*)' at bazel-out/k8-opt/bin/proto/dataset_migrator_service.pb.cc:1407:13,
inlined from 'v1alpha2::services::MigrateRequest_ConfigureMigrator::MigrateRequest_ConfigureMigrator()' at bazel-out/k8-opt/bin/proto/dataset_migrator_service.pb.h:844:87,
inlined from 'void InitDefaultsscc_info_MigrateRequest_ConfigureMigrator_proto_2fdataset_5fmigrator_5fservice_2eproto()' at bazel-out/k8-opt/bin/proto/dataset_migrator_service.pb.h:844:10:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: warning: 'void* _builtin_memset(void*, int, long unsigned int)' offset [45, 48] from the object at 'v1alpha2::services::MigrateRequest_ConfigureMigrator_default_instance' is out of the bounds of referenced subobject 'v1alpha2::services::MigrateRequest_ConfigureMigrator::type' with type 'int' at offset 40 [-Warray-bounds]
71 | return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(00:33:14) ERROR: /root/dataset-process-service/BUILD:64:10: Linking of rule '//:server' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc @bazel-out/k8-opt/bin/server-2.params
Use --sandbox_debug to see verbose messages from the sandbox
gcc: fatal error: cannot execute '/usr/lib/gcc/x86_64-linux-gnu/9/collect2': execv: Argument list too long
compilation terminated.
(00:33:14) INFO: Elapsed time: 461.389s, Critical Path: 37.70s
(00:33:14) INFO: 964 processes: 2 remote cache hit, 962 processwrapper-sandbox.
(00:33:14) FAILED: Build did NOT complete successfully
root@root:~/dataset-process-service# client_loop: send disconnect: Broken pipe
benjaminp commentedon Oct 12, 2020
To debug further, I think we'd need to know what makes the argument list so long or a reproducer.
ling2yt commentedon Oct 13, 2020
This is a converter service which needs to link many interface definition.
The internal interface we need links:
$cat bazel-out/k8-opt/bin/server-2.params | grep _idl | wc -l
673
The .o we need links: (the external -o is external.para.txt)
$cat bazel-out/k8-opt/bin/server-2.params | grep .o | wc -l
2773
And I don't know why there are so many duplicated "-pthread" at the end of the params file
$cat bazel-out/k8-opt/bin/server-2.params | grep "pthread" | wc -l
78
If our project needs to link so many .o, do you have any suggestion or document on how to improve it?
Thanks
benjaminp commentedon Oct 13, 2020
The question is it properly invoking collect2 with a param file, too?