jobserver: allow overriding the parent jobserver in a subprocess.
Previously, if you passed a -j option to a redo process in a redo or make process hierarchy with MAKEFLAGS already set, it would ignore the -j option and continue using the jobserver provided by the parent. With this change, we instead initialize a new jobserver with the desired number of tokens, which is what GNU make does in the same situation. A typical use case for this is to force serialization of build steps in a subtree (by using -j1). In make, this is often useful for "fixing" makefiles that haven't been written correctly for parallel builds. In redo, that happens much less often, but it's useful at least in unit tests. Passing -j1 is relatively harmless (the redo you are starting inherits a token anyway, so it doesn't create any new tokens). Passing -j > 1 is more risky, because it creates new tokens, thus increasing the level of parallelism in the system. Because this may not be what you wanted, we print a warning when you pass -j > 1 to a sub-redo. GNU make gives a similar warning in this situation.
This commit is contained in:
parent
e247a72300
commit
19049d52fc
3 changed files with 38 additions and 17 deletions
|
|
@ -79,7 +79,7 @@ def main():
|
|||
state.init(targets)
|
||||
if env.is_toplevel and not targets:
|
||||
targets = ['all']
|
||||
j = atoi(opt.jobs or 1)
|
||||
j = atoi(opt.jobs)
|
||||
if env.is_toplevel and (env.v.LOG or j > 1):
|
||||
builder.close_stdin()
|
||||
if env.is_toplevel and env.v.LOG:
|
||||
|
|
@ -98,7 +98,7 @@ def main():
|
|||
'not redoing.\n') % f.nicename())
|
||||
state.rollback()
|
||||
|
||||
if j < 1 or j > 1000:
|
||||
if j < 0 or j > 1000:
|
||||
err('invalid --jobs value: %r\n' % opt.jobs)
|
||||
jobserver.setup(j)
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue