bugmake - Bugs: bug #63439, [Regression]...

 
 

bug #63439: [Regression] --no-builtin-variables with --warn-undefined-variables trigger warning on GNUMAKEFLAGS

Submitter:  Pekka S <pexu>
Submitted:  Tue 29 Nov 2022 10:02:55 AM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.4 Operating System:  Any
Fixed Release:  4.4.1 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 16 Oct 2023 07:29:25 PM UTC, comment #13: 

Thanks for confirming the issue I am reporting.

Could you please update the "Fixed Release: 4.4.1", as it is not actually true?

Or if it is a separate issue to the one fixed in 4.4.1, then it would probably be worth creating a new bug report for it, with a new "Fixed Release" value. Otherwise, it all gets rather confusing .

R. Diez <rdiez>
Mon 16 Oct 2023 06:41:07 PM UTC, comment #12: 

Yes, my example didn't use the -R option (--no-builtin-variables).  That's why I didn't see the problem.

As noted by Pekka S, this is already fixed in Git and the fix will be available in the next release of GNU Make.

Paul D. Smith <psmith>
Group administrator
Mon 16 Oct 2023 06:28:04 PM UTC, comment #11: 

GNUMAKEFLAGS is effectively unconditionally expanded at main.c:2086.

The warning message, should the environment variable not exist, is not suppressed for GNUMAKEFLAGS until the commit ebe0a1c9f1d1529a3f2c64d628686f500d460b0e.  Version 4.4.1 predates this.

As a workaround just define (perhaps an empty) GNUMAKEFLAGS environment variable.

# make --version
GNU Make 4.4.1
Built for x86_64-pc-msys

# make --no-builtin-variables --warn-undefined-variables
make: warning: undefined variable 'GNUMAKEFLAGS'
make: * No targets specified and no makefile found.  Stop.

# GNUMAKEFLAGS= make --no-builtin-variables --warn-undefined-variables
make: * No targets specified and no makefile found.  Stop.

Pekka S <pexu>
Mon 16 Oct 2023 02:04:07 PM UTC, comment #10: 


> Please be sure to post the output of make --version
> so we know what version of GNU Make you are using.


Sorry I forgot. I am using GNU Make 4.4.1, which I built from sources myself:

GNU Make 4.4.1
Built for x86_64-pc-linux-gnu


> Also please show a minimally reproducible example


If I somehow manage to do it, I will post it here.


> I looked at the Makefile in the directory on GitHub you pointed to and
> there is no reference to GNUMAKEFLAGS or the "help" target there
> [...]


Yes, that is what I said: The makefile does not reference GNUMAKEFLAGS at all. That is why I was surprised to see that warning. I wrote the makefile myself and I have never used variable GNUMAKEFLAGS as far as I can remember.

I am guessing that GNU Make 4.4.1 must internally query variable GNUMAKEFLAGS as a side effect when the makefile tries to use some other rule or variable. But I do not know enough to debug the exact position.

How about you try the command I posted with that makefile with GNU Make 4.3 and 4.4.1 ? You should see the warning only with 4.4.1. The makefile is actually relatively straightforward and does not check the GNU Make version itself. That is, it behaves exactly the same, no matter what GNU Make version you are using.

Regards,
  rdiez

R. Diez <rdiez>
Mon 16 Oct 2023 01:31:43 PM UTC, comment #9: 

Please be sure to post the output of make --version so we know what version of GNU Make you are using.

Also please show a minimally reproducible example: I looked at the Makefile in the directory on GitHub you pointed to and there is no reference to GNUMAKEFLAGS or the "help" target there and I didn't have the energy to go searching through the entire project looking for it.

Here is the behavior I see with GNU Make 4.4.1:


$ unset GNUMAKEFLAGS

$ make --version
GNU Make 4.4.1
Built for x86_64-pc-linux-gnu
  ...

$ echo '$(info GNUMAKEFLAGS = $(GNUMAKEFLAGS))' | make -f- --warn-undefined-variables
GNUMAKEFLAGS =
make: *** No targets.  Stop.


showing no warnings.

Paul D. Smith <psmith>
Group administrator
Sun 15 Oct 2023 09:01:16 PM UTC, comment #8: 

I don't thing this bug is fixed yet.

I am using the following makefile:

https://github.com/rdiez/DebugDue/tree/master/Toolchain

This is the command I am running:

$ make --no-builtin-variables --warn-undefined-variables help >/dev/null
make: warning: undefined variable 'GNUMAKEFLAGS'

The makefile does not reference GNUMAKEFLAGS at all.

With GNU Make 4.3 there is no such spurious warning.

R. Diez <rdiez>
Sat 24 Dec 2022 03:57:21 PM UTC, comment #7: 

I pushed a fix for this.

Paul D. Smith <psmith>
Group administrator
Sun 04 Dec 2022 04:37:02 PM UTC, comment #6: 

I think it depends a little bit on what you think the goal of the option is.  I think that the goal should be to warn when users make use of non-standard variables that are not defined.  That is, it's there to catch various typos etc.

If that's the correct definition then it seems that any variable mentioned as any sort of default or official variable in the GNU make manual, should never be reported as undefined.

The problem is that to make that true the simplest way possible, we'd need to simply define all these variables as o_default which would then change the results of running $(origin XXX) for that variable XXX.

I don't know if that matters, or not.

Paul D. Smith <psmith>
Group administrator
Sat 03 Dec 2022 04:10:23 AM UTC, comment #5: 


> Exactly how this difference comes to pass is beyond my ken, but there it is... in 4.3 the variable is empty whereas in 4.4 it is undefined.



MAKECMDGOALS is undefined in both.
make-4.3 is not reporting the undefined variable, because setting 'MAKEFLAGS += --warn-undefined-variables' in makefile has not effect in make-4.3. Try passing --warn-undefined-variables on the command line and see that make-4.3 reports the undefined variable.

i checked a few versions, down to 3.82, and they all report MAKECMDGOALS as undefined.
Do you see a reason why make should not report MAKECMDGOALS as undefined in this case?

Dmitry Goncharov <dgoncharov>
Wed 30 Nov 2022 10:15:06 PM UTC, comment #4: 

I perhaps was over-eager to chalk up my observation as being the same underlying issue.  I still think there is a regression, but I certainly misreported it.  Try this:


/tmp$ make -f- <<<$'MAKEFLAGS += --warn-undefined-variables \n $(info MAKE_VERSION: ${MAKE_VERSION}  MAKECMDGOALS: ${MAKECMDGOALS})'
/tmp/GmuYbgmA:2: warning: undefined variable 'MAKECMDGOALS'
MAKE_VERSION: 4.4  MAKECMDGOALS:
make: *** No targets.  Stop.

/tmp$ make4.3 -f- <<<$'MAKEFLAGS += --warn-undefined-variables \n $(info MAKE_VERSION: ${MAKE_VERSION}  MAKECMDGOALS: ${MAKECMDGOALS})'
MAKE_VERSION: 4.3  MAKECMDGOALS:
make: *** No targets.  Stop.


Exactly how this difference comes to pass is beyond my ken, but there it is... in 4.3 the variable is empty whereas in 4.4 it is undefined.

There certainly is an easy workaround, but for some few cases, it is a significant difference.  Alas, mine was one of them.

malcolm cook <malcook>
Wed 30 Nov 2022 06:53:40 PM UTC, comment #3: 

It's true that the same issue exists for this, but in this case it's not a regression.  It also warned in previous releases:

~$ make --version
GNU Make 4.3

~$ echo 'all:;echo $(GNUMAKEFLAGS)' | make -f- --warn-undefined-variables
echo

~$ echo 'all:;echo $(MAKECMDGOALS)' | make -f- --warn-undefined-variables
/tmp/GmXydHev:1: warning: undefined variable 'MAKECMDGOALS'
echo


I think we're going to need a more generic way to disable warnings for certain variables that should not be warned about if they're not set.

Paul D. Smith <psmith>
Group administrator
Wed 30 Nov 2022 06:43:48 PM UTC, comment #2: 

FWIW: The exact same issue is present for the variable MAKECMDGOALS.  I have reported it as #63452

malcolm cook <malcook>
Tue 29 Nov 2022 09:21:13 PM UTC, comment #1: 

Thank you for your report.

This patch runs the lookup for gnumakeflags before decode_env_switches.

(file #54041, file #54042)

Dmitry Goncharov <dgoncharov>
Tue 29 Nov 2022 10:02:55 AM UTC, original submission:  

Hi.

GNU make 4.4 always attemps to expand GNUMAKEFLAGS.  This causes warning "make: warning: undefined variable 'GNUMAKEFLAGS'" to be emitted unless the variable exists.

Reproducing this is very easy (unless there is a Makefile to go there will be an error afterwards but that is unrelated).  One shall also ensure that there is no corresponding GNUMAKEFLAGS environment variable present.

$ (unset GNUMAKEFLAGS; make --no-builtin-variables --warn-undefined-variables)
make: warning: undefined variable 'GNUMAKEFLAGS'
[...]

Typically GNUMAKEFLAGS is always set via define_default_variables() at default.c:744.  However, if --no-builtin-variables is given then default_variables is not iterated.  Also, GNUMAKEFLAGS is no longer automatically added to the environment (commit 3ec497f8) during the first decode phase at main.c:1575.

When switches are decoded again GNUMAKEFLAGS is expanded using decode_env_switches() at main.c:2074.  However, this not guarded by lookup_variable().  So when the constructed variable '$(GNUMAKEFLAGS)' is expanded variable_expand_string() complains (and rightfully so) about the missing variable.

A workaround is to always provide (an empty) GNUMAKEFLAGS environment variable.

Pekka S <pexu>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #54041:  sv63439_fix.diff added by dgoncharov (1KiB - text/x-patch)
file #54042:  sv63439_test.diff added by dgoncharov (2KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rdiez (Posted a comment)
  • -email is unavailable- added by psmith (Posted a comment)
  • -email is unavailable- added by malcook (Posted a comment)
  • -email is unavailable- added by dgoncharov (Updated the item)
  • -email is unavailable- added by pexu (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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-24 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Operating SystemNone Any
        Fixed ReleaseNone 4.4.1
        Triage StatusNone Small Effort
    2022-11-29 dgoncharov Attached File- Added sv63439_fix.diff, #54041
        Attached File- Added sv63439_test.diff, #54042

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code