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

 
 

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

Submitted by:  None
Submitted on:  Fri 15 Sep 2017 05:47:30 AM UTC  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Closed
Component Version: 4.1Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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:

Paul D. Smith <psmith>
Project 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 23 Sep 2017 06:08:08 PM UTCpsmithOpen/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1