manpagez: man pages & more
info autoconf
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.10 Parallel Make

Support for parallel execution in make implementation varies. Generally, using GNU make is your best bet. When NetBSD make is invoked with ‘-jN’, it will reuse the same shell for multiple commands within one recipe. This can have unexpected consequences.(6) For example, change of directories or variables persist between commands:

 
all:
        @var=value; cd /; pwd; echo $$var; echo $$$$
        @pwd; echo $$var; echo $$$$

may output the following with make -j1:

 
--- all ---
/
value
32235
/
value
32235

while without ‘-j1’, or with ‘-B’, the output looks less surprising:

 
/
value
32238
/tmp

32239

Another consequence of this is that, if one command in a recipe uses exit 0 to indicate a successful exit, the shell will be gone and the remaining commands of this recipe will not be executed.

The above example also shows additional status output NetBSD make produces in parallel mode for targets being updated.

Furthermore, parallel NetBSD make will route standard error from commands that it spawns into its own standard output, and may remove leading whitespace from output lines.

You can avoid these issues by using the ‘-B’ option to enable compatibility semantics. However, that will effectively also disable all parallelism as that will cause prerequisites to be updated in the order they are listed in a rule.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© manpagez.com 2000-2018
Individual documents may contain additional copyright information.