bugmake - Bugs: bug #62118, Fix parsing of command line...

 
 

bug #62118: Fix parsing of command line options -f, --file, --makefile.

Submitter:  Dmitry Goncharov <dgoncharov>
Submitted:  Sat 26 Feb 2022 04:52:59 PM 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 Triage Status:  Medium Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 27 Feb 2022 11:10:57 PM UTC, comment #1: 

Thanks for the patches Dmitry.

When looking at the test results I noticed that we were leaving the temporary files behind if we had to re-exec, because the re-exec'd version of make didn't realize they were temporary.

I decided to fix this, rather than apply the changes you provided.  However I preserved the tests you wrote.

What I did was create a new command line option which is only used by make when it re-execs itself, to specify that the filename provided is a temporary batch file.  When the re-exec'd make sees that option it manages that file as a temporary file: it marks it as up to date and it will delete the file when it exits.  Because of this, we no longer need that extra "-o" option either.

I changed the argv updates accordingly: also I didn't try to preserve the exact command line options that the user provided.  I converted all makefile options from whatever they were (--file <foo>, --makefile <foo>, --file=<foo>, --makefile=<foo>) into simply "-f<foo>".

To allow this to be tested I added another hack :( to the test framework: if the makefile string provided to run_make_test() is the empty string then the test framework doesn't add any -f options when it invokes make.  A few tests that had used the empty string were updated to pass a blank line instead.

Paul D. Smith <psmith>
Group administrator
Sat 26 Feb 2022 04:52:59 PM UTC, original submission:  

Make fails to parse command line options -f, --file, --makefile when there is a makefile that updates itself and also makefile read from stdin with -f combined with other options.


$ cat makefile
def:;echo hello world

ifeq ($(flavor $(MAKE_RESTARTS)), undefined)
makefile: force
        $(info updating makefile)
        touch makefile

force:
endif
$ printf 'all:; $(info all)' | make --debug=b -Rf- -f makefile def
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
updating makefile
touch makefile
Re-executing[1]: make --debug=b -Rf- -f /tmp/GmtbheQ7 def -o/tmp/GmtbheQ7
GNU Make 4.3
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
Updating goal targets....
 File 'def' does not exist.
Must remake target 'def'.
make: *** No rule to make target 'def'.  Stop.
$


Notice

Re-executing[1]: make --debug=b -Rf- -f /tmp/GmtbheQ7 def -o/tmp/GmtbheQ7


Should be

Re-executing[1]: make --debug=b -Rf/tmp/GmuF8N7n -f makefile def -o/tmp/GmuF8N7n


With the patch applied

$ printf 'all:; $(info all)' | make --debug=b -Rf- -f makefile def
GNU Make 4.3.90
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
updating makefile
touch makefile
Re-executing[1]: make --debug=b -Rf/tmp/GmuF8N7n -f makefile def -o/tmp/GmuF8N7n
GNU Make 4.3.90
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Updating makefiles....
updating makefile
touch makefile
Updating goal targets....
 File 'def' does not exist.
Must remake target 'def'.
echo hello world
hello world
Successfully remade target file 'def'.
$


Dmitry Goncharov <dgoncharov>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #52937:  sv62118_test.diff added by dgoncharov (4KiB - text/x-patch)
file #52938:  sv62118_fix.diff added by dgoncharov (4KiB - 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 psmith (Posted a comment)
  • -email is unavailable- added by dgoncharov (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-02-27 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Operating SystemNone Any
        Fixed ReleaseNone 4.4
        Triage StatusNone Medium Effort
    2022-02-26 dgoncharov Attached File- Added sv62118_test.diff, #52937
        Attached File- Added sv62118_fix.diff, #52938

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code