bugmake - Bugs: bug #48360, Environment variable doesn't loose...

 
 

bug #48360: Environment variable doesn't loose specialness, although redefined

Submitter:  Stefan Becker <stefanb>
Submitted:  Fri 01 Jul 2016 11:38:24 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Duplicate Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.2 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 26 Dec 2016 04:46:12 PM UTC, comment #2: 

It seems this is a duplicate of bug #46585.

The unique thing about this is perhaps some way to determine from within a makefile whether a make variable is exported or not; currently neither the flavor nor origin functions provide this information.  However, I don't know that it's really that useful to query this: if you want the variable to be exported you should export it, and if you want it to be guaranteed to not be exported you should unexport it... I'm not sure testing the value first is a useful thing to do.

I'm closing this as a duplicate for now but feel free to add comments if you disagree.

Paul D. Smith <psmith>
Group administrator
Fri 01 Jul 2016 05:31:33 PM UTC, comment #1: 

By "specialness", I think you mean "whether it's exported".  Adding "export CC" turns the first example into a BOOM case for me.  Adding "unexport CC" stops the second example BOOMing for me.  This seems well-behaved to me.

Martin Dorey <mdorey>
Fri 01 Jul 2016 11:38:24 AM UTC, original submission:  

A variable inherited from environment doesn't loose it's specialness, although flavor/origin don't show specialness anymore.

Test makefile:


# work arounds:
#undefine CC
#override undefine CC

$(info Origin BEFORE: $(origin CC))
$(info Flavor BEFORE: $(flavor CC))

CC = $(error BOOM!)

$(info Origin AFTER:  $(origin CC))
$(info Flavor AFTER:  $(flavor CC))

all:
        @env | grep CC || true


Test run:


$ make
Origin BEFORE: default
Flavor BEFORE: recursive
Origin AFTER:  file
Flavor AFTER:  recursive

# error case
$ CC= make
Origin BEFORE: environment
Flavor BEFORE: recursive
Origin AFTER:  file
Flavor AFTER:  recursive
Makefile:7: *** BOOM!.  Stop.

$ make CC=
Origin BEFORE: command line
Flavor BEFORE: recursive
Origin AFTER:  command line
Flavor AFTER:  recursive
MAKEFLAGS= -- CC=
CC=


In the error case CC retains its environment flavor but the contents are defined by the makefile. Thus preparing the environment for the command execution will trigger the $(error).

BTW: you can replace CC with SOME_VAR, i.e. a non-default variable, and the test case still fails the same way.

This is probably closely related to the following bugs

Stefan Becker <stefanb>

 

(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)
  • -email is unavailable- added by mdorey (Posted a comment)
  • -email is unavailable- added by stefanb (Submitted the item)
  •  

    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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-12-26 psmith StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code