You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
incompatible_disable_nocopts: Disallow 'nocopts' attribute from cc_* rules #8706
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
This may be because of a whole separate issue (and I realize years after the original change), but one of the use cases for nocopts that I was using was removing /I. from some windows builds where it was being applied incorrectly (it's inclusion causes MSVC to behave differently than gcc/clang given the same file structure; this would be the separate and much more complex issue to fix that I am fine working around, even though it's pretty weird (the first depending cc_library's BUILD file location effects the build of the dependent cc_library for all the other depending rules)). So a feature flag setting of -include_path_local (minus to remove) would be nice (unless there is a syntax for removing a specific instance of the include_paths flag group? Currently my workaround is this:
I have to admit that I'm only starting with Bazel, so please take the following with a grain of salt.
I'm trying to integrate a non-gcc C++ compiler into Bazel, and it is complaining about a lot of gcc-specific options that are being injected into the build. I can easily believe that this is because I'm following a tutorial that assumes a gcc builder, hence a single load() could be adding unnecessary flags. However, the most egregious of these (as I see it) are:
"Unknown option '-frandom-seed=...'"
"Unknown option '-iquote' passed to linker"
"Unrecognized option: -S"
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.
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 cxx_flags).
Activity
Introduce --incompatible_disable_nocopts flag
Introduce --incompatible_disable_nocopts flag
Release 0.28.0 (2019-07-10)
Introduce --incompatible_disable_nocopts flag
Release 0.28.0 (2019-07-10)
Release 0.28.0 (2019-07-10)
15 remaining items
wrowe commentedon May 7, 2021
@mst9009 sorry this is quite late, but adding copts "-g0" should accomplish what you were looking for?
changlan commentedon May 20, 2021
Hi. How should I filter out the
-fstack-protectorflag with the “features” attribute? Trieddefault_compile_flagsbut it removed all compile flags.mason-bially commentedon Dec 3, 2021
This may be because of a whole separate issue (and I realize years after the original change), but one of the use cases for
nocoptsthat I was using was removing/I.from some windows builds where it was being applied incorrectly (it's inclusion causes MSVC to behave differently than gcc/clang given the same file structure; this would be the separate and much more complex issue to fix that I am fine working around, even though it's pretty weird (the first dependingcc_library's BUILD file location effects the build of the dependentcc_libraryfor all the other depending rules)). So a feature flag setting of-include_path_local(minus to remove) would be nice (unless there is a syntax for removing a specific instance of theinclude_pathsflag group? Currently my workaround is this:Which is brittle, ugly, and not great (and is notably significantly worse than the original
nocoptsmethod of fixing it up)wondfor commentedon Jan 13, 2022
maybe you should update https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary.nocopts
JohnGHS commentedon Mar 28, 2022
I have to admit that I'm only starting with Bazel, so please take the following with a grain of salt.
I'm trying to integrate a non-gcc C++ compiler into Bazel, and it is complaining about a lot of gcc-specific options that are being injected into the build. I can easily believe that this is because I'm following a tutorial that assumes a gcc builder, hence a single
load()could be adding unnecessary flags. However, the most egregious of these (as I see it) are: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.
scentini commentedon Mar 28, 2022
cc @oquenchil
dmadisetti commentedon May 13, 2022
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
UNFILTERED_COMPILE_FLAGS_FEATURE_NAMEstill relevant?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
cxx_flags).Introduce --incompatible_disable_nocopts flag
Remove nocopts attribute from cc_library.bzl
Remove nocopts attribute from cc_library.bzl
Remove `nocopts` from cc_nanopb_proto_library
Remove `nocopts` from cc_nanopb_proto_library
keith commentedon Jun 27, 2024
FWIW this attribute is still in the docs which might confuse some folks
hvadehra commentedon Jul 1, 2024
cc @pzembrod
Remove `nocopts` from cc_nanopb_proto_library