make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .ONESHELL enhancement?


From: Ralf Wildenhues
Subject: Re: .ONESHELL enhancement?
Date: Sat, 3 Oct 2009 10:12:19 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

David Boyce writes:
> I have an interest in seeing the .ONESHELL special target enhancement
> implemented, as recommended by POSIX

Testing Automake for the 1.11 release, I've had the chance to get some
experience with other make implementations that already implement a similar
optimization: some BSD make reuse shells in parallel build mode.  It may
be helpful to state a few pitfalls I've encountered, so this is FYI.

First off, the shell carries more state across recipe command lines than
just the status of the last executed command.  The Posix sh page lists some
at "Shell Execution Environment".  Specifically, several options that can be
set with "set", traps, variable settings, and the current directory are
relevant for makefiles.  Automake used to rely on
  cd $(subdir) && $(MAKE)
  $some_other_command

executing the second line in the current directory, as well as variables
not being saved across command lines.  File descriptors being redirected
are another issue.

Some of the BSD make implementations also had interesting semantics when
an earlier command line had an "exit 0" statement in it, as in
  $condition || exit 0; \
  $expensive_commands
  $cmds_to_be_run_even_with_false_condition

where the last commands would not be executed, of course without a diagnosis
or error exit.

The portability section of the Autoconf manual documents these quirks now.


Second, I may remind you that the shell && does not have precedence in the
way that one expects from C, but operates in left to right fashion and with
equal precedence to ||.  This means, connecting these two lines
  false
  echo nope || echo oops

in one shell command with && will give a different result from passing it
to two different shells.

As another minor point, constructs used to avoid shell command line length
limitations may break with this optimization.

And IME, even with this optimization in place, BSD make is noticeably
slower than GNU make without this feature, on GNU/Linux at least.

Cheers,
Ralf





reply via email to

[Prev in Thread] Current Thread [Next in Thread]