bazel build is failing on gcc 11
See original GitHub issueTrying to build bazel on gcc 11:
$ bazel --version
bazel 4.0.0rc6
$ bazel build src:bazel-bin-dev
[...]
ERROR: /home/davido/projects/bazel/third_party/ijar/BUILD:47:11: Compiling third_party/ijar/zlib_client.cc failed: (Exit 1): gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 20 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 20 argument(s) skipped)
Use --sandbox_debug to see verbose messages from the sandbox
In file included from third_party/ijar/zlib_client.cc:20:
./third_party/ijar/zlib_client.h:64:46: error: 'numeric_limits' is not a member of 'std'
64 | static const size_t MAX_BUFFER_SIZE = std::numeric_limits<int32_t>::max();
| ^~~~~~~~~~~~~~
./third_party/ijar/zlib_client.h:64:68: error: expected primary-expression before '>' token
64 | static const size_t MAX_BUFFER_SIZE = std::numeric_limits<int32_t>::max();
| ^
./third_party/ijar/zlib_client.h:64:71: error: '::max' has not been declared; did you mean 'std::max'?
64 | static const size_t MAX_BUFFER_SIZE = std::numeric_limits<int32_t>::max();
| ^~~
| std::max
In file included from /usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/algorithm:62,
from third_party/ijar/zlib_client.cc:16:
/usr/lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/bits/stl_algo.h:3467:5: note: 'std::max' declared here
3467 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
Target //src:bazel-bin-dev failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.734s, Critical Path: 1.12s
INFO: 21 processes: 19 internal, 2 linux-sandbox.
FAILED: Build did NOT complete successfully
GCC version:
$ g++ --version
g++ (GCC) 11.0.0 20201204 (Red Hat 11.0.0-0)
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (12 by maintainers)
Top Results From Across the Web
Commands and Options | Bazel
This page covers the options that are available with various Bazel commands, such as bazel build , bazel run , and bazel test...
Read more >bazel-bootstrap: ftbfs with GCC-11 - Debian Bug report logs
The package fails to build in a test rebuild on at least amd64 with gcc-11/g++-11, but succeeds to build with gcc-10/g++-10.
Read more >c++ - undefined reference to 'std::filesystem' using Bazel build
Does how to use std::filesystem on gcc 8? answer your question? ... What is an undefined reference/unresolved external symbol error and how do...
Read more >Error when building bazel 0.2.3 from source - Google Groups
I'm trying to build a binary from source for bazel 0.2.3 on a Centos5 ... '//third_party/grpc:grpc_unsecure' failed: gcc failed: error executing command
Read more >error executing command /usr/bin/gcc u/bazel-out/k8 ... - Reddit
Bazel is telling you it won't render the error from GCC as it's too long. Look at the contents of the file path...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Because it was closed, I opened this issue: #12756.
Should we continue the discussion there?
If you install upcoming Fedora Rawhide 34, then GCC is 11 and Bazel is failing to build.
The issue is outdated
abseil
that is used bygRPC
.Related: abseil/abseil-cpp#887 and grpc/grpc#25114.
@IleanaAldama,
the path is hardcoded here, in the toolchain
There’s
--compiler
option, but you can’t just specifygcc-10.2.0
there https://docs.bazel.build/versions/master/user-manual.html#flag--compiler, it seems, it is just for selecting one version among versions already defined.All in all, I believe it is not possible to just override 2 paths values (for
cpp
andgcc
) without defining a customgcc-10
toolchain https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.htmlPlease share if you have something working before I do. Thanks!
// sorry for offtop folks, I’d be happy to move this discussion elsewhere, just let me know
UPDATE: what I ended up doing is simply hardcoding a different path for the cc toolchain in the bazel cache 🤦 It’s a hack, but at least it unblocks the build of my scala + gRPC project after hours of headbanging 😃
To locate the file to edit I simply grepped entire bazel cache by string
/usr/bin/gcc