head 1.19; access; symbols netbsd-11-0-RC4:1.18 netbsd-11-0-RC3:1.18 netbsd-11-0-RC2:1.18 netbsd-11-0-RC1:1.18 perseant-exfatfs-base-20250801:1.18 netbsd-11:1.18.0.2 netbsd-11-base:1.18 netbsd-10-1-RELEASE:1.5 perseant-exfatfs-base-20240630:1.7 perseant-exfatfs:1.7.0.2 perseant-exfatfs-base:1.7 netbsd-10-0-RELEASE:1.5 netbsd-10-0-RC6:1.5 netbsd-10-0-RC5:1.5 netbsd-10-0-RC4:1.5 netbsd-10-0-RC3:1.5 netbsd-10-0-RC2:1.5 netbsd-10-0-RC1:1.5 netbsd-10:1.5.0.2 netbsd-10-base:1.5 cjep_sun2x-base1:1.2 cjep_sun2x:1.2.0.4 cjep_sun2x-base:1.2 cjep_staticlib_x-base1:1.2 cjep_staticlib_x:1.2.0.2 cjep_staticlib_x-base:1.2; locks; strict; comment @# @; 1.19 date 2026.02.01.16.42.35; author rillig; state Exp; branches; next 1.18; commitid QDTzAMUxdyOj5HsG; 1.18 date 2025.06.13.03.51.18; author rillig; state Exp; branches; next 1.17; commitid Dmn2d9jxc5gaiGYF; 1.17 date 2025.06.12.20.07.59; author rillig; state Exp; branches; next 1.16; commitid TvXDsjyvKE04KDYF; 1.16 date 2025.06.12.19.02.32; author rillig; state Exp; branches; next 1.15; commitid KVFL0xqz3NxBnDYF; 1.15 date 2025.03.30.09.51.51; author rillig; state Exp; branches; next 1.14; commitid veGmSzVhPiW2G4PF; 1.14 date 2025.03.29.10.39.48; author rillig; state Exp; branches; next 1.13; commitid 22Yp9aLGm4mSZWOF; 1.13 date 2024.08.29.20.20.36; author rillig; state Exp; branches; next 1.12; commitid EaMgk7FrF8mB1LnF; 1.12 date 2024.08.27.05.01.03; author rillig; state Exp; branches; next 1.11; commitid XteaeUfwks9Q0qnF; 1.11 date 2024.08.27.04.52.14; author rillig; state Exp; branches; next 1.10; commitid UgjCTqNeLLzyXpnF; 1.10 date 2024.08.25.20.44.31; author rillig; state Exp; branches; next 1.9; commitid capvERC4HzksifnF; 1.9 date 2024.07.04.20.18.40; author rillig; state Exp; branches; next 1.8; commitid 75IS4XOhTa8VOygF; 1.8 date 2024.07.04.17.47.54; author rillig; state Exp; branches; next 1.7; commitid mjDGVMgldk7QYxgF; 1.7 date 2024.01.07.01.33.57; author sjg; state Exp; branches 1.7.2.1; next 1.6; commitid rbwPJlgOwPyjmsTE; 1.6 date 2023.06.01.20.56.35; author rillig; state Exp; branches; next 1.5; commitid j3tIvMRlxolKQhrE; 1.5 date 2022.01.29.10.19.49; author rillig; state Exp; branches; next 1.4; commitid hFGRNbkyf4Rs0wqD; 1.4 date 2022.01.29.10.09.37; author rillig; state Exp; branches; next 1.3; commitid 8uAjdFjSKkZsXvqD; 1.3 date 2022.01.29.09.38.27; author rillig; state Exp; branches; next 1.2; commitid WnLcfqYcBVn7MvqD; 1.2 date 2020.10.31.13.45.00; author rillig; state Exp; branches; next 1.1; commitid pZ4Fmx6ruwsLM3uC; 1.1 date 2020.10.31.11.30.57; author rillig; state Exp; branches; next ; commitid kmh81vim1jnH23uC; 1.7.2.1 date 2025.08.02.05.58.38; author perseant; state Exp; branches; next ; commitid 23j6GFaDws3O875G; desc @@ 1.19 log @make: in stack traces, add location information for targets @ text @make: var-recursive.mk:11: Variable DIRECT is recursive. while evaluating variable "DIRECT" with value "${DIRECT}" in make[1] in directory "" make: var-recursive.mk:11: <> make: var-recursive.mk:19: Variable INDIRECT1 is recursive. while evaluating variable "INDIRECT2" with value "${INDIRECT1}" while evaluating variable "INDIRECT1" with value "${INDIRECT2}" in make[1] in directory "" make: var-recursive.mk:19: <> make: var-recursive.mk:26: make: var-recursive.mk:34: Variable MODIFIERS is recursive. while evaluating variable "MODIFIERS" with value "${MODIFIERS:Mpattern}" in make[1] in directory "" make: var-recursive.mk:34: make: var-recursive.mk:43: Variable V is recursive. while evaluating variable "V" with value "$V" in make[1] in directory "" make: var-recursive.mk:43: <> make: Fatal errors encountered -- cannot continue make: stopped making "loadtime" in unit-tests sub-exit status 1 : before-recursive make: Variable VAR is recursive. while evaluating variable "VAR" with value "${VAR}" in command ": recursive-line-before <${VAR}> recursive-line-after" in target "runtime" from var-recursive.mk:56 in make[1] in directory "" sub-exit status 2 exit status 0 @ 1.18 log @make: add on-demand inter-process stack traces When debugging a build that heavily uses nested calls to sub-makes, the chain of calls is useful to quickly assess the situation. If explicitly requested, include the actions from any parent processes in the stack traces. Reviewed by: sjg @ text @d26 1 a26 1 in target "runtime" @ 1.17 log @make: add program name to stack traces from sub-makes @ text @d27 1 @ 1.16 log @make: add quotes to "in directory" line in stack traces The other lines in stack traces use quotes as well. @ text @d3 1 a3 1 in directory "" d8 1 a8 1 in directory "" d13 1 a13 1 in directory "" d17 1 a17 1 in directory "" @ 1.15 log @make: use '"filename" line 123' for locations instead of 'filename:123' The format 'filename:123' is commonly used for identifying a location in a file. Text editors recognize it and allow quick navigation through it. The previous format was specific to make and would have required custom support in editors. The new format was already used in stack traces, except for the first line. Now all lines use the same format. @ text @d3 1 a3 1 in directory d8 1 a8 1 in directory d13 1 a13 1 in directory d17 1 a17 1 in directory @ 1.14 log @make: in stack traces from target commands, add the command level A target can contain several commands, and these commands are likely to contain the same expressions. To distinguish them, add one more line to the stack trace, to narrow down the source of the error. @ text @d1 1 a1 1 make: "var-recursive.mk" line 11: Variable DIRECT is recursive. d4 2 a5 2 make: "var-recursive.mk" line 11: <> make: "var-recursive.mk" line 19: Variable INDIRECT1 is recursive. d9 3 a11 3 make: "var-recursive.mk" line 19: <> make: "var-recursive.mk" line 26: make: "var-recursive.mk" line 34: Variable MODIFIERS is recursive. d14 2 a15 2 make: "var-recursive.mk" line 34: make: "var-recursive.mk" line 43: Variable V is recursive. d18 1 a18 1 make: "var-recursive.mk" line 43: <> @ 1.13 log @make: reduce line length in error messages The error messages for deeply nested parse errors were hard to decipher, due to the large amount of text. Split these messages into individual lines, just as in the backtrace for .include files and .for loops. This unified backtrace makes the output more uniform. @ text @d25 1 @ 1.12 log @tests/make: add stricter checks to test for recursive variables @ text @d1 2 a2 1 make: "var-recursive.mk" line 11: while evaluating variable "DIRECT" with value "${DIRECT}": Variable DIRECT is recursive. d5 3 a7 1 make: "var-recursive.mk" line 19: while evaluating variable "INDIRECT1" with value "${INDIRECT2}": while evaluating variable "INDIRECT2" with value "${INDIRECT1}": Variable INDIRECT1 is recursive. d11 2 a12 1 make: "var-recursive.mk" line 34: while evaluating variable "MODIFIERS" with value "${MODIFIERS:Mpattern}": Variable MODIFIERS is recursive. d15 2 a16 1 make: "var-recursive.mk" line 43: while evaluating variable "V" with value "$V": Variable V is recursive. d23 3 a25 1 make: in target "runtime": while evaluating variable "VAR" with value "${VAR}": Variable VAR is recursive. @ 1.11 log @make: treat recursive variables non-fatally A recursive variable is no worse than an unknown modifier, so treat them in the same way by continuing parsing until the end of the makefile. @ text @d17 1 a17 1 : OK @ 1.10 log @make: add more context to error message about recursive variables @ text @d1 1 a1 2 make: "var-recursive.mk" line 21: still there make: "var-recursive.mk" line 23: while evaluating variable "DIRECT" with value "${DIRECT}": Variable DIRECT is recursive. d3 6 a8 4 make: stopped in unit-tests sub-exit status 2 make: "var-recursive.mk" line 31: while evaluating variable "INDIRECT1" with value "${INDIRECT2}": while evaluating variable "INDIRECT2" with value "${INDIRECT1}": Variable INDIRECT1 is recursive. d10 2 a11 5 make: stopped in unit-tests sub-exit status 2 make: "var-recursive.mk" line 39: ok make: "var-recursive.mk" line 48: while evaluating variable "V" with value "$V": Variable V is recursive. d13 4 a16 3 make: stopped in unit-tests sub-exit status 2 d18 1 a18 3 In a command near "var-recursive.mk" line 60: make[1]: in target "target": while evaluating variable "VAR" with value "${VAR}": Variable VAR is recursive. make: stopped making "target" in unit-tests @ 1.9 log @make: on error, print the targets to be made This helps to understand situations with several nested sub-makes in varying directories. @ text @d2 1 a2 2 make: Variable DIRECT is recursive. in var-recursive.mk:22 d6 2 a7 2 make: Variable INDIRECT1 is recursive. in var-recursive.mk:29 d11 3 a13 3 make: "var-recursive.mk" line 37: ok make: Variable V is recursive. in var-recursive.mk:45 d17 1 d19 1 a19 1 In a command near "var-recursive.mk" line 57: make[1]: Variable VAR is recursive. d22 1 @ 1.8 log @make: add more context information to error messages In case of a parse error or evaluation error, print the variable value in addition to the variable name, to see the effects of previous expression modifiers. In nested make calls, print the current directory at the bottom of a stack trace, as that information is otherwise hard to get in a parallel build spanning multiple directories. @ text @d21 1 a21 1 make: stopped in unit-tests @ 1.7 log @make: more consistent error messages Move %s: progname from Job_CheckCommands to Fatal to avoid is being repeated when Job_CheckCommands is passed Error. This means some errors from var also report progname (and level) which is useful. Reviewed by: rillig @ text @d4 1 d9 1 d15 1 @ 1.7.2.1 log @Sync with HEAD @ text @d1 18 a18 28 make: var-recursive.mk:11: Variable DIRECT is recursive. while evaluating variable "DIRECT" with value "${DIRECT}" in make[1] in directory "" make: var-recursive.mk:11: <> make: var-recursive.mk:19: Variable INDIRECT1 is recursive. while evaluating variable "INDIRECT2" with value "${INDIRECT1}" while evaluating variable "INDIRECT1" with value "${INDIRECT2}" in make[1] in directory "" make: var-recursive.mk:19: <> make: var-recursive.mk:26: make: var-recursive.mk:34: Variable MODIFIERS is recursive. while evaluating variable "MODIFIERS" with value "${MODIFIERS:Mpattern}" in make[1] in directory "" make: var-recursive.mk:34: make: var-recursive.mk:43: Variable V is recursive. while evaluating variable "V" with value "$V" in make[1] in directory "" make: var-recursive.mk:43: <> make: Fatal errors encountered -- cannot continue make: stopped making "loadtime" in unit-tests sub-exit status 1 : before-recursive make: Variable VAR is recursive. while evaluating variable "VAR" with value "${VAR}" in command ": recursive-line-before <${VAR}> recursive-line-after" in target "runtime" in make[1] in directory "" sub-exit status 2 @ 1.6 log @tests/make: force line-based diagnostics to be listed in the tests This way, contradictions between the intended output and the actual output are closer together and have a better chance of being spotted. @ text @d2 1 a2 1 Variable DIRECT is recursive. d6 1 a6 1 Variable INDIRECT1 is recursive. d11 1 a11 1 Variable V is recursive. d16 1 a16 1 In a command near "var-recursive.mk" line 57: Variable VAR is recursive. @ 1.5 log @make: for recursive variables in commands, print location Print the approximate location based on the last command that has been defined for the target. It would be possible to get more detailed location information by counting the number of commands of the target, but that would get messy due to .USEBEFORE, .USE and .DEFAULT, and still, this is an edge case, so don't waste too much code for it now. Having this hint about the location is more helpful than just a plain "Variable X is recursive" without any further details. @ text @d1 1 a1 1 make: "var-recursive.mk" line 20: still there d3 1 a3 1 in var-recursive.mk:21 d7 1 a7 1 in var-recursive.mk:28 d10 1 a10 1 make: "var-recursive.mk" line 35: ok d12 1 a12 1 in var-recursive.mk:43 d16 1 a16 1 In a command near "var-recursive.mk" line 55: Variable VAR is recursive. @ 1.4 log @tests/make: demonstrate recursive variable in target @ text @d16 1 a16 1 Variable VAR is recursive. @ 1.3 log @make: print stack trace on fatal errors The only fatal error that occurs while the makefiles are read in is the one about recursive variables, which didn't give any hint about the location before. If a recursive variable is detected while evaluating the commands of a target to be made, there is no location information, as before. @ text @d15 4 @ 1.2 log @make(1): add test for recursion detection with short variable names @ text @d3 1 d7 1 d12 1 @ 1.1 log @make(1): add test for recursive variable expressions @ text @d9 3 @