summaryrefslogtreecommitdiff
path: root/usr.bin/make/job.c
AgeCommit message (Collapse)Author
2023-02-15make: inline macros for variable namesrillig
The variable name '.MAKEOVERRIDES' was already used in the non-macro form. No binary change.
2023-02-14make: clean up calls to Var_Substrillig
None of the calls to Var_Subst used the return value, and the return value was always VPR_OK. No functional change.
2023-01-17Accept whitespace between command specifiers @+- like gmake does. New binutilschristos
does this.
2022-10-10make: change return type of unlink_file back to intrillig
As unlink_file is a wrapper around unlink, use the same encoding for the possible return values as in the wrapped function. This consistency is more important than expressing all possible return values in the return type 'bool'. https://mail-index.netbsd.org/tech-toolchain/2022/10/06/msg004155.html No functional change.
2022-09-03make: untangle output handling in jobs mode, remove redundant bracesrillig
No functional change.
2022-09-03make: fix handling of null bytes in the output in jobs moderillig
The test job-output-null failed occasionally, depending on the exact timing of the child's write and make's read.
2022-05-07make: rename Compat_Run to Compat_MakeAllrillig
No functional change.
2022-02-12make: fix echoing of command with '-' in silent target in jobs moderillig
Since job.c 1.83 from 2003-12-20, the command had been echoed even if the target had the attribute '.SILENT'. In sh-flags.exp, each removed 'echo' command is below a target name matching the pattern 'opt-?j????-tgt-??s-cmd-?i?', which means that the target was marked as silent, either through a global '.SILENT' declaration or the command line option '-s' or the attribute '.SILENT' on the target. Reported by Alan Barrett in PR#45356.
2022-02-04make: use unsigned int for line numbers everywhererillig
Previously, some line numbers were stored as signed int while others were stored as size_t. Since line numbers are never negative, use an unsigned type. Since the maximum file size for makefiles is 1 GB (see loadfile), unsigned int is large enough even on 64-bit platforms. Using a single data types reduces the number of type conversions. Using unsigned int improves compatibility with C90 (printf %u instead of %zu), which is needed by bmake, which is derived from usr.bin/make. No functional change.
2022-01-30Make the GNode lineno unsigned to fix lint warning in var.c callingchristos
PrintLocation()
2022-01-22make: add missing newline after "cannot continue" messagerillig
It was wrong of Parse_File to output an unfinished line and hope for some other code to finish it. As demonstrated in the test, PrintOnError did not do that in the case of additional debug output. To keep the overall behavior as close as possible to before, the other callers of PrintOnError now have to pass the newline themselves. Passing strings that start with newlines but don't end with them looked suspicious anyway.
2022-01-08make: remove redundant bracesrillig
No binary change, except for assertion line numbers.
2022-01-07make: rename and inline Targ_Preciousrillig
No functional change.
2022-01-07make: reduce code for initializing error handling in shellrillig
No functional change.
2021-12-27make: remove unnecessary words from command line optionsrillig
Several years ago, the command line options were individual global variables. The global variable could therefore not be named 'silent' since that would have conflicted with local variables of the same name. After moving the global variable to the namespace 'struct CmdOpts', there is no conflict anymore. There doesn't seem to be any risk of naming collisions for the names 'touch' and 'query'. No functional change.
2021-12-27make: rename eunlink to unlink_filerillig
The name eunlink suggested a relation with the similarly named functions emalloc or esnprintf, but that was misleading. Instead, unlink_file works like unlink, except that it refuses to remove an empty directory. No functional change.
2021-12-15make: format comments according to /usr/share/misc/stylerillig
Assisted by indent(1), with manual corrections due to its many remaining bugs. No functional change.
2021-12-15make: use consistent indentation for statements and continuationsrillig
No binary change, except for line numbers in assertions in suff.c.
2021-12-15make: change return type of Compat_RunCommand from int to boolrillig
The documentation was wrong before since status was not restricted to only 0 or 1. No functional change.
2021-11-28make: convert GNodeFlags from enum into bit-fieldsrillig
Now that Enum_ToString is implemented for each type separately, it's easy to convert them to bit-fields. This gets rid of the magic numbers 12 for CYCLE and 13 for DONECYCLE that left a suspicious gap in the numbers. This gap was not needed since the code didn't make use of the relative ordering of the enum constants. The effects of this conversion are fewer capital letters in the code, smaller scope for the GNode flags, and clearer code especially when setting a flag back to false. One strange thing is that GCC 10.3.0 doesn't optimize GNodeFlags_IsNone to an single bitmasking instruction, at least on x86_64. Instead it generates a testb instruction for each of the flags, even loading bit 8 separately from the others. Clang 12.0.1 knows this optimization though and generates the obvious sequence of movzwl, testl, jz. No functional change.
2021-11-28make: eliminate common subexpressions in DebugFailedJobrillig
No functional change.
2021-11-28make: fix memory leak in jobs mode with -de (since today)rillig
2021-11-28make: with the option -de in jobs mode, output expanded commandsrillig
This helps tracking down the actual cause of build failures in build systems like NetBSD's build.sh that use highly abstracted commands that are mainly defined in terms of variables.
2021-10-24Do not ignore write failures.sjg
We should not ignore failure to write to cmdFILE, meta files and filemon. Reviewed by: rillig
2021-06-16make: fix error handling in jobs moderillig
By using the same error handling code as in the branch for non-empty commands, the behavior is the same again as before 2021-01-29.
2021-06-16make: extract commands-ok check from JobWriteShellCommandsrillig
This piece of code did not match the function name and thus could not reasonably be expected in that function. In job.c 1.399 from 2021-01-29 I missed exactly this little detail when I added code to skip the apparently unnecessary creation of empty shell files. The code I added only handled the happy case, not the case where the target could not be made. That code path then differed, leading to a much more verbose error message than before. before: don't know how to make ../missing/no-such.o. Stop after: don't know how to make ../missing/no-such.o. Stop ... `../missing/no-such.o' was not built (made BEINGMADE, ...)! `muck' was not built (made DEFERRED, type OP_DEPENDS|...)! `muck' has .ORDER dependency against build-all (made DEFERRED, ...) Thanks to sjg for finding and reproducing this unintended change of behavior.
2021-06-16make: clean up comment for JobStartrillig
The parameter 'flags' was renamed in job.c 1.354 from 2020-12-10 without adjusting the documentation. The parameter 'previous' was removed in job.c 1.108 from 2006-03-12, also without adjusting the documentation of JobStart. No functional change.
2021-04-27make: use consistent variable names, types and braces in DebugFailedJobrillig
No functional change.
2021-04-27make: remove stray space in -de output in jobs moderillig
In compat mode, having a space in this place makes sense to align the target name with the command. In jobs mode, since each command is listed in a separate line, there is no need for the double space.
2021-04-27Print -de error information when running multiple jobschristos
Problem and patch description from https://reviews.freebsd.org/D29647: When running `make -de` (without any -j flag) bmake prints which command failed. However, when using the -j flag the -de flag is ignored. This can make it rather difficult to determine which command failed in an very parallel build (especially when combined with the -s flag to avoid ridiculously large logfiles). For single-threaded builds we can combine -s with -de to get the failed command but this does not work with -jN (even with -j1). This patch prints the failed shell script with -de in the multiple jobs mode as well. From Alexander Richardson @ FreeBSD
2021-04-16make: use distinct wording for writing to the shell commands filerillig
The word 'write' now means to write to the file that holds the shell commands to be run later. The word 'print' is now used exclusively for handling the output of the child commands and printing them to make's stdout. No functional change.
2021-04-16make: align name of jobs_table_dump to the other functionsrillig
2021-04-15make: remove type name for the abort status in job handlingrillig
2021-04-15make: rename PrintOutput to PrintFilteredOutput to avoid confusionrillig
In the default configuration, the function PrintOutput did nothing. Only if the shell has defined an output filter, something happens at all.
2021-04-15make: document two previously unknown bugs in job moderillig
2021-04-04make: rename a few functions to be more descriptiverillig
No functional change.
2021-04-04make: rename ambiguous functionsrillig
These two functions have counterparts that include the word 'Do' in their name, which is confusing. No functional change.
2021-04-03make: backport to C90rillig
In the past few months I had accidentally used C99 features in the make code. According to tools/README, tools that are used in the build system should restrict themselves to C90. This allows make to build with GCC's options "-pedantic -Wno-system-headers -Dinline= -Wno-error=cast-qual". I didn't notice anyone actively complaining though, I just wanted to see how much work this backporting would be. The identifier __func__ is still used, as in other tools. No functional change.
2021-04-03make: use C99 bool type instead of defining its ownrillig
No functional change.
2021-02-05Job_TempFile: unlink while signals blockedsjg
2021-02-05Avoid strdup in mkTempFilesjg
Require caller to pass a buffer and size if they want the tempfile not unlinked. Add Job_TempFile to handle blocking signals around call to mkTempFile, so that meta_open_filemon can use it in jobs mode.
2021-02-05make: remove unnecessary assignment in Job_Start, clean up commentsrillig
2021-02-05make: in the Var_ functions, move the scope to the frontrillig
This change provides for a more natural reading order in the code. Placing the scope first makes it immediately clear in which context the remaining parameters are interpreted. No functional change.
2021-02-04make: rename some VAR constants to SCOPErillig
The word "context" does not fit perfectly to the variables that are associate with a GNode, as the context is usually something from the outside and the variables are more like properties inherent to the GNode. The term "global context" fits even less. Since the thing where variables are looked up is commonly named a scope, use that term instead. This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL and VAR_CMDLINE, plus a few very closely related comments. These are: GNode.vars (because of line breaks) GNode_Free (dito) varname-make_print_var_on_error.mk varname-make_print_var_on_error-jobs.mk The debug message in Var_Stats is left as-is since there is no unit test for it yet. The other renamings (variable names "context", "ctxt", as well as further comments) will be done in a follow-up commit.
2021-02-03make: replace Global_AppendExpand with Global_Appendrillig
All callers with a variable name that is guaranteed to not contain a dollar sign have been converted to call Global_Append instead of the previous Global_AppendExpand. After that, Global_AppendExpand was unused, therefore it was effectively just renamed.
2021-02-03make: replace Global_SetExpand with Global_Set for constant namesrillig
2021-02-03make: use shortcut functions Global_SetExpand and Global_AppendExpandrillig
There are many places where global variables are set or appended to. To reduce clutter and code size, encode the VAR_GLOBAL in the function name. The word Expand in the function names says that the variable name is expanded. In most of the cases, this is not necessary, but there are no corresponding functions Global_Set or Global_Append yet. Encoding the information whether the name is expanded or not in the function name will make inconsistencies obvious in future manual code reviews. Letting the compiler check this by using different types for unexpanded and expanded variable names is probably not worth the effort. There are still a few bugs to be fixed, such as in SetVar, which expands the variable name twice in a row.
2021-02-01make: indent preprocessor directives consistentlyrillig
As seen in share/misc/style.
2021-02-01make: always use vfork, never forkrillig
Before compat.c 1.217, job.c 1.390 and main.c 1.504 from 2020-12-27, the exported make variables were exported from each freshly forked child process. There was no practical difference though between exporting the variables from the parent process or the child process since these two processes share the same address space, except that the forked process is very limited in what it may actually do. This limitation was violated on a regular basis. When an exported variable referred to a variable that used the :sh variable modifier, this led to a fork from within vfork, which is not allowed. Since 2020-12-27, exporting the variables is done from the main process, which prevents this situation from ever occurring. Since that day, there is no need anymore to distinguish between vfork and fork, which removes any need for the macro.
2021-02-01make: remove unused Lst_Destroyrillig
The code in job.c that seemed to use it is inside an '#if 0' block.