-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constraint value @bazel_tools//tools/cpp:compiler:gcc
not true when using GCC compiler
#12707
Comments
@bazel_tools//tools/cpp:compiler:gcc
not true when using GCC compiler@bazel_tools//tools/cpp:compiler:gcc
not true when using GCC compiler
It is impossible to turn on the "//bazel/gcc_build" config setting, see: bazelbuild/bazel#12707 GCC 9, which is the default in Ubuntu 20.04, requires the -Wno-maybe-uninitialized for @com_googlesource_quiche//:quic_core_framer_lib to compile successfully. Mitigate by assuming the default "compiler" is GCC. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
It is impossible to turn on the "//bazel/gcc_build" config setting on Bazel 3.7.x, see: bazelbuild/bazel#12707 GCC 9, which is the default in Ubuntu 20.04, requires the -Wno-maybe-uninitialized for @com_googlesource_quiche//:quic_core_framer_lib to compile successfully. Mitigate by assuming the default "compiler" is GCC. Clang is properly recognized by Bazel, so it is not affected by this. Additional Description: See bazelbuild/bazel#12707 Risk Level: Medium, non-GCC compilers may not implement -Wno-maybe-uninitialized, and may start to fail if not recognized by Bazel. Testing: Tested compilations with both GCC and clang, and observed that -Wno-maybe-uninitialized is present with GCC but not with clang. Docs Changes: Release Notes: Fix compilation with GCC by assuming it is the default compiler. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
@oquenchil I have a (simple) fix for this bug, but am wondering about your thoughts on backwards compatibility here: If Envoy may break, but would certainly welcome the fix based on the discussion on that PR. Abseil would not break as they treat |
It is impossible to turn on the "//bazel/gcc_build" config setting on Bazel 3.7.x, see: bazelbuild/bazel#12707 GCC 9, which is the default in Ubuntu 20.04, requires the -Wno-maybe-uninitialized for @com_googlesource_quiche//:quic_core_framer_lib to compile successfully. Mitigate by assuming the default "compiler" is GCC. Clang is properly recognized by Bazel, so it is not affected by this. Additional Description: See bazelbuild/bazel#12707 Risk Level: Medium, non-GCC compilers may not implement -Wno-maybe-uninitialized, and may start to fail if not recognized by Bazel. Testing: Tested compilations with both GCC and clang, and observed that -Wno-maybe-uninitialized is present with GCC but not with clang. Docs Changes: Release Notes: Fix compilation with GCC by assuming it is the default compiler. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
@fmeum , can you describe what your simple fix is? Is there a way to simply tell bazel which compiler to use? |
@aaron-michaux If you just want to have Bazel use a particular compiler, add The fix I was talking about above was for getting GCC recognized by Bazel as @oquenchil Friendly ping, do you think reporting GCC as |
… to "gcc", instead of just detecting Bazel's default "compiler" string. When Bazel auto-configures GCC, it sets the compiler string to "compiler", probably for backwards compatibility. Some users manually set the string to "gcc". This should address the backwards compatibility issues described in bazelbuild/bazel#12707 and hopefully fix #1263 PiperOrigin-RevId: 473069817 Change-Id: I8a24721f63f9d61447b22b3b05b06a9dde7d34d8
No. I think it's fine. This would be a bug fix. Ideally the change would be checked in together with a script that runs buildozer (or some regex) over a project and fixes the places that need fixing. But if that's not possible then properly describing how it can break and what the instructions for fixing it are should be enough. |
This makes it possible to detect gcc specifically via a `config_setting` for the `@bazel_tools//tools/cpp:compiler` flag with value `gcc`. RELNOTES: The `@bazel_tools//tools/cpp:compiler` flag now has the value `gcc` if the configured compiler is detected to be gcc rather than the generic value `compiler`. A branch for `gcc` may have to be added to `select` statements that do not have a default case that handles gcc appropriately. Fixes bazelbuild#12707 Closes bazelbuild#16297. PiperOrigin-RevId: 475467838 Change-Id: I9fa98ddd3c7f29742357596280dfc98c939f0253
Note: This isn't fully fixed: #17794 |
… to "gcc", instead of just detecting Bazel's default "compiler" string. When Bazel auto-configures GCC, it sets the compiler string to "compiler", probably for backwards compatibility. Some users manually set the string to "gcc". This should address the backwards compatibility issues described in bazelbuild/bazel#12707 and hopefully fix abseil#1263 PiperOrigin-RevId: 473069817 Change-Id: I8a24721f63f9d61447b22b3b05b06a9dde7d34d8
It is impossible to turn on the "//bazel/gcc_build" config setting, see: bazelbuild/bazel#12707 GCC 9, which is the default in Ubuntu 20.04, requires the -Wno-maybe-uninitialized for @com_googlesource_quiche//:quic_core_framer_lib to compile successfully. Mitigate by assuming the default "compiler" is GCC. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Description of the problem:
The constraint value
@bazel_tools//tools/cpp:compiler:gcc
is not detected/enabled correctly when the GCC compiler is used and can not be targeted with aconfig_setting
.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
The following Bazel repo demonstrates the issue. It has a dummy target that is intended to be compiled with different
copts
, depending on the compiler. We useconfig_setting
s which match on the@bazel_tools//tools/cpp:compiler
flag andselect
on them later.WORKSPACE:
BUILD:
empty.cc
The system has both gcc and clang installed and available in $PATH:
Now try to compile the dummy target.
With no
$CC
/$CXX
set, we expect the build to fail with the-fail_gcc
message, as GCC is the default. Bazel found and usedgcc
as seen in the error, but with the wrong flags (unrecognized command line option '-fail_compiler'
):Snippet from
<bazel cache dir>/external/local_config_cc/BUILD
:With
$CC=clang
/$CXX=clang++
, the build fails as expected:clang: error: unknown argument: '-fail_llvm'
And the local config seems correct, too:
Setting
$CC=gcc
/$CXX=g++
does not help, same error as above:gcc: error: unrecognized command line option '-fail_compiler'
What operating system are you running Bazel on?
20.04.1 LTS (Focal Fossa)
Linux 5.4.0-53-generic #59-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
What's the output of
bazel info release
?release 3.7.1
Have you found anything relevant by searching the web?
Abseil uses the same technique to detect the compiler, but uses the default condition for GCC:
The text was updated successfully, but these errors were encountered: