bugmake - Bugs: bug #52028, Preventing infinite recursions...

 
 

bug #52028: Preventing infinite recursions when make is invoked from recipes

Submitter:  None
Submitted:  Fri 15 Sep 2017 05:47:30 AM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 23 Sep 2017 06:08:08 PM UTC, comment #1: 

I don't think adding a new function is appropriate for this.  It's simpler, IMO, to use the existing "-o" / "--old-file" command line option and arrange for it to be passed down.  For example something like:


$ cat Makefile
export OLDFILES

a :
        echo a1
        $(eval OLD_FILES += -o$@)
        $(MAKE) $(OLD_FILES) b
        echo a2

b :
        echo b1
        $(eval OLD_FILES += -o$@)
        $(MAKE) $(OLD_FILES) a
        echo b2

$ make
echo a1
a1
make  -oa b
echo b1
b1
make  -oa -ob a
make[2]: 'a' is up to date.
echo b2
b2
echo a2
a2


Paul D. Smith <psmith>
Group administrator
Fri 15 Sep 2017 05:47:30 AM UTC, original submission:  

Consider this Makefile:

a :
echo a1
$(MAKE) b
echo a2

b :
echo b1
$(MAKE) a
echo b2

Building either a or b will cause infinite recursion.

It is possible to work around this with a template, similar to the following:

SHELL := bash
exportable = $(shell echo $(1) | sed 's%[^[:alnum:]_]%_%g')
define make
$(eval d := $(strip $(call exportable,$(1))))
$(eval f := $(if $(strip $(2)), -f $(realpath $(strip $2))))
if [ "$$_making_$(d)" != "$@" ]; then \
export making$(d)="$@"; \
$(MAKE) $(f) "$(strip $(1))"; \
fi


a :
echo a1
$(call make,b)
echo a2

b :
echo b1
$(call make,a)
echo b2

Running with -s produces:
a1
b1
a1
a2
b2
a2

Making b instead:
b1
a1
b1
b2
a2
b2


This is an enhancement/optional feature request:

Add a command $(make ...) or modify interpretation of $(MAKE) in recipes, which functions in a way similar to the work around template provided.

The template is highly non-portable, uses regular expressions and invokes a shell, pollutes environment variables without cleaning up, and it is very hard to understand (it took several hours of experimenting to come up with).

Reasons to deny the request that I can think of:

It may be considered "bad design" to specify dependencies within a recipe. The above example is basically a circular dependency.

Counter arguments:

GNU Make allows recursion which therefore exposes an infinite recursion bug. A circular dependency specified normally will not cause an infinite recursion. GNU Make should treat these the same way.

The dependency specified by a recursive make is different to a normal dependency in that it allows for control over ordering of recipe instructions. This may open up more patterns for make to be used more heuristically (dependencies do not need to be rigidly pre-determined).

I'd quite like to try implementing this feature because I have specific use cases for it.

Sam Moore
<smoore@elementengineering.com.au>

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-23 psmith Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-aa77.
    Corresponding source code