bugmake - Bugs: bug #60538, Environment variable overrides...


bug #60538: Environment variable overrides explicit assignment

Submitted by:  Shareef Jalloq <sjalloq>
Submitted on:  Thu 06 May 2021 02:24:37 PM UTC  
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  4.3 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None

Add a New Comment (Rich Markup)

You are not logged in

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


Thu 06 May 2021 04:01:08 PM UTC, comment #5: 

As Martin says, if the variable is set ON THE COMMAND LINE, it will absolutely take precedence over the setting in a makefile variable (unless overridden with override).

But, you said you has set this IN THE ENVIRONMENT which is very different; values set in the environment should not take precedence over values set in the makefile (as long as -e is not set).

So, you'll have to investigate why/how this variable assignment is appearing in your command line (in MAKEFLAGS).

I'm going to close this; you can continue to post here but better would be to discuss on the mailing list, until/unless we discover a bug.


Paul D. Smith <psmith>
Project Administrator
Thu 06 May 2021 03:57:51 PM UTC, comment #4: 

Looks like it's working as designed to me.  If I do:

$ make -n -p -- TESTNAME=test_mtp_remap

... like in your original post:

> make blah TESTNAME=mytest1

... then I see that:


... where:

MAKEOVERRIDES = ${-*-command-variables-*-}

... and:

-*-command-variables-*- := TESTNAME=test_mtp_remap

https://www.gnu.org/software/make/manual/html_node/Override-Directive.html explains what you would need to do to override such a command line assignment.

Martin Dorey <mdorey>
Thu 06 May 2021 03:24:34 PM UTC, comment #3: 

Ah, sorry, should have thought about a mailing list.  I can move it there if this doesn't help:

w -- TESTNAME=test_mtp_remap

Not modifying MAKEFLAGS as far as I know and using -e explicitly doesn't have any effect on the variable.

Shareef Jalloq <sjalloq>
Thu 06 May 2021 02:58:35 PM UTC, comment #2: 

Sounds like this discussion would be better on the -email is unavailable- or -email is unavailable- mailing lists, at least until we determine there's a real bug.

The only way this can happen that I know of (barring bugs) is by adding the -e make command line option which causes environment variables to override make variables.

Can you print the $(MAKEFLAGS) variable in your makefile to see if it's set?  Are you modifying MAKEFLAGS anywhere in your setup, that might be done incorrectly so make thinks you want to set the -e option?

Paul D. Smith <psmith>
Project Administrator
Thu 06 May 2021 02:32:01 PM UTC, comment #1: 

I've just tried running the make command using env -i and that prevents the make variable from being overridden but obviously I lose the environment required for the test.

env -i make <target>

Shareef Jalloq <sjalloq>
Thu 06 May 2021 02:24:37 PM UTC, original submission:  

I'm not sure what is going on here as I'm not able to create a testcase that highlights the same failure.  This issue only happens when calling Make from a Python subprocess running inside a Cocotb test (a simulation framework for RTL simulation).

I have a pretty simple Makefile where I set a variable TESTNAME using an explicit assignment:


and what I'm seeing is that variable being overridden from a matching environment variable.

I'm calling Make to run a simulation (make blah TESTNAME=mytest1) and from within that simulation, the Python environment makes a second call to Make using subprocess in order to build a dependency.  That dependency (TESTNAME=mytest2) isn't being built because the TESTNAME is overridden to be mytest1.

I've built a number of testcases to check this and can't replicate the failure.

Also, if I use any other environment variable name aside from TESTNAME, it works as expected.  So is there something special about that variable name?  It's not reserved or something?

What mechanism could there be that would allow an explicit assignment be overridden like this?


Shareef Jalloq <sjalloq>


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

Attach Files:

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

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

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-06 psmith StatusNone => Not A Bug
        Open/ClosedOpen => Closed

    Back to the top

    Powered by Savane 3.7