bugmake - Bugs: bug #24251, Random error including rebuilt...

 
 

bug #24251: Random error including rebuilt makefiles

Submitted by:  None
Submitted on:  Fri 12 Sep 2008 03:07:19 PM UTC  
 
Severity:  3 - Normal Item Group:  Bug
Status:  Not A Bug Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Component Version:  3.81 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.

 

Tue 02 Jun 2009 04:32:23 AM UTC, comment #5: 

This is not a bug, although I'm not sure Martin's comment gets at the heart of it.  What happens is that you're prerequisite (ECOS_DIR) is a directory, not a file.  It's almost ALWAYS wrong to list a directory as a prerequisite in a makefile.   Makefiles work off of last modification times, and the last modification time for a directory is not set the same way as for a file: directory modification times are updated only when the directory itself is modified, NOT when files within the directory are modified.  Modifying a directory means that you add, remove, or rename a file in that directory.  Just changing an existing file in the directory does not modify the directory timestamp.

Since make has no way of knowing that you really modified ECOS_MAKE in the rule (you've only told make that you modified ECOS_DIR), and you did not provide any recipe to update ECOS_MAKE, make will assume that ECOS_MAKE was not modified unless ECOS_DIR was modified.

By adding the empty recipe here, you are forcing make to believe that ECOS_MAKE could have been modified, so make will check the timestamp on ECOS_MAKE, see that it was updated, and things work as you like.

Nevertheless I reiterate: nothing good can come of listing directories in normal prerequisite rules.

Paul D. Smith <psmith>
Project Administrator
Mon 15 Sep 2008 09:52:34 PM UTC, comment #4: 

Thanks Martin for your assistance, adding the semi-colon after the prerequisite fixes my problem.

I'm not sure I understand the difference, I expect a pre-requisite to be completely built before it is included, but I'll worry about my lack of understanding later.

To make administrators,
If the lack of the semi-colon was an error in my makefile, then this bug can be closed and sorry for the inconvenience.
Even if there is still a bug in make, the severity of this bug can be lowered since there's a work-around (at least for me).

Anonymous
Mon 15 Sep 2008 05:48:37 PM UTC, comment #3: 

I reproduced the behavior you saw without svn by replacing the end of the makefile with:

$(ECOS_MAKE) : $(ECOS_DIR)

$(ECOS_DIR) :
mkdir -p $(ECOS_DIR)/include/pkgconf/
{ \
echo 'ECOS_GLOBAL_CFLAGS = -mcpu=arm7tdmi -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -finit-priority'; \
echo 'ECOS_GLOBAL_LDFLAGS = -mcpu=arm7tdmi -Wl,--gc-sections -Wl,-static -g -nostdlib'; \
echo 'ECOS_COMMAND_PREFIX = arm-elf-'; \
} > $(ECOS_MAKE)

Looking at the manual, "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".  That suggests that it should re-evaluate all these variables.  But using "make --debug=all" suggests that make isn't restarting.

Looking at the source code, it seems to be checking whether the modification time on the makefile has changed:

                      if (file->updated && g->changed &&
                           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.  */

But makefile doesn't give a rule for updating $(ECOS_MAKE).  It just says that it depends on $(ECOS_DIR).  Telling make that it needn't do anything to update $(ECOS_MAKE) once it's updated $(ECOS_DIR), by changing:

$(ECOS_MAKE) : $(ECOS_DIR)

To:

$(ECOS_MAKE) : $(ECOS_DIR);

Fixes the problem.

Martin Dorey <mdorey>
Mon 15 Sep 2008 03:49:36 PM UTC, comment #2: 

I don't think this is a duplicate of https://savannah.gnu.org/bugs/?102

This issue isn't about these minor warnings in the output
makefile:10: ecos/include/pkgconf/ecos.mak: No such file or directory
makefile:11: sub/makefile: No such file or directory

This issue is that although make will sometimes build an included makefile it will then ignore the contents of the included makefile.

Anonymous
Fri 12 Sep 2008 04:04:41 PM UTC, comment #1: 
Martin Dorey <mdorey>
Fri 12 Sep 2008 03:07:19 PM UTC, original submission:  

I'm trying to automatically build (checkout from svn) an included makefile. The build always succeeds, but the variables set in the included makefile don't always get set.

I can make it work by building and including a file I don't care for, but that doesn't seem like a proper solution. (see example)

The same problem occurs with both make 3.79.1 on a Linux machine and make 3.81 on Cygwin/XP machine.

Am I expecting more from make than I should be?

I'm attaching a log showing a trimmed down version of the makefile and the included makefile along with results showing the inconsistent behaviour. Unfortunately you won't be able to access my svn repository, but hopefully you'll be able to recreate the problem some other way.

The $(SUB_CMD_PREFIX) variable defined in $(SUB_MAKE) is always set successfully, but the $(ECOS_COMMAND_PREFIX) defined in $(ECOS_MAKE) is only set if $(SUB_MAKE) also needs to be built.
i.e. there seems to be a race condition rather than waiting for the dependency to complete.

Sorry that this is a duplicate of http://savannah.gnu.org/support/index.php?106466, but I haven't received any response there.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #16470:  make.log added by None (2KiB - application/octet-stream - log of session showing makefile, usage results and version info)

 

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 mdorey (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-06-02 psmith PrivacyPrivate => Public
        Open/ClosedOpen => Closed
    2009-06-02 psmith StatusNone => Not A Bug
        PrivacyPublic => Private
    2008-09-12 None Attached File- => Added make.log, #16470

    Back to the top


    Powered by Savane 3.6