fix: "Not a Target" logic bug in make helper awk script#1577
fix: "Not a Target" logic bug in make helper awk script#1577rnvannatta wants to merge 1 commit intoscop:mainfrom
Conversation
|
Fixed the lint issues with the commit message |
|
How do you feel about adding a test? You could probably just add it to |
| # should be output. | ||
|
|
||
| # only process the targets the user wants. | ||
| starts_with($0, prefix) { is_target_block = 1; } |
There was a problem hiding this comment.
I don't know if this PR is the right fix for the present issue. In the first place, does anyone have an idea of the reason that we start the block with the matching line and include also unmatching lines in the same block? Isn't this the root cause of the present issue? I translated the original sed script in #1069 into AWK so that the behavior wouldn't be changed, but the behavior seems a mystery. This behavior seems to have existed from the beginning since the analysis was introduced in commit b28d710 by @code5hot.
There was a problem hiding this comment.
It's kind of an obscure issue for a less widely used Makefile feature, that for some reason make outputs a slightly different formatted message for.
Normally 'blocks' that aren't targets have their first line be "Not a target:".
In this case, the "Not a target:" comes after the line that passes the starts_with() awk test.
There was a problem hiding this comment.
I didn't ask why the present PR fixes the issue. I know that this PR does fix the present specific issue, but that doesn't immediately mean that's the right fix. If the root cause lies in the original approach at all, the root cause should be fixed instead of patching every downstream symptom separately.
In some obscure cases,
target: VAR = valcan causemake tto autocomplete to the incorrect result.This is happening in one of my projects with a somewhat complex set of makefiles, such that
make wreturns windows, webgl, and a random build file. A silly, though minimal repro is:where
make fwill erroneously list completion possibilitiesall fluffThe root cause is that the foobar 'block' looks like this
the script matches f against foobar, setting the target flag true, then it encounters
# Not a targetover and over and over again until it hits the all target, and because the target flag is true, it accepts that. The solution is to make# Not a targetreset the flag as it skips.You can test the script in isolation with:
make -npq __BASH_MAKE_COMPLETION__=1 -C . .DEFAULT 2>/dev/null | prefix="f" prefix_replace="f" awk -f make-extract-targets.awkTested on Debian Trixie with GNU Make 4.4.1, the latest in Debian.
Here is the output of make -nqp on the minimal repro makefile for your convenience: make-nqp-output.txt