bazel: incompatible_disable_nocopts: Disallow 'nocopts' attribute from cc_* rules
Flag: --incompatible_disable_nocopts
Available since: 0.28
Will be flipped: 1.0
The nocopts
attribute in cc_* rules is used to specify a pattern for filtering out flags from C++ compilation command line.
We are deprecating it because:
- it prevents migration of C++ rules to Starlark: we don’t have regex in Starlark currently
- we don’t need to do it - we can disable features to have the same effect
Migration
If you use the nocopts
attributes to filter out a flag please comment on this issue, with the offending flag/pattern that you’re filtering out.
As we have no way of knowing which flags users filter out, we will rely on them reaching out to us in case the flipping of the --incompatible_disable_nocopts
flag breaks their project. We will keep on support for filtering out the flags through --noincompatible_disable_nocopts
for 1-2 extra Bazel releases, until we are able to provide the support for disabling the reported flags through features.
If a user is filtering out a flag provided by bazel’s own C++ toolchain configuration, we will wrap the flag into a feature, so the user can disable the feature instead of filter out the flag. E.g a
cc_library(
name = "lib",
srcs = ["lib.cc", "lib.h"],
nocopts = "flagA",
)
would be migrated to
cc_library(
name = "lib",
srcs = ["lib.cc", "lib.h"],
features = ["-flag_a_feature"],
)
with flag_a_feature
being defined in bazel’s own C++ toolchain configuration.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (8 by maintainers)
Commits related to this issue
- Introduce --incompatible_disable_nocopts flag This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue #8706 RELNOTES: --incompatible_disable_nocopts flag has been added. See https:/... — committed to bazelbuild/bazel by scentini 5 years ago
- Introduce --incompatible_disable_nocopts flag This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue #8706 RELNOTES: --incompatible_disable_nocopts flag has been added. See https:/... — committed to siberex/bazel by scentini 5 years ago
- Release 0.28.0 (2019-07-10) Baseline: 2e374a9c6e3d4ed71f0145de287c4b2fe43c76d6 Cherry picks: + 6d0b14b95a71175362030b4811ca74512b00a890: rule_test: apply "tags" to all rules in the macro I... — committed to bazelbuild/bazel by a-googler 5 years ago
- Introduce --incompatible_disable_nocopts flag This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue #8706 RELNOTES: --incompatible_disable_nocopts flag has been added. See https:/... — committed to irengrig/bazel by scentini 5 years ago
- Release 0.28.0 (2019-07-10) Baseline: 2e374a9c6e3d4ed71f0145de287c4b2fe43c76d6 Cherry picks: + 6d0b14b95a71175362030b4811ca74512b00a890: rule_test: apply "tags" to all rules in the macro I... — committed to irengrig/bazel by a-googler 5 years ago
- Release 0.28.0 (2019-07-10) Baseline: 2e374a9c6e3d4ed71f0145de287c4b2fe43c76d6 Cherry picks: + 6d0b14b95a71175362030b4811ca74512b00a890: rule_test: apply "tags" to all rules in the macro I... — committed to bazelbuild/bazel by a-googler 5 years ago
- Remove nocopts attribute from cc_* rules from Tensorflow. This attribute will be removed soon: https://github.com/bazelbuild/bazel/issues/8706 The only nocopts values passed are "-fno-exceptions" and... — committed to tensorflow/tensorflow by tensorflower-gardener 5 years ago
- Introduce --incompatible_disable_nocopts flag This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue #8706 RELNOTES: --incompatible_disable_nocopts flag has been ad... — committed to luca-digrazia/DatasetCommitsDiffSearch by deleted user 2 years ago
- Remove nocopts attribute from cc_library.bzl Using this attribute was disabled, see #8706. It was added to the Starlark rule definition although it wasn't working. It is now moved to semantics while ... — committed to bazelbuild/bazel by oquenchil a year ago
- Remove nocopts attribute from cc_library.bzl Using this attribute was disabled, see #8706. It was added to the Starlark rule definition although it wasn't working. It is now moved to semantics while ... — committed to bazelbuild/bazel by oquenchil a year ago
- Remove `nocopts` from cc_nanopb_proto_library With Bazel 7.0.0, nocopts has been removed and is no longer supported. The correct way to handle this is to subtract features using the `features` attrib... — committed to armandomontanez/nanopb by armandomontanez 8 months ago
- Remove `nocopts` from cc_nanopb_proto_library With Bazel 7.0.0, nocopts has been removed and is no longer supported. The correct way to handle this is to subtract features using the `features` attrib... — committed to nanopb/nanopb by armandomontanez 8 months ago
maybe you should update https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary.nocopts
Do you use your own toolchain configuration? If so, you’ll need to create a feature that will pass the -Wno-declaration-after-statement to the command line, and use
features = ["-declaration_after_statement"]
in the targets that you’d like to not apply the flag to.That looks like it worked. That’s a much better solution than nocopts. Thanks!