Skip to content

Pass target as an actual Make goal to 'make -pq' - #9

Merged
colluca merged 2 commits into
mainfrom
pass-target-to-make-pq
Jul 27, 2026
Merged

Pass target as an actual Make goal to 'make -pq'#9
colluca merged 2 commits into
mainfrom
pass-target-to-make-pq

Conversation

@colluca

@colluca colluca commented Jul 27, 2026

Copy link
Copy Markdown
Owner

_parse_makefile previously ran a bare make -pq with no goal, so MAKECMDGOALS was always empty inside that invocation. Any Makefile logic conditioned on the requested goal — e.g. an -include gated behind
$(if $(filter ...,$(MAKECMDGOALS)),...), used to lazily include an
auto-generated dependency file only when it's actually relevant to what's being
built — was never triggered, silently hiding whatever prerequisites that logic
would otherwise have surfaced.

This came up because snitch_cluster's yosys target relies on exactly this
pattern to expand into its full list of RTL source files (generated via a
Verilator preprocessing pass into a .d file), and list-make-prerequisites yosys --recursive was silently missing every one of them.

Fix

Pass target as an actual positional goal to the underlying make -pq call, so
it behaves the same way a real make <target> invocation would for
MAKECMDGOALS-conditional logic — including letting Make regenerate a missing auto-generated dependency file via its normal rule, if there is one.

Verification

Tested against a real checkout of snitch_cluster's yosys target (with its
dependency file already generated from a prior local build):

before after
total prerequisites 11 424
RTL files (`.sv`/`.svh`/`.v`) 0 413

Also reran the existing CLI checks against this repo's own test/ fixtures to
confirm no regression there.

Testing

Added a regression test (test/test_cli.py::test_list_prerequisites_with_makecmdgoals_conditional_prerequisite) that reproduces the exact pattern behind this bug: a conditional target in test/Makefile whose full prerequisite list only appears once a generated gendep.mk is -included, gated on $(filter conditional,$(MAKECMDGOALS)) — mirroring snitch_cluster's sn_include_deps/auto-generated .d-file mechanism.

Verified it actually catches the regression: reinstalling the pre-fix common.py makes this test fail (hiddenprereq silently missing, only standaloneprereq returned), while the fix makes it pass.

@colluca
colluca force-pushed the pass-target-to-make-pq branch from d195f52 to 4e97dc2 Compare July 27, 2026 13:20
@colluca
colluca merged commit ae240b1 into main Jul 27, 2026
2 checks passed
@colluca
colluca deleted the pass-target-to-make-pq branch July 27, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant