Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnu make -j8 not running things in parallel

I'm running an Android NDK make file using ndk-build which is just normal gnu make that runs with the google makefile templates. I'm running it with ndk-build -j8 and I can confirm that indeed the make command line runs with -j8
The compilation however proceeds to compile my source files one by one, never running clang++ more that once at a time. This was not always like that. Just a few days ago I used the same exact scripts and it used all 8 cores and was much faster.
What can possibly make gnu make not respect -j8 all of a sudden?
Is there a way to make gnu make produce any explanatory information about this? The various --debug options don't seem to talk about it.

Running from OSX 10.10.5, version of gnu make is 3.81

Update: If I do ndk-build clean before, the build I do immediately after does run on all 8 cores. Subsequent builds done a day after return to only use 1 core

like image 772
shoosh Avatar asked Feb 19 '26 19:02

shoosh


2 Answers

You can check that make is actually make (use which make and type make to see whether there are wrapping scripts, functions or aliases involved).

This could be also be at play: Communicating options to a s submake:

The -j option is a special case (see Parallel Execution). If you set it to some numeric value N and your operating system supports it (most any UNIX system will; others typically won’t), the parent make and all the sub-makes will communicate to ensure that there are only N jobs running at the same time between them all. Note that any job that is marked recursive (see Instead of Executing Recipes) doesn’t count against the total jobs (otherwise we could get N sub-makes running and have no slots left over for any real work!)

And relevant to you:

If your operating system doesn’t support the above communication, then -j 1 is always put into MAKEFLAGS instead of the value you specified. This is because if the -j option were passed down to sub-makes, you would get many more jobs running in parallel than you asked for. If you give -j with no numeric argument, meaning to run as many jobs as possible in parallel, this is passed down, since multiple infinities are no more than one.

like image 159
sehe Avatar answered Feb 21 '26 07:02

sehe


The answers above have given the known links to issues regarding your question.

Without knowing more about your setup, I can only guess:

Perhaps, somehow, running your build script is affecting MAKEFLAGS.

You could try directly passing the number of jobs into the ndk-build script. Edit your ndk-build script like so:

$GNUMAKE -j8 -f $YourProgramDir/.../build-local.mk "$@"

like image 25
wizurd Avatar answered Feb 21 '26 09:02

wizurd