head 1.13; access; symbols netbsd-11-0-RC4:1.12 netbsd-11-0-RC3:1.12 netbsd-11-0-RC2:1.12 netbsd-11-0-RC1:1.12 perseant-exfatfs-base-20250801:1.12 netbsd-11:1.12.0.2 netbsd-11-base:1.12 netbsd-10-1-RELEASE:1.2 perseant-exfatfs-base-20240630:1.2 perseant-exfatfs:1.2.0.4 perseant-exfatfs-base:1.2 netbsd-10-0-RELEASE:1.2 netbsd-10-0-RC6:1.2 netbsd-10-0-RC5:1.2 netbsd-10-0-RC4:1.2 netbsd-10-0-RC3:1.2 netbsd-10-0-RC2:1.2 netbsd-10-0-RC1:1.2 netbsd-10:1.2.0.2 netbsd-10-base:1.2 cjep_sun2x-base1:1.1 cjep_sun2x:1.1.0.4 cjep_sun2x-base:1.1 cjep_staticlib_x-base1:1.1 cjep_staticlib_x:1.1.0.2 cjep_staticlib_x-base:1.1; locks; strict; comment @# @; 1.13 date 2026.02.10.18.53.34; author sjg; state Exp; branches; next 1.12; commitid pvj2zluBGR7owRtG; 1.12 date 2025.07.02.17.11.56; author rillig; state Exp; branches; next 1.11; commitid UzA3WWuOSacA6c1G; 1.11 date 2025.06.16.18.20.00; author rillig; state Exp; branches; next 1.10; commitid SL73kxnHvsOH09ZF; 1.10 date 2025.06.13.05.41.36; author rillig; state Exp; branches; next 1.9; commitid PtkQ6vl73RBWUGYF; 1.9 date 2025.06.05.21.56.54; author rillig; state Exp; branches; next 1.8; commitid 5HlgHu0266W5tKXF; 1.8 date 2025.05.28.20.18.45; author sjg; state Exp; branches; next 1.7; commitid njFOxdteK3NMhIWF; 1.7 date 2025.05.26.19.56.49; author rillig; state Exp; branches; next 1.6; commitid 35t9uxcPEsZxdsWF; 1.6 date 2025.05.23.21.16.36; author rillig; state Exp; branches; next 1.5; commitid xUXcBbJD5QbZJ4WF; 1.5 date 2025.05.23.21.05.56; author rillig; state Exp; branches; next 1.4; commitid IdhqV8K8pwyOF4WF; 1.4 date 2025.05.11.20.17.08; author rillig; state Exp; branches; next 1.3; commitid ZNMxAjc9PGsIOwUF; 1.3 date 2025.05.11.20.10.56; author rillig; state Exp; branches; next 1.2; commitid Qyyo87AADWqrLwUF; 1.2 date 2022.01.23.16.09.38; author rillig; state Exp; branches 1.2.4.1; next 1.1; commitid 55UrqaZMiBo29MpD; 1.1 date 2020.08.16.12.07.51; author rillig; state Exp; branches; next ; commitid coEgPk3hgfeYGhkC; 1.2.4.1 date 2025.08.02.05.58.36; author perseant; state Exp; branches; next ; commitid 23j6GFaDws3O875G; desc @@ 1.13 log @make: move MaybeSubMake to job.c Simplify MaybeSubMake to work on the expanded command from JobWriteCommand, we check for progname sans any "[level]". This improves reliability and reduces overhead as we only scan commands that will actually be run - in jobs mode. In meta_oodate we need to know of OP_SUBMAKE when deciding if a .meta file is needed or not - and therefor needs checking. This obviously happens before JobWriteCommand is called, so we may have to check MaybeSubMake from meta_needed. If so, we set a flag doneSubmake so JobWriteCommand will not recheck. Tweak the few unit-tests that are impacted. In particular; we have to use a symlink .make -> ${MAKE} to be able to defeat MaybeSubMake and trigger warnings about bogus -J args. Reviewed by: rillig @ text @direct: mode=parallel make: error: invalid internal option "-J garbage" in "" make: warning: Invalid internal option "-J" in ""; see the manual page in make[2] in directory "" direct-open: mode=compat .make[2]: warning: Invalid internal option "-J" in ""; see the manual page in .make[2] in directory "" indirect-open: mode=compat indirect-expr: mode=parallel .make[2]: warning: Invalid internal option "-J" in ""; see the manual page in .make[2] in directory "" indirect-comment: mode=compat indirect-silent-comment: mode=parallel indirect-expr-empty: mode=parallel exit status 0 @ 1.12 log @make: shorten diagnostic for invalid -J option In the manual page, there's more space to properly explain the complexity behind the warning. @ text @d6 2 a7 2 make: warning: Invalid internal option "-J" in ""; see the manual page in make[2] in directory "" d10 2 a11 2 make: warning: Invalid internal option "-J" in ""; see the manual page in make[2] in directory "" @ 1.11 log @make: in a warning without location information, print the stack trace Without further context, a warning like the following is hard to track back: > nbmake[4]: warning: Invalid character " " in variable name > "if ,"LSAN_OPTIONS="" @ text @d3 1 a3 5 make: warning: internal option "-J" in "" refers to unopened file descriptors; falling back to compat mode. To run the target even in -n mode, add the .MAKE pseudo-source to the target. To run the target in default mode only, add a ${:D make} marker to a target's command. (This marker expression expands to an empty string.) To make the sub-make run in compat mode, add -B to its invocation. To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. d6 1 a6 5 make: warning: internal option "-J" in "" refers to unopened file descriptors; falling back to compat mode. To run the target even in -n mode, add the .MAKE pseudo-source to the target. To run the target in default mode only, add a ${:D make} marker to a target's command. (This marker expression expands to an empty string.) To make the sub-make run in compat mode, add -B to its invocation. To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. d10 1 a10 5 make: warning: internal option "-J" in "" refers to unopened file descriptors; falling back to compat mode. To run the target even in -n mode, add the .MAKE pseudo-source to the target. To run the target in default mode only, add a ${:D make} marker to a target's command. (This marker expression expands to an empty string.) To make the sub-make run in compat mode, add -B to its invocation. To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. @ 1.10 log @make: new sentence, new line @ text @d8 1 d15 1 d23 1 @ 1.9 log @make: remove empty line from diagnostic, add tests for output handling The warning for the invalid internal option "-J" does not need a trailing newline, as that is provided by Parse_Error already. Having this newline in the output demonstrated a previously unknown bug in handling the output of child commands in parallel mode. There, empty lines are randomly discarded, depending on the chunks in which the output from the child process is copied to make's stdout. See job-output.mk for a demonstration. The test for the Korn shell did not run the Korn shell in error handling mode, as the error handling mode only affects the parallel mode but the test didn't switch to that mode. After fixing the shell-ksh.mk test, the single '"' in the output looked suspicious, and indeed, the shell-csh.mk test had the same problem of filtering more characters from the output than intended. @ text @d6 2 a7 1 To make the sub-make run in compat mode, add -B to its invocation.To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. d12 2 a13 1 To make the sub-make run in compat mode, add -B to its invocation.To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. d19 2 a20 1 To make the sub-make run in compat mode, add -B to its invocation.To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. @ 1.8 log @make: delay warning about bogus -J flag In MainParseArgJobsInternal just set bogusJflag to indicate that the descriptors passed were invalid. By the time we get to InitMaxJobs the command line and indeed the makefile have had a chance to put us in compat mode, in which case the warning is unnecessary. Add suggestion of -B if compat mode is desired in the sub-make. Reviewed by: rillig @ text @a6 1 a11 1 a17 1 @ 1.7 log @make: show contents of MAKEFLAGS in the stack trace When the internal -J option refers to a closed file descriptor, it's helpful to know what the MAKEFLAGS environment variable contains, in addition to the executed command line. Same for parse errors in variable assignments from the command line. @ text @d3 1 a3 1 make: warning: internal option "-J 31,32" in "" refers to an unopened file descriptor; falling back to compat mode. d6 2 a7 1 To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. d9 1 a9 1 make: warning: internal option "-J 15,16" in "" refers to an unopened file descriptor; falling back to compat mode. d12 2 a13 2 To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. while evaluating MAKEFLAGS " -r -k -j 1 -J 15,16 " d16 1 a16 1 make: warning: internal option "-J 15,16" in "" refers to an unopened file descriptor; falling back to compat mode. d19 2 a20 2 To make the sub-make independent from the parent make, unset the MAKEFLAGS environment variable in the target's commands. while evaluating MAKEFLAGS " -r -k -j 1 -J 15,16 " @ 1.6 log @make: add current directory to error messages from MAKEFLAGS While parsing the additional command line arguments from the MAKEFLAGS environment variable, the current directory was not initialized yet, so swap the order. As a side effect, this change would allow a "-m .../share/mk" option, with a literal magic "...", thus looking up the system directory in any ancestor directory of the current directory. This idea sounds unreliable enough that probably nobody will try this in practice. @ text @d12 1 d19 1 @ 1.5 log @make: warn when falling from parallel mode back to compat mode Falling back may run fewer jobs than intended, thus increasing the build's wall time. Falling back may run more jobs than intended, when a sub-make creates its own and independent token pool, thus overloading the system. Warn in both cases. Since the -J option is internal, it is not obvious how to fix the situation, so provide detailed instructions on the possible fixes and their effects. @ text @d8 1 a8 1 make: warning: internal option "-J 15,16" in "" refers to an unopened file descriptor; falling back to compat mode. d14 1 a14 1 make: warning: internal option "-J 15,16" in "" refers to an unopened file descriptor; falling back to compat mode. @ 1.4 log @make: clean up error message for malformed internal -J option There's no point printing the usage, as the problem is typically somewhere else. Reword the message to be easier to parse. @ text @d2 5 a6 1 make: error: invalid internal option "-J garbage" d8 4 d14 4 @ 1.3 log @tests/make: document internal option for parallel mode In several places in the NetBSD build, a subdir target invokes ${MAKEDIRTARGET}, assuming that this sub-make would coordinate the number of parallel jobs with its parent make. But since that command neither contains the plain word "make" nor the expression "${MAKE}", the sub-make falls back to compat mode. @ text @d2 1 a2 5 make: internal error -- J option malformed (garbage) usage: make [-BeikNnqrSstWwX] [-C directory] [-D variable] [-d flags] [-f makefile] [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file] [-V variable] [-v variable] [variable=value] [target ...] @ 1.2 log @tests/make: extend test suite, move old tests to 2020 scheme The tests from envfirst.mk are now in opt-env.mk. The tests from modword.mk are now in varmod-select-words.mk. @ text @d1 1 d7 7 a13 1 exit status 2 @ 1.2.4.1 log @Sync with HEAD @ text @d1 6 a6 15 direct: mode=parallel make: error: invalid internal option "-J garbage" in "" make: warning: Invalid internal option "-J" in ""; see the manual page in make[2] in directory "" direct-open: mode=compat make: warning: Invalid internal option "-J" in ""; see the manual page in make[2] in directory "" indirect-open: mode=compat indirect-expr: mode=parallel make: warning: Invalid internal option "-J" in ""; see the manual page in make[2] in directory "" indirect-comment: mode=compat indirect-silent-comment: mode=parallel indirect-expr-empty: mode=parallel exit status 0 @ 1.1 log @make(1): add dummies for fine-grained tests, one per single feature The test names have been derived from the current manual page. All these tests are dummies right now, and the code from the existing tests will be moved into the new tests step by step. This is done to prevent modmisc, escape, varmod-edge and varmisc from growing without any bounds, and to reduce the side-effects of one test to the others. @ text @d1 6 a6 1 exit status 0 @