automake-commit
[Top][All Lists]
Advanced

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

[Automake-commit] [SCM] GNU Automake branch, experimental/ng/memoize-mac


From: Stefano Lattarini
Subject: [Automake-commit] [SCM] GNU Automake branch, experimental/ng/memoize-macros, created. v1.12-217-g0d7517f
Date: Sun, 13 May 2012 11:01:32 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".

http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=0d7517f51df2697bcc12c33478b33c89cc301424

The branch, experimental/ng/memoize-macros has been created
        at  0d7517f51df2697bcc12c33478b33c89cc301424 (commit)

- Log -----------------------------------------------------------------
commit 0d7517f51df2697bcc12c33478b33c89cc301424
Author: Stefano Lattarini <address@hidden>
Date:   Sat May 12 14:03:26 2012 +0200

    vars: implement make variable memoization (new function 'am__memoize')
    
    This is a preparatory patch that introduces on-demand memoization through
    the use of the new internal 'am__memoize' make function.  Rationale and a
    more detailed explanation follow.
    
    In GNU make (as well as in portable make), "recursive" variables (the
    default kind, deriving from assignments like "var = value") have their
    value recomputed every time they get expanded.
    
    Most of the time, this has no actual impact on performance, since the
    value of a recursive variable is usually either static:
    
        prefix = /usr/local
    
    or only contains references to other recursive variables with static
    values:
    
        datadir = ${prefix}/share
    
    In other cases, though, the expansion of the value might require some
    non-trivial calculation, or other time-costly operation:
    
        TESTS = $(sort LONG-LIST-OF-FILES)
        VC-VERSION = $(shell git describe)
    
    Having such operation performed over and over again (each time the
    variable is expanded) might become inefficient, sometimes intolerably
    so.
    
    "Immediate" variables (deriving from assignments like "var := value")
    are better in this respect, since their definition evaluates the LHS
    immediately, and only once.
    
    But immediate variables have their drawbacks as well.
    
    First of all, the fact that the LHS is expanded immediately means that
    the definition of immediate variables is overly sensitive to ordering,
    in that any variable referenced in the LHS must be completely defined
    before the definition of the affected immediate variable is seen.
    Ensuring this might be tricky in general, and even more so with Automake,
    which performs non-trivial reordering of make variable.
    
    Also, the LHS in an immediate variable definition is computed
    unconditionally, which might be wasteful if it is the case that only
    few of the immediate variables defined in the Makefile are actually
    going to be used in a given make invocation.
    
    So we'd like to go for a good middle ground solutions: implementing
    memoization for recursive-evaluations variable which are expected to
    be expanded often.
    
    Apparently, this is easy to do:
    
        LAZY-VAR = $(override LAZY-VAR := VALUE)$(LAZY-VAR)
    
    But alas, a bug in all the GNU make versions up to *and including* 3.82
    prevents the above to working correctly in some non-uncommon situations:
    
      <http://lists.gnu.org/archive/html/bug-make/2012-05/msg00013.html>
      <https://savannah.gnu.org/patch/?7534>
    
    Still, we *seem* to have founnd an implementation that works around the
    above issue.  Referencing again the examples above, we would now write
    something like this:
    
        memo/TESTS = $(sort LONG-LIST-OF-FILES)
        memo/VC-VERSION = $(shell git describe)
        $(call am__memoize, TESTS VC-VERSION)
    
    This API is a little more verbose and clumsy than we'd like, but since
    it apparently doesn't tickle the nasty bug referenced above, we'll stick
    with it for the moment.
    
    The idea of memoizing recursive variables stemmed from a suggestion
    by Akim Demaille:
    <http://lists.gnu.org/archive/html/automake-ng/2012-05/msg00062.html>
    
    * lib/am/header-vars.am (am__memoize): New internal function.
    (am__memoize_0): Likewise.
    * t/memoize.tap: New test, checking $(am__memoize).
    * t/spy-override.sh: New test, check that we can use the 'override'
    directive as we do in the 'am__memoize' implementation.
    
    Signed-off-by: Stefano Lattarini <address@hidden>

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU Automake



reply via email to

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