bugmake - Bugs: bug #11913, definition of target specific...

 
 

bug #11913: definition of target specific variable doesnt use correct variable set

Submitter:  None
Submitted:  Thu 10 Feb 2005 12:38:05 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  3.80 Operating System:  Any
Fixed Release:  3.81 Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 09 Jun 2005 07:20:22 PM UTC, comment #2: 

OK, I committed a fix for this bug.  It will be in the next release of GNU make.
Thanks!

Paul D. Smith <psmith>
Group administrator
Sat 21 May 2005 02:55:28 PM UTC, comment #1: 

Hm.  The latest CVS code gives an even more strange result:

Makefile:7: e = E1
Makefile:25: Test run of foreach: e = e2
Makefile:25: Test run of foreach: e = e3
Makefile:26: Inside function mkRuleForE: e = e2
Makefile:26: Inside function mkRuleForE: e = e3
Making target e2Target //e = E3
Making target e3Target //e = E3
Making target E1Target //e = E1

I see the problem in the code.  Fixing it will be interesting.  I'll try to look at it this weekend.

Paul D. Smith <psmith>
Group administrator
Thu 10 Feb 2005 12:38:05 AM UTC, original submission:  

When processing 'target: var := varvalue', make380/381b doesnt use the "current" variable set while computing var's new value. E.g. take  '$(e)target: e := $(e)', then the 1st $(e) uses the current variable set, but the 2nd $(e) may take a wrong one.
#------sample makefile-----------
.PHONY: all

all: ;

e := E1

  $(warning e = $(e))
  .PHONY: $(e)Target
  all: $(e)Target
  $(e)Target: e := $(e)
  $(e)Target: ; @echo Making target $@ //"e" = "$(e)"

e := E2

define mkRuleForE
  $(warning Inside function mkRuleForE: e = $(e))
  .PHONY: $(e)Target
  all: $(e)Target
  $(e)Target: e := $(e)
  $(e)Target: ; @echo Making target $@ //"e" = "$(e)"
endef

e := E3

$(foreach e,e2 e3,$(warning Test run of foreach: e = $(e)))
$(foreach e,e2 e3,$(eval $(value mkRuleForE)))

e := E4
#------sample makefile-end----------

Running make should now result in ...

  Making target E1Target //e = E1
  Making target e2Target //e = e2
  Making target e3Target //e = e3

... but the actual result with all my 380|381beta1 is ...

  Making target E1Target //e = E1
  Making target e2Target //e = E3
  Making target e3Target //e = E3

Workaround, e.g. inside the above makfile: make sure to use only global variables inside such definitions of target specific variable =>

define mkRuleForE
   e := $x
     # Assign from local var 'x' to global var 'e'.
     # Now only use global var:
   $(e)Target: e := $(e)
endef
....
$(foreach x,e2 e3,$(eval $(value mkRuleForE)))

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

 

CC list is empty

 

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.

 

Follow 7 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-04-01 psmith Fixed Release4.0 3.81
2005-06-09 psmith StatusNone Fixed
    Assigned toNone psmith
    Open/ClosedOpen Closed
    Component VersionNone 3.80
    Operating SystemNone Any
    Fixed ReleaseNone 4.0

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code