Repository navigation
Conversation
|
|
||
| ## IWYU for C++ targets | ||
|
|
||
| By convention, there should be one wd_cc_library target for each .c++/.h file pair in most cases and |
There was a problem hiding this comment.
Here I'm really trying to teach the agent some nuance since fully enforcing IWYU and not trying to follow it at all are likely to cause significant churn. I hope this will lead to agents not adding headers that are not needed and using implementation_deps in Bazel where appropriate?
There was a problem hiding this comment.
I'm not sure this is the best placement for this. A skill file might be better as this is likely only going to be read if the agent is doing something in the build directory.
Also, it's a bit too wordy to be effective. I'd suggest something shorter like:
## IWYU FOR C++ TARGETS
Adapted from [include-what-you-use](https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md).
Small targets with accurate deps mean a change rebuilds and retests fewer targets.
- Don't add `#include`s a file doesn't use or `deps` a target doesn't use. When a change removes
the last use of a header, delete its `#include`, then the dep if it's now unused.
- Put deps whose headers are included only from `.c++` files in `implementation_deps`, so they
don't propagate to dependents.
- Prefer direct includes and deps over relying on transitive ones, but don't add a long list just
to spell out what you already get transitively.
- Give each `.h`/`.c++` pair its own `wd_cc_library`, named after the file (e.g.
`:tracked-wasm-instance`). A header without a `.c++` gets its own target too, with the deps it
needs to compile on its own.
- Keep each header in exactly one target, together with its `.c++` if it has one. Exposing a
header from a target that doesn't build its `.c++` lets code call its functions without
depending on their definitions, which shows up later as undefined-symbol link errors.
- If splitting a pair out would create a dependency cycle, leave it in its combined target (e.g.
`//src/workerd/io`) instead of separating the header from its `.c++`. Don't add new files to
such targets if they can have their own.
There was a problem hiding this comment.
Yeah it's wordy, but I think that's needed to tell the agent that sometimes it's not possible to separate each source/header pair into its own target and that it shouldn't go ham on adding headers even though that's what IWYU means (in a strict sense). Will try to rephrase this a bit/make it shorter based on your suggestion and put it into a skill file...
There was a problem hiding this comment.
Actually your text covers most of it, I'll probably just make minor edits
There was a problem hiding this comment.
Ok, I turned it into a skill and added two sentences to your text to (hopefully) make it not spray includes. I hope the description makes sense
|
Since last review: 0 resolved, 0 still open, 0 new. Carried forward from the last review: rust-first (no author changes in their files since then; earlier findings stand) Not re-run: api-compat, jsg-gc (no author changes in their files since the last review) Reviewed commit: f128879e · github run |
|
The generated output of |
cf332ea to
f128879
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7736 +/- ##
==========================================
+ Coverage 40.91% 41.04% +0.13%
==========================================
Files 983 986 +3
Lines 284112 284720 +608
Branches 27545 27618 +73
==========================================
+ Hits 116247 116875 +628
+ Misses 151793 151757 -36
- Partials 16072 16088 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…to its own target
We already enforce this using the bazel aquery somepath check, no need to check it twice.
f128879 to
7fc447a
Compare
|
Author identity unknown *** Please tell me who you are. Run git config --global user.email "you@example.com" to set your account's default identity. fatal: empty ident name (for runner@runnervm8k3b6.lkg1l3nnvv1ejizkdb15p355fb.gx.internal.cloudapp.net) not allowed |
|
@fhanau Bonk workflow failed. Check the logs for details. View workflow run · To retry, trigger Bonk again. |
[nfc] Add IWYU guidelines to AGENTS.md, move tracked-wasm-instance into its own target
[build] Remove rust_io_link_check
We already enforce this using the bazel aquery somepath check, no need to check it twice.
tracked-wasm-instance.h should be its own target anyway, moving it out facilitates some downstream improvements.
Otherwise this PR is just cleaning up and trying to teach agents about IWYU to hopefully avoid superfluous includes. We will also be adding some enforcement of not having bazel targets have unused dependencies when it would be harmful in an internal PR (!15453).