bugmake - Bugs: bug #55242, Included Makefile not found, no...

 
 

bug #55242: Included Makefile not found, no rule to build it but make does not fail

Submitted by:  None
Submitted on:  Wed 19 Dec 2018 12:37:06 PM UTC  
 
Severity:  3 - Normal Item Group:  Bug
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  4.2.1 Operating System:  Any
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.

 

Sat 11 Apr 2020 12:27:54 PM UTC, comment #2: 

Here is a test.

diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index 0c63c06..f39e5ec 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -260,4 +260,16 @@ inc1:; @%s $@ && echo FOO := bar > $@
     rmfiles('inc1');
 }

+unlink('b');
+unlink('a.mk');
+run_make_test(q!
+all:; @echo hello=$(hello)
+include a.mk
+a.mk: b
+b:
+       @echo hello=world >a.mk
+!, '', 'hello=world');
+unlink('a.mk');
+unlink('b');
+
 1;

Dmitry Goncharov <dgoncharov>
Sat 11 Apr 2020 12:26:57 PM UTC, comment #1: 

Here is a patch against the current master (0c326a66c9eb3a3b5e4ab7892578b016b0590b1f).

This patch causes make to re-execute itself to read the included makefile.

diff --git a/src/remake.c b/src/remake.c
index fb237c5..4dc91d8 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -175,24 +175,30 @@ update_goal_chain (struct goaldep *goaldeps)
                     }
                   else
                     {
-                      FILE_TIMESTAMP mtime = MTIME (file);
+                      struct file *oldfile = file;
                       check_renamed (file);

-                      if (file->updated && g->changed &&
-                           mtime != file->mtime_before_update)
+                      if (file->updated && g->changed)
                         {
-                          /* Updating was done.  If this is a makefile and
-                             just_print_flag or question_flag is set (meaning
-                             -n or -q was given and this file was specified
-                             as a command-line target), don't change STATUS.
-                             If STATUS is changed, we will get re-exec'd, and
-                             enter an infinite loop.  */
-                          if (!rebuilding_makefiles
-                              || (!just_print_flag && !question_flag))
-                            status = us_success;
-                          if (rebuilding_makefiles && file->dontcare)
-                            /* This is a default makefile; stop remaking.  */
-                            stop = 1;
+                          FILE_TIMESTAMP lm = oldfile->last_mtime;
+                          FILE_TIMESTAMP mtime =
+                            lm == UNKNOWN_MTIME || lm == NONEXISTENT_MTIME ?
+                            f_mtime (oldfile, 0) : lm;
+                          if (mtime != file->mtime_before_update)
+                            {
+                              /* Updating was done.  If this is a makefile and
+                                 just_print_flag or question_flag is set (meaning
+                                 -n or -q was given and this file was specified
+                                 as a command-line target), don't change STATUS.
+                                 If STATUS is changed, we will get re-exec'd, and
+                                 enter an infinite loop.  */
+                              if (!rebuilding_makefiles
+                                  || (!just_print_flag && !question_flag))
+                                status = us_success;
+                              if (rebuilding_makefiles && file->dontcare)
+                                /* This is a default makefile; stop remaking.  */
+                                stop = 1;
+                            }
                         }
                     }
                 }

Dmitry Goncharov <dgoncharov>
Wed 19 Dec 2018 12:37:06 PM UTC, original submission:  

With the following Makefile:

.PHONY: all clean

all:;

include a.mk

a.mk: b

b:
        @touch $@
        @printf '$$(info a.mk included)' > a.mk

clean:
        @rm -f a.mk b

The first make invocation produces:

$ make
make: Nothing to be done for 'all'.

And the second make invocation:

make
a.mk included
make: Nothing to be done for 'all'.

So we are in a situation where:

  1. a makefile is included with the include directive (no -include),
  2. the included makefile is not found,
  3. make finds no rule to produce it and decides not to include it,
  4. make executes a recipe for a prerequisite of the included makefile that incidentally also produces the included makefile,
  5. as the included makefile is finally found make does not fail... but it does not read the included makefile.

This could be considered as contradictory with the documentation:

After all makefiles have been checked, if any have actually been changed, make starts with a clean slate and reads all the makefiles over again.

make should either fail or include the included makefile.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

 

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)
  •  

    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
    2020-04-11 dgoncharov Attached File- => Added sv_55242_let_included_files_be_byproduct_of_unrelated_rules.diff, #48811
        Attached File- => Added sv_55242_let_included_files_be_byproduct_of_unrelated_rules_test.diff, #48812

    Back to the top


    Powered by Savane 3.5