Recursive `make` and `-j`
This technical post explores the nuances of recursive 'make' invocations in GNU Make, specifically focusing on how the jobserver handles parallelism. The author provides solutions for ensuring child processes correctly inherit build flags.
Why it matters
Provides critical technical guidance for software engineers managing complex build systems and automation workflows.
Today I looked into “recursive” invocations of make ; that is, cases in which a Makefile recipe itself invokes make . The official documentation is quite good, but since I’m working with a range of different GNU Make versions, I looked at how the behavior has changed over time, from GNU Make 3.81 to 4.3.
Basically, the issue is that if you have a recipe in your Makefile like this:
ser: make -C subdir and then you run make -j4 ser , recent versions of GNU Make will give a warning ( jobserver unavailable: using -j1 ). And you’ll lose the parallelism you wanted, because the “jobserver” (basically, the -j option) isn’t forwarded to the child make . And, incidentally, it won’t necessarily use the same make binary that you invoked; it’ll run whatever make happens to be in your path.
Get smarter about the news
Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.
Create free accountAlready have an account? Sign in