-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
FR: Add option to disable warnings from external C++ headers #12009
Comments
Tagging @hicksjoseph |
How do you identify which code is first-party and which is third-party? |
I'm not sure who @ulfjack 's question is intended for, but I'll say that any dep that bazel thinks is an external dep should likely be considered third-party. |
Any update on this? |
@ulfjack would Greg's suggestion work? Make anything starting with external be included as /external? Would that mean flattening the headers nested set in analysis? Regarding when to tackle this Greg, it would help a lot if you can provide a Windows repro. Also if you could try out replacing /I with /external yourself to verify that that it would work, I could take it from there and check it in the change. |
I think the proposal makes sense. I'm not sure how it would be implemented though. We did something like this in google3, but I'm not sure how it currently works. |
google3 basically says
I agree with @devjgm that external deps are a good start as to what should be considered third party, though I guess it would also be nice if we could control that in some way. |
Would you take a PR that makes headers of external libraries referenced using -isystem instead of -I? |
Projects with strict warnings level experience issues when they depend on third party libraries with less-strict warnings: The compiler will emit warnings for external sources. See bazelbuild#12009 for more. This change optionally silences those warnings, by changing -I flags to -isystem flags and by adding -isystem flags for each -iquote flag, in case of external dependencies, i.e: those targets that come from a non-main workspace. The new behavior can be enabled by --features=external_include_paths, otherwise there's no functional change. The default flag_group in unix_cc_toolchain_config will silence warnings coming from -I and -iquote dirs in case of GCC, and -I for Clang. Clang will still produce warnings for -iquote dirs, therefore the Clang specific --system-header-prefix is recommended instead.
Projects with strict warnings level experience issues when they depend on third party libraries with less-strict warnings: The compiler will emit warnings for external sources. See bazelbuild#12009 for more. This change optionally silences those warnings, by changing -I flags to -isystem flags and by adding -isystem flags for each -iquote flag, in case of external dependencies, i.e: those targets that come from a non-main workspace. The new behavior can be enabled by --features=external_include_paths, otherwise there's no functional change. The default flag_group in unix_cc_toolchain_config will silence warnings coming from -I and -iquote dirs in case of GCC, and -I for Clang. Clang will still produce warnings for -iquote dirs, therefore the Clang specific --system-header-prefix is recommended instead.
Projects with strict warnings level experience issues when they depend on third party libraries with less-strict warnings: The compiler will emit warnings for external sources. See #12009 for more. This change optionally silences those warnings, by changing -I flags to -isystem flags and by adding -isystem flags for each -iquote flag, in case of external dependencies, i.e: those targets that come from a non-main workspace. The new behavior can be enabled by --features=external_include_paths, otherwise there's no functional change. The default flag_group in unix_cc_toolchain_config will silence warnings coming from -I and -iquote dirs in case of GCC, and -I for Clang. Clang will still produce warnings for -iquote dirs, therefore the Clang specific --system-header-prefix is recommended instead. Closes #13107. PiperOrigin-RevId: 366220384
Should this be closed now that 08936ae landed? |
Confirming that adding the following to
|
i am using -Wconditional-uninitialized flag and then i am getting some errrors from the library. external/com_google_protobuf/src/google/protobuf/arena.cc:398:12: error: variable 'arena' may be uninitialized when used here [-Werror,-Wconditional-uninitialized] i want to filter out this error since it is coming from the library and i am using Bazel 5.0 and feature : build --features=external_include_paths but still i am seeing the above error from the library. Could you please help me on this? |
external/com_google_protobuf/src/google/protobuf/arena.cc:398:12: error: variable 'arena' may be uninitialized when used here [-Werror,-Wconditional-uninitialized] i want to filter out this error since it is coming from the library and i am using Bazel 5.0 and feature : build --features=external_include_paths but still i am seeing the above error from the library. Could you please help me on this? |
Hi bazel team I use an aspect to run clangtidy on the codebase. It is based on https://github.com/erenon/bazel_clang_tidy. To check my codebase with `-Werror`, I use the "new" feature `external_include_path` requested by #12009, introduced by commit 08936ae. Now my clangtidy rules did not work anymore of course. As you can see in https://github.com/erenon/bazel_clang_tidy/blob/master/clang_tidy/clang_tidy.bzl, all the different include paths are being passed to the clang-tidy executable. I now also needed to pass the new external_includes to `clang-tidy`. This PR adds `external_includes` to the `compilation_context` object. I looked at the style of the other `includes` and hope it is in line with your expectations. Closes #18094. PiperOrigin-RevId: 548070112 Change-Id: I212420d2f888c3af088c4afbf8202c848d19722e
Does external_include_paths only cover what's specified in I have multiple external repos in my |
Mirrors this upstream feature bazelbuild/bazel#12009
Mirrors this upstream feature bazelbuild/bazel#12009
I work on https://github.com/googleapis/google-cloud-cpp and we use CMake and bazel. Our project has several external dependencies defined in our WORKSPACE file. This is all working, but we'd like to be able to compile our own code with a high-level of compiler warnings, like
-Wconversion
, and we don't want to be bothered by errors in our external dependencies (because we cannot fix those errors).In our CMake builds, our deps get "installed", and we include them with angle-brackets and they're found by some
-isystem dir
flags. This works fine with CMake.However, this doesn't work with Bazel, because bazel encourages all code to be compiled with the same flags, so there's no distinction between my project's code and the code of our external dependencies. The issue is that if I want to compile with
-Wconversion
, I'll be warned about all my deps' problems that I cannot fix.WANT: I'd like bazel to provide some supported mechanism to let users compile their own code different warnings flags than their dependencies.
Can bazel already do this? If so, what's the right way to disable warnings from external deps with Bazel?
We have some ideas that seem to work (maybe) that rely on the
includes = [ "." ]
attribute. We think this might be working, but it also seems like maybe the wrong thing. Is there some other recommended good solution that we should be considering?The text was updated successfully, but these errors were encountered: