Repository navigation
Say which cc_library attributes propagate to dependents - #57
Open
anakanemison wants to merge 1 commit into
Open
anakanemison wants to merge 1 commit into
anakanemison wants to merge 1 commit into
Conversation
anakanemison
force-pushed
the
mschaller/d5-transitive-defines
branch
from
October 26, 2026 13:30
b835d7e to
9456ead
Compare
| grouping-agnostic), but keep **executable** names aligned or add a `target_map` | ||
| entry. Write `MODULE.bazel` as needed — before picking rulesets or pinning | ||
| `cc_binary` with `srcs`, `hdrs`, `copts`, `defines`, `includes`, `deps`. Bazel's | ||
| `defines` propagate to every dependent; a define the reference keeps private to |
Contributor
There was a problem hiding this comment.
We should cover more of these:
defines, includes, quote_includes, and linkopts all do. copts, local_defines, local_includes do not.
Contributor
Author
There was a problem hiding this comment.
Now says defines/includes/linkopts propagate, local_defines/local_includes/copts don’t, and implementation_deps is for private headers.
I left out quote_includes, which isn’t a cc_library attribute, as far as I can tell. Appears to be a field in CcInfo's compilation context?
CMake scopes a compile definition or include directory to a target (PRIVATE) or its consumers (PUBLIC/INTERFACE). In Bazel the attribute decides: `defines`, `includes` and `linkopts` propagate to every dependent, while `copts`, `local_defines` and `local_includes` stay with the target, and `implementation_deps` keeps a dependency's headers private. The per-TU diff only checks that each TU gets what CMake gave it, so a PRIVATE define written as `defines` converges while changing how every consumer compiles (a visibility macro such as <target>_EXPORTS turning on export-side behavior in consumers is the classic case). The only signal would be a WARN-level extra define on each consumer's TUs. "Create initial BUILD.bazel files" now lists both groups and says where private defines and include directories go. `local_includes` arrived in rules_cc 0.2.19 (June 2026), so the text gives the `copts` -I fallback for older versions. The scopes are as Bazel's cc_library documentation states them. Observed in any2bazel-lab: a lensfun migration avoided this unprompted, putting its visibility and <target>_EXPORTS defines in local_defines for exactly this reason. No run has yet been seen getting it wrong. In the lab's later lensfun run with an earlier version of this change (one sentence, on defines only), the agent again kept those defines in local_defines. Lab-Proposal: P7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anakanemison
force-pushed
the
mschaller/d5-transitive-defines
branch
from
November 2, 2026 17:51
9456ead to
c20829e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMake scopes a definition or include directory with
PRIVATEorPUBLIC; in Bazel the attribute decides. "Create initial BUILD.bazel files" now listsdefines,includesandlinkoptsas propagating, andcopts,local_defines,local_includesandimplementation_depsas private, so a private define such as<target>_EXPORTSgoes inlocal_defines.local_includesneeds rules_cc 0.2.19 or later; the text gives thecoptsfallback.The per-TU diff cannot see the mistake: a private define written as
definesconverges and changes how every consumer compiles. No any2bazel-lab run has been seen making it; a lensfun agent avoided it unprompted, and again with an earlier one-sentence version of this change.Stacked on #56 (tracking issue: #35).
pytest tests/: 186 passed (132 onmain). Lab proposal: P7.🤖 Generated with Claude Code