-
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
incompatible_disable_nocopts: Disallow 'nocopts' attribute from cc_* rules #8706
Comments
This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue bazelbuild#8706 RELNOTES: --incompatible_disable_nocopts flag has been added. See bazelbuild#8706 for details. PiperOrigin-RevId: 254781400
Baseline: 2e374a9 Cherry picks: + 6d0b14b: rule_test: apply "tags" to all rules in the macro Incompatible changes: - Add --incompatible_enable_profile_by_default to enable the JSON profile by default. - The --incompatible_windows_style_arg_escaping flag is flipped to "true", and the "false" case unsupported. Bazel no longer accepts this flag. Important changes: - Bazel now supports hiding compiler warnings for targets that you're not explicitly building (see https://docs.bazel.build/versions/master/user-manual.html#flag--au to_output_filter). - Flag `--incompatible_restrict_escape_sequences` is added. See #8380 - The "info" command now supports the "starlark-semantics" argument, which outputs a representation of the effective Starlark semantics option values. - The `outputs` parameter of the `rule()` function is deprecated and attached to flag `--incompatible_no_rule_outputs_param`. Migrate rules to use `OutputGroupInfo` or `attr.output` instead. See #7977 for more info. - When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. - Turn on --experimental_build_setting_api by default for starlark build settings (see https://docs.bazel.build/versions/master/skylark/config.html#user- defined-build-settings for more info) - `@bazel_tools//tools/jdk:toolchain_java10` and `@bazel_tools//tools/jdk:toolchain_java11` are now available to enable java 10, respectively java 11 language level support. - The `command` parameter of the `actions.run_shell()` function will be restricted to only accept strings (and not string sequences). This check is attached to flag `--incompatible_run_shell_command_string`. One may migrate by using the `arguments` parameter of `actions.run()` instead. See #5903 for more info. - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See #8622 for details. - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See #8622 f... - Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS` environment variable to specify system libraries that should be appended to the link command line. - paths under the execution root starting with "." or "_" will be re-linked across builds - execution_log_json_file now allows actions without outputs. - Labels aapt as deprecated for aapt_version, and heavily endorses aapt2. - Update doc links still pointing to cc_binary.features to point to common features - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See #8622 for details. RELNOTES: - --incompatible_disable_nocopts flag has been added. See #8706 for details. - Fixed treatment of <dist:module /> tags in AndroidManifest.xml - Fixed asset precedence for android_binary rules with aapt2. - Bazel now officially supports running on CentOS 7. - The runtime dynamic libraries are no longer in default output group of cc_binary. - set the FDOBuildType as CSFDO for binaries built with --cs_fdo_absolute_path. - Bazel can now be bootstrapped and built on arm64 platforms without requiring any flags or patches. - Fixed treatment of AndroidManifest.xml attributes which contained XML escaping - Retire experimental blaze flag experimental_link_compile_output_separately. The same behavior is available through the feature dynamic_link_test_srcs. - --incompatible_load_java_rules_from_bzl was added to forbid loading the native java rules directly. See more on tracking issue #8746 - Turn on --experimental_build_setting_api by default for starlark build settings (see https://docs.bazel.build/versions/master/skylark/config.html#user- defined-build-settings for more info) - Attribute names are going to be restricted and must be syntactically valid identifiers. #6437 - rule_test: fix Bazel 0.27 regression ("tags" attribute was ingored, #8723 This release contains contributions from many people at Google, as well as Ben Diuguid, Benjamin Peterson, Dave Lee, Loo Rong Jie, Mark Butcher, Marwan Tammam, Pedro Alvarez.
This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue bazelbuild#8706 RELNOTES: --incompatible_disable_nocopts flag has been added. See bazelbuild#8706 for details. PiperOrigin-RevId: 254781400
Baseline: 2e374a9 Cherry picks: + 6d0b14b: rule_test: apply "tags" to all rules in the macro Incompatible changes: - Add --incompatible_enable_profile_by_default to enable the JSON profile by default. - The --incompatible_windows_style_arg_escaping flag is flipped to "true", and the "false" case unsupported. Bazel no longer accepts this flag. Important changes: - Bazel now supports hiding compiler warnings for targets that you're not explicitly building (see https://docs.bazel.build/versions/master/user-manual.html#flag--au to_output_filter). - Flag `--incompatible_restrict_escape_sequences` is added. See bazelbuild#8380 - The "info" command now supports the "starlark-semantics" argument, which outputs a representation of the effective Starlark semantics option values. - The `outputs` parameter of the `rule()` function is deprecated and attached to flag `--incompatible_no_rule_outputs_param`. Migrate rules to use `OutputGroupInfo` or `attr.output` instead. See bazelbuild#7977 for more info. - When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. - Turn on --experimental_build_setting_api by default for starlark build settings (see https://docs.bazel.build/versions/master/skylark/config.html#user- defined-build-settings for more info) - `@bazel_tools//tools/jdk:toolchain_java10` and `@bazel_tools//tools/jdk:toolchain_java11` are now available to enable java 10, respectively java 11 language level support. - The `command` parameter of the `actions.run_shell()` function will be restricted to only accept strings (and not string sequences). This check is attached to flag `--incompatible_run_shell_command_string`. One may migrate by using the `arguments` parameter of `actions.run()` instead. See bazelbuild#5903 for more info. - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See bazelbuild#8622 for details. - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See bazelbuild#8622 f... - Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS` environment variable to specify system libraries that should be appended to the link command line. - paths under the execution root starting with "." or "_" will be re-linked across builds - execution_log_json_file now allows actions without outputs. - Labels aapt as deprecated for aapt_version, and heavily endorses aapt2. - Update doc links still pointing to cc_binary.features to point to common features - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See bazelbuild#8622 for details. RELNOTES: - --incompatible_disable_nocopts flag has been added. See bazelbuild#8706 for details. - Fixed treatment of <dist:module /> tags in AndroidManifest.xml - Fixed asset precedence for android_binary rules with aapt2. - Bazel now officially supports running on CentOS 7. - The runtime dynamic libraries are no longer in default output group of cc_binary. - set the FDOBuildType as CSFDO for binaries built with --cs_fdo_absolute_path. - Bazel can now be bootstrapped and built on arm64 platforms without requiring any flags or patches. - Fixed treatment of AndroidManifest.xml attributes which contained XML escaping - Retire experimental blaze flag experimental_link_compile_output_separately. The same behavior is available through the feature dynamic_link_test_srcs. - --incompatible_load_java_rules_from_bzl was added to forbid loading the native java rules directly. See more on tracking issue bazelbuild#8746 - Turn on --experimental_build_setting_api by default for starlark build settings (see https://docs.bazel.build/versions/master/skylark/config.html#user- defined-build-settings for more info) - Attribute names are going to be restricted and must be syntactically valid identifiers. bazelbuild#6437 - rule_test: fix Bazel 0.27 regression ("tags" attribute was ingored, bazelbuild#8723 This release contains contributions from many people at Google, as well as Ben Diuguid, Benjamin Peterson, Dave Lee, Loo Rong Jie, Mark Butcher, Marwan Tammam, Pedro Alvarez.
Baseline: 2e374a9 Cherry picks: + 6d0b14b: rule_test: apply "tags" to all rules in the macro Incompatible changes: - Add --incompatible_enable_profile_by_default to enable the JSON profile by default. - The --incompatible_windows_style_arg_escaping flag is flipped to "true", and the "false" case unsupported. Bazel no longer accepts this flag. Important changes: - Bazel now supports hiding compiler warnings for targets that you're not explicitly building (see https://docs.bazel.build/versions/master/user-manual.html#flag--au to_output_filter). - Flag `--incompatible_restrict_escape_sequences` is added. See #8380 - The "info" command now supports the "starlark-semantics" argument, which outputs a representation of the effective Starlark semantics option values. - The `outputs` parameter of the `rule()` function is deprecated and attached to flag `--incompatible_no_rule_outputs_param`. Migrate rules to use `OutputGroupInfo` or `attr.output` instead. See #7977 for more info. - When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. - Turn on --experimental_build_setting_api by default for starlark build settings (see https://docs.bazel.build/versions/master/skylark/config.html#user- defined-build-settings for more info) - `@bazel_tools//tools/jdk:toolchain_java10` and `@bazel_tools//tools/jdk:toolchain_java11` are now available to enable java 10, respectively java 11 language level support. - The `command` parameter of the `actions.run_shell()` function will be restricted to only accept strings (and not string sequences). This check is attached to flag `--incompatible_run_shell_command_string`. One may migrate by using the `arguments` parameter of `actions.run()` instead. See #5903 for more info. - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See #8622 for details. - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See #8622 f... - Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS` environment variable to specify system libraries that should be appended to the link command line. - paths under the execution root starting with "." or "_" will be re-linked across builds - execution_log_json_file now allows actions without outputs. - Labels aapt as deprecated for aapt_version, and heavily endorses aapt2. - Update doc links still pointing to cc_binary.features to point to common features - Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See #8622 for details. RELNOTES: - --incompatible_disable_nocopts flag has been added. See #8706 for details. - Fixed treatment of <dist:module /> tags in AndroidManifest.xml - Fixed asset precedence for android_binary rules with aapt2. - Bazel now officially supports running on CentOS 7. - The runtime dynamic libraries are no longer in default output group of cc_binary. - set the FDOBuildType as CSFDO for binaries built with --cs_fdo_absolute_path. - Bazel can now be bootstrapped and built on arm64 platforms without requiring any flags or patches. - Fixed treatment of AndroidManifest.xml attributes which contained XML escaping - Retire experimental blaze flag experimental_link_compile_output_separately. The same behavior is available through the feature dynamic_link_test_srcs. - --incompatible_load_java_rules_from_bzl was added to forbid loading the native java rules directly. See more on tracking issue #8746 - Turn on --experimental_build_setting_api by default for starlark build settings (see https://docs.bazel.build/versions/master/skylark/config.html#user- defined-build-settings for more info) - Attribute names are going to be restricted and must be syntactically valid identifiers. #6437 - rule_test: fix Bazel 0.27 regression ("tags" attribute was ingored, #8723 This release contains contributions from many people at Google, as well as Ben Diuguid, Benjamin Peterson, Dave Lee, Loo Rong Jie, Mark Butcher, Marwan Tammam, Pedro Alvarez.
What is the flag flip risk in 1.0? |
I grepped through our code base and we have 1 call site. One library really doesn't work well when built with coverage support (which is enabled by the toolchain/crosstool). We remove the |
Thanks for reaching out! |
That looks like it worked. That's a much better solution than nocopts. Thanks! |
This attribute will be removed soon: bazelbuild/bazel#8706 The only nocopts values passed are "-fno-exceptions" and "-[W]error". Bazel's crosstool doesn't provide either of them. PiperOrigin-RevId: 263082078
This flag was flipped in 8b840e1. |
There's one more use-case for nocopts - when we build third-party code and have to disable some warnings (-Wno-). If we have both .c and .cpp files in a single cc_library and need to turn off some c-only warnings (like -Wno-declaration-after-statement), we also have to add then to nocopts to make g++ happy. |
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 |
if I want to filter "-Werror" with nocopts="-Werror" |
Hi, I have a use-case for nocopts, and wanted to know what the appropriate migration is. I have a third-party library that I'm building through an Originally I was going to use nocopts and patch the BUILD file for the dependency, but instead it seems I should be using a feature. Does this mean I need to create a feature for FUZZING_BUILD_MODE... and pass it in to every target but the RE2 library during a specific build config? |
If I want to filter out the “-g” option, how should I set the “features” attribute?Thanks! |
@mst9009 sorry this is quite late, but adding copts "-g0" should accomplish what you were looking for? |
Hi. How should I filter out the |
This may be because of a whole separate issue (and I realize years after the original change), but one of the use cases for
Which is brittle, ugly, and not great (and is notably significantly worse than the original |
maybe you should update https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary.nocopts |
I have to admit that I'm only starting with Bazel, so please take the following with a grain of salt.
I know what each of these options do with gcc (although I'm surprised to see '-iquote' passed to the linker), but want to turn them off. |
cc @oquenchil |
3 years later and docs have no been updated. Also dead references in comments and code: https://github.com/bazelbuild/bazel/search?p=1&q=nocopts&type=code (edit: github code search is 😬, see: https://cs.opensource.google/search?q=nocopts&sq=&ss=bazel%2Fbazel ) Is the logic with bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CompileCommandLine.java Line 144 in a48e246
The provided toolchain link is also dead, has it been moved to https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/cc_toolchain_config_lib.bzl ? Which is then consumed by the various tool chain definitions? e.g. https://cs.opensource.google/bazel/bazel/+/master:tools/cpp/unix_cc_toolchain_config.bzl I think these features need to be a bit better documented, are they consistent between toolchains? I think I found something for my usecase, but not with the granularity I would like (just looking to turn off |
This flag prohibits the use of 'nocopts' attribute in cc_* rules. Issue #8706 RELNOTES: --incompatible_disable_nocopts flag has been added. See bazelbuild/bazel#8706 for details. PiperOrigin-RevId: 254781400
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 we do the necessary internal migration to remove it completely. output_filter_test doesn't make sense in Bazel since nocopts is not available. The file must remain while we migrate internally away from nocopts though. RELNOTES:none PiperOrigin-RevId: 503155992 Change-Id: I43184941c9cb9ee97d5229cf37062b346643a48a
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 we do the necessary internal migration to remove it completely. output_filter_test doesn't make sense in Bazel since nocopts is not available. The file must remain while we migrate internally away from nocopts though. RELNOTES:none PiperOrigin-RevId: 503155992 Change-Id: I43184941c9cb9ee97d5229cf37062b346643a48a
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` attribute (see bazelbuild/bazel#8706).
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` attribute (see bazelbuild/bazel#8706).
FWIW this attribute is still in the docs which might confuse some folks |
cc @pzembrod |
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:
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
would be migrated to
with
flag_a_feature
being defined in bazel's own C++ toolchain configuration.The text was updated successfully, but these errors were encountered: