Skip to content

fix: "Not a Target" logic bug in make helper awk script#1577

Open
rnvannatta wants to merge 1 commit intoscop:mainfrom
rnvannatta:main
Open

fix: "Not a Target" logic bug in make helper awk script#1577
rnvannatta wants to merge 1 commit intoscop:mainfrom
rnvannatta:main

Conversation

@rnvannatta
Copy link

In some obscure cases, target: VAR = val can cause make t to autocomplete to the incorrect result.

This is happening in one of my projects with a somewhat complex set of makefiles, such that make w returns windows, webgl, and a random build file. A silly, though minimal repro is:

all: fluff
fluff:
	touch fluff
foobar: OUCH = glitch

where make f will erroneously list completion possibilities all fluff

The root cause is that the foobar 'block' looks like this

# makefile (from 'Makefile', line 4)
foobar: OUCH = glitch
# Not a target:
foobar:
#  Implicit rule search has not been done.
#  Modification time never checked.
#  File has not been updated.
# variable set hash-table stats:
# Load=1/32=3%, Rehash=0, Collisions=0/2=0%

the script matches f against foobar, setting the target flag true, then it encounters # Not a target over 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 target reset 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.awk

Tested 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

@rnvannatta rnvannatta changed the title Fix "Not a Target" logic issue in make autocompletion awk script fix: "Not a Target" logic issue in make autocompletion awk script Mar 2, 2026
@rnvannatta rnvannatta changed the title fix: "Not a Target" logic issue in make autocompletion awk script fix: "Not a Target" logic bug in make helper awk script Mar 2, 2026
@rnvannatta
Copy link
Author

Fixed the lint issues with the commit message

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