bugmake - Bugs: bug #56301, Mandatory/Optional include files...

 
 

bug #56301: Mandatory/Optional include files and pattern rule with multi-targets

Submitter:  Masahiro Yamada <masahiroy>
Submitted:  Fri 10 May 2019 04:33:49 PM UTC
   
 
Severity:  3 - Normal Item Group:  Bug
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  4.2.1 Operating System:  None
Fixed Release:  4.4 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 20 Sep 2022 12:59:53 PM UTC, comment #5: 

Thanks Dmitry.  I used this change but I didn't check for -k because I think that if a makefile that needs to be included fails to be built, that make should stop even if -k was given.  I added a few more tests.

Paul D. Smith <psmith>
Group administrator
Sat 11 Apr 2020 12:42:51 PM UTC, comment #4: 

This test is the same as the one submitted earlier, but unlinks the included makefiles.

diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index 0c63c06..4401622 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -260,4 +260,15 @@ inc1:; @%s $@ && echo FOO := bar > $@
     rmfiles('inc1');
 }
 
+# Stop when cannot include a makefile.
+# https://savannah.gnu.org/bugs/?56301.
+unlink('inc_a.mk');
+unlink('inc_b.mk');
+run_make_test(q!
+all:; @echo hello
+include inc_a.mk
+-include inc_b.mk
+%_a.mk %_b.mk:; @false
+!, '', "#MAKE#: Failed to remake makefile 'inc_a.mk'.", 512);
+
 1;

Dmitry Goncharov <dgoncharov>
Sat 11 Apr 2020 12:39:04 PM UTC, comment #3: 

These patches are against the current master (0c326a66c9eb3a3b5e4ab7892578b016b0590b1f).

Dmitry Goncharov <dgoncharov>
Fri 10 Apr 2020 08:59:41 PM UTC, comment #2: 

Here is a test.
diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index 0c63c06..2281ee4 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -260,4 +260,13 @@ inc1:; @%s $@ && echo FOO := bar > $@
     rmfiles('inc1');
 }
 
+# Stop when cannot include a makefile.
+# https://savannah.gnu.org/bugs/?56301.
+run_make_test(q!
+all:; @echo hello
+include inc_a.mk
+-include inc_b.mk
+%_a.mk %_b.mk:; @false
+!, '', "#MAKE#: Failed to remake makefile 'inc_a.mk'.", 512);
+
 1;

Dmitry Goncharov <dgoncharov>
Fri 10 Apr 2020 08:58:34 PM UTC, comment #1: 

Here is a fix.

diff --git a/src/main.c b/src/main.c
index bcba2d1..5c1a7da 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2305,6 +2305,8 @@ main (int argc, char *argv, char *envp)
                         any_remade |= (mtime != NONEXISTENT_MTIME
                                        && mtime != makefile_mtimes[i]);
                         makefile_status = MAKE_FAILURE;
+                        if (!keep_going_flag)
+                          any_failed = 1;
                       }
                   }
                 else

Dmitry Goncharov <dgoncharov>
Fri 10 May 2019 04:33:49 PM UTC, original submission:  

I see a problem when
a pattern rule with multiple targets
are responsible for creating included files,
some of which are mandatory, and the
others are optional.

I attached two test cases.

Both of them include two files, inc_a.mk and inc_b.mk

The difference between the two is:

For Makefile1, inc_a.mk is optional, inc_b.mk is mandatory.
For Makefile2, inc_a.mk is mandatory, inc_b.mk is optional.

inc_a.mk and inc_b.mk are supposed to be
simultaneously created by a pattern rule
(but it always fails).


The behavior is completely different
between Makefile1 and Makefile2.


$ make -f Makefile1
Makefile1:1: starting
target in question: inc_b.mk
false
Makefile1:8: inc_b.mk: No such file or directory
make: * [Makefile1;12: inc_b.mk] Error 1


Make was terminated immediately when
it failed to create inc_b.mk



$ make -f Makefile2
Makefile2:1: starting
target in question: inc_b.mk
false
make: Failed to remake makefile 'inc_a.mk'.
hello


This also failed to create included files,
and showed "Failed to remake" message,
but continued running, then executed the 'all' target.

I think the reason is the target in question
in the pattern rule is inc_b.mk, which is
an optional include file.

As far as I examined, the last included file
becomes the target in question of the pattern rule.

So, I see some sort of sense in this behavior.

However, Makefile2 failed to create the mandatory
include file, inc_a.mk, so Make cannot (should not)
continue parsing the Makefile.

One way to fix this is,
the target in question should be chosen
from mandatory include files over optional ones.

Masahiro Yamada <masahiroy>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46891:  Makefile1 added by masahiroy (163B - application/octet-stream)
file #46892:  Makefile2 added by masahiroy (163B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2022-09-20 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Component VersionNone 4.2.1
        Fixed ReleaseNone 4.4
        Triage StatusNone Small Effort
    2019-12-27 psmith Item GroupNone Bug
    2019-05-10 masahiroy Attached File- Added Makefile1, #46891
        Attached File- Added Makefile2, #46892

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code