make/tests/scripts/variables
Paul Smith 16e14b4114 Disable the jobserver in non-recursive children
Savannah issues such as SV 57242 and SV 62397 show how passing
references to closed file descriptors via the --jobserver-auth option
in MAKEFLAGS can lead to problematic outcomes.

When computing the child environment for a non-recursive shell, add
an extra option to MAKEFLAGS to disable the file descriptors for the
jobserver.

Unfortunately this doesn't modify the value of the make variable
MAKEFLAGS, it only modifies the value of the sub-shell environment
variable MAKEFLAGS.  This can lead to confusion if the user is not
considering the distinction.

* src/makeint.h: Publish the jobserver-auth value.  Add a global
definition of the name of the command line option.
* src/os.h (jobserver_get_invalid_auth): New function to return a
string invalidating the jobserver-auth option.
* src/w32/w32os.c (jobserver_get_invaid_auth): Implement it.  On
Windows we use a semaphore so there's no need to invalidate.
* src/posixos.c (jobserver_parse_auth): If we parse the invalid
auth string, don't set up the jobserver.
(jobserver_get_invalid_auth): Return an invalid option.
* src/variable.h (target_environment): Specify if the target
environment is for a recursive shell or non-recursive shell.
* src/variable.c (target_environment): Move checking for MAKELEVEL
into the loop rather than doing it at the end.
Along with this, check for MAKEFLAGS and MFLAGS, and update them
based on whether we're invoking a recursive or non-recursive child,
and also on whether it's necessary to invalidate the jobserver.
* src/function.c (func_shell_base): Shell functions can never be
recursive to pass 0 to target_environment().
* src/job.c (start_job_command): Specify whether the child is
recursive when calling target_environment().
* src/main.c: Export jobserver_auth.  sync_mutex doesn't need to
be exported.  Use the global definition for the option name.
* tests/scripts/variables/MAKEFLAGS: Add tests for $MAKEFLAGS.
2022-07-30 18:40:28 -04:00
..
automatic [SV 62324] Simplify set_file_variables by passing in the stem 2022-04-24 10:39:32 -04:00
CURDIR
DEFAULT_GOAL
define Add support for the POSIX :::= assignment operator. 2021-09-20 00:29:31 -04:00
EXTRA_PREREQS Support the .EXTRA_PREREQS special variable 2020-01-03 02:08:59 -05:00
flavors Add support for the POSIX :::= assignment operator. 2021-09-20 00:29:31 -04:00
GNUMAKEFLAGS Don't add GNUMAKEFLAGS to the environment 2022-06-19 14:35:27 -04:00
INCLUDE_DIRS [SV 45211] Parse MAKEFLAGS immediately when it's reset 2021-09-05 21:08:59 -04:00
LIBPATTERNS
MAKE
MAKE_RESTARTS * tests/scripts/variables/MAKE_RESTARTS: Remove TAB chars 2022-02-27 18:01:13 -05:00
MAKECMDGOALS
MAKEFILES
MAKEFLAGS Disable the jobserver in non-recursive children 2022-07-30 18:40:28 -04:00
MAKELEVEL
MFILE_LIST
negative Add support for the POSIX :::= assignment operator. 2021-09-20 00:29:31 -04:00
private
SHELL Support "unexport" in target-specific variables. 2020-11-29 17:57:33 -05:00
special
undefine [SV 59870] define/undefine prerequisites are not target-specific vars 2021-03-14 16:35:38 -04:00