question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bazel build is failing on gcc 11

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
davidocommented, Jan 26, 2021

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 by gRPC.

Related: abseil/abseil-cpp#887 and grpc/grpc#25114.

1reaction
koiuocommented, Jun 1, 2021

@IleanaAldama,

the path is hardcoded here, in the toolchain

https://github.com/bazelbuild/rules_cc/blob/608c7b605fb844a20e96a3eddc9b49ad2542adab/cc/private/toolchain/cc_toolchain_config.bzl#L1327

There’s --compiler option, but you can’t just specify gcc-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 and gcc) without defining a custom gcc-10 toolchain https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.html

Please 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

$ cd .cache/bazel
$ grep -r /usr/bin/gcc .
...
./install/129c3d389c2d09bb0ad5b4a301d67a9c/embedded_tools/tools/cpp/cc_toolchain_config.bzl:            tool_path(name = "gcc", path = "/usr/bin/gcc"),
...
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found