Commit graph

12 commits

Author SHA1 Message Date
Dan Willemsen
f0e2986cbf Wait for children to exit in makeparallel
This is a partial revert to the last makeparallel change, since now we
were being killed by the signal before waiting for our child to exit. So
instead of not installing the handlers, only pass the signal along if
it's a SIGTERM.

Bug: 35214134
Test: Ensure that we're still only getting one signal for SIGINT
Test: Ctrl-C, ensure that all the soong_ui lines are before the make
      error line.
Change-Id: I26fff9483a3abfd79ceb5a9ea47e3f7572d9e923
2017-02-21 17:53:35 -08:00
Dan Willemsen
c6a900bee1 Prevent duplicate signals from makeparallel
As part of the soong_ui effort, we noticed that we'd sometimes see
multiple SIGINTs from a single ctrl-c from a user. ctrl-c sends a SIGINT
to the entire process group, so make, makeparallel, soong_ui, and all of
its children would get a signal. Since makeparallel was passing it along
to it's child, soong_ui would get two signals.

So instead, follow what Make does and only pass along SIGTERM. Assume
that all other signals went to the entire process group.

Bug: 35214134
Test: Send SIGINT to process group, check in makeparallel's child for
more than one signal received.
Change-Id: I5b2a77ad0fcebbaa5087439948e71bf3b541061a
2017-02-21 13:50:12 -08:00
Colin Cross
524c868107 Don't pass empty arguments to ninja
Passing an empty argument in argv to ninja results in an error:
ninja: error: empty path

Don't add jarg to the argument list if it is empty.

Bug: 34392351
Test: m -j
Change-Id: I39c8998c79b09835650628e1413ae7625cdbc555
2017-01-18 21:12:28 -08:00
Colin Cross
ba55c623cb Convert -j to a reasonable parallelism for kati
When running makeparallel in non-ninja mode, which is used when running
kati with USE_GOMA=true, convert -j to a reasonable parallelism value
the same way ninja does.

Bug: 34392351
Test: make -C build/make/tools/makeparallel makeparallel_test
Change-Id: I9aee4dd2a3b0f2b1c2c10087be83f7b2b06f4368
2017-01-18 14:50:50 -08:00
Colin Cross
49c45aecc4 Propagate signals through makeparallel
Set up a signal handler in makeparallel that will forward SIGHUP,
SIGINT, SIGQUIT, and SIGTERM to the child process.

Bug: 31907490
Test: m -j & killall make; pgrep -a ninja
Test: make makeparallel_test
Change-Id: I306e5335ed1b2c7056804d5da377a2f283877f30
2016-10-03 15:33:11 -07:00
Colin Cross
8f9a53258b makeparallel: reset make's unlimited stack
make 3.81 sets its own stack size to be unlimited, but accidentally
leaves it unlimited for all child processes.  If it is unlimited, reset
it back to a reasonable default (8MB).

See http://savannah.gnu.org/bugs/?22010

Change-Id: Ieb0289823f12a421b59d8ab5292d3df3c6dfc27e
2016-04-06 17:59:14 -07:00
Colin Cross
d8f0d68b78 makeparallel: unset MAKEFLAGS and MAKELEVEL
makeparallel inherits values for MAKEFLAGS and MAKELEVEL from make
through the environment, but they should not be propagated to the child
process in case the child process tries to run make again.

Change-Id: I4c5df10ea8055cd1f1f61a892d5b1a7acb287bbb
2016-02-05 00:10:20 -08:00
Dan Willemsen
3f60c4b6c0 Allow building kati & makeparallel with soong
This uses far fewer hacks in order to build these host tools, but will
require more libraries(libc++,etc) from unbundled and stripped down
branches.

Once this becomes the only option, all builds will happen after soong
runs. Then the toolchain / global cflags information will be able to be
moved from make to soong (and exported back to make).

Change-Id: I270b1d92bcef28a96fbc3ec9910d9bd0c101ac0f
2016-01-13 13:08:29 -08:00
Colin Cross
2862458bbb makeparallel: print path on exec failure
If ninja is missing makeparallel prints an unhelpful error:
out/host/linux-x86/bin/makeparallel: exec failed: No such file or directory
which suggests that makeparallel is what is missing, not what is
reporting the error.  Print the path passed to exec as well.

Change-Id: Ic04c1cde6da9c3a974b5c43e3fb3bdb6da6605f7
2016-01-11 13:43:27 -08:00
Colin Cross
466ea35202 makeparallel: prepend flags to ninja command line
Ninja stops parsing top level options after -t is used to select a
tool.  Put any inserted command line options at the beginning of the
command.

Change-Id: I2ba903143366aaded63e21d749476248617c8962
2015-10-20 17:05:49 -07:00
Colin Cross
69047fab7e makeparallel: improve support for wrapping ninja
Allow makeparallel to pass better -j and -k arguments to ninja if the
first argument to makeparallel is --ninja.  Uses getopt to parse
MAKEFLAGS to get values for --jobserver-fds, -k, and -j, and uses the
result to not pass any -j argument to ninja for make -j with no number,
and pass -k0 to ninja for make -k.

Also improve the test makefile to provide many more tests.

Bug: 24199503
Change-Id: Id6481430f77e9e952213be58a98fe78c46ee5d6a
2015-09-18 15:02:40 -07:00
Colin Cross
a55544875a Implement makeparallel
makeparallel communicates with the GNU make jobserver
(http://make.mad-scientist.net/papers/jobserver-implementation/)
in order claim all available jobs, and then passes the number of jobs
claimed to a subprocess with -j<jobs>.

Change-Id: Id41a2d81e0d835517da8ba52c818c763fc455c14
2015-09-14 14:33:50 -07:00