bazel: bazel build is failing on gcc 11
Trying 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)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (12 by maintainers)
Commits related to this issue
- Updating ABSL cpp library into new LTS version This change makes absl cpp library compatible with gcc 11 [1] in bazel compile. Related with : https://github.com/google/mediapipe/issues/1889 [1] :... — committed to onuralpszr/mediapipe by onuralpszr 3 years ago
- Bump grpc to 1.38.0 Fixes #12702. Also update transitive dependencies: o netty to 4.1.52 o netty-tcnative to 2.0.24 Change-Id: Iff6d300255b0c5a6732bb310ac99848ee75a45f6 — committed to davido/bazel by davido 3 years ago
- Fix building on gcc 11 Fixes #12702. Without this include the build is failing with: third_party/ijar/mapped_file_unix.cc: In constructor 'devtools_ijar::MappedOutputFile::MappedOutputFile(const ... — committed to davido/bazel by davido 3 years ago
- Bump grpc to 1.38.0 Fixes #12702. Also update transitive dependencies: o netty to 4.1.52 o netty-tcnative to 2.0.24 Change-Id: Iff6d300255b0c5a6732bb310ac99848ee75a45f6 — committed to davido/bazel by davido 3 years ago
- Bump grpc to 1.38.0 Fixes #12702. Also update transitive dependencies: o netty to 4.1.52 o netty-tcnative to 2.0.24 Change-Id: Iff6d300255b0c5a6732bb310ac99848ee75a45f6 — committed to davido/bazel by davido 3 years ago
- Fix thrid party compilation with gcc 11 or higher The [fix](https://github.com/bazelbuild/bazel/issues/12702) was available — committed to Koisell/rules_scala by Koisell 2 years ago
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
sorry if this is not the right place to ask, but is it a way to configure bazel to use an older gcc version? in my system I have gcc10 and gcc11 being the later the default one