-
Notifications
You must be signed in to change notification settings - Fork 464
Limit warnings about unused things #5239
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this matches behavior of clang and it makes it easier to actually see the directly unused entities. One downside could be no warnings even on removal of control-plane visible entities (if the target allows removing them), but this would only occur if the user chooses to ignore other warnings, so I am not too concerned. So overall I think this makes the compiler output better.
I added a second change here that adds two things:
Having the former without the latter generates a slew of warnings from core.p4, v1model.p4, etc, but necessitates some fixes to the way the system header files are tracked, mostly to make gtests work (as they use hacked-up ways of getting the header files). |
when calling RemoveUnused it a loop, only set the 'warn' flag to true on the first iteration. This avoid wantings about things that *are* used, but only by unused things removed in a previous iteration. Signed-off-by: Chris Dodd <cdodd@nvidia.com>
- supress unused warnings for thing in the arch/core p4include Signed-off-by: Chris Dodd <cdodd@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although I did not double-check the declarations are really unused in the test outputs. Please also update the PR name.
@@ -73,7 +73,7 @@ $(BPFNAME).c: $(P4FILE) | |||
echo "*** ERROR: Cannot find $(P4C)"; \ | |||
exit 1;\ | |||
fi; | |||
$(P4C) --Werror $(P4INCLUDE) --target $(TARGET) -o $@ $< $(P4ARGS) | |||
$(P4C) --Werror --Wdisable=unused $(P4INCLUDE) --target $(TARGET) -o $@ $< $(P4ARGS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several of the testcases contain unused actions that previously were not being warned about. With --Werror
these become errors which cause the testcases to fail.
when calling RemoveUnused it a loop, only set the 'warn' flag to true on the first iteration. This avoid wantings about things that are used, but only by unused things removed in a previous iteration.