[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #60595] make doesn't always restart when a makefile is rebuilt
From: |
André Chalella |
Subject: |
[bug #60595] make doesn't always restart when a makefile is rebuilt |
Date: |
Thu, 13 May 2021 03:32:34 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 |
URL:
<https://savannah.gnu.org/bugs/?60595>
Summary: make doesn't always restart when a makefile is
rebuilt
Project: make
Submitted by: andrechalella
Submitted on: Thu 13 May 2021 07:32:32 AM UTC
Severity: 3 - Normal
Item Group: Bug
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Component Version: 4.3
Operating System: Any
Fixed Release: None
Triage Status: None
_______________________________________________________
Details:
GNU make manual, in section 3.5 How Makefiles Are Remade
<https://www.gnu.org/software/make/manual/html_node/Remaking-Makefiles.html>,
says:
> 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.
I found the hard way this is not _quite_ true. If, during makefile rebuilding
("Updating makefiles...."), the following conditions are met, then make won't
restart, carrying on as if nothing was updated.
0 One makefile is rebuilt as a *prerequisite* of another makefile;
0 The *goal* makefile of #1 is not rebuilt (e.g. recipe executes but exits
without modifying the file, so its mtime doesn't change).
I know this may seem an obscure corner case and maybe it is, and I apologize
if that's the case. I don't have much experience with "real world" makefiles;
I write mine based on the manual (which is excellent) and the rebuild-restart
functionality has made possible for me to write a simple yet powerful
dependency resolver for Fortran <https://github.com/andrechalella/fMakefile>.
The thing is, it stopped working when I incidentally changed "include
$(files2) $(files1)" to "include $(files1) $(files2)" somewhere in it, and it
took me a couple days, many rounds of "make -d" and reading the source to
understand why.
(in the example line above, $(files1) are distant prerequisites to $(files2))
I can and will (at least for now) keep the original, working order, but it is
kind of the "wrong" order of files logic-wise, plus it only works because make
rebuilds makefiles in the reversed order in which they were included. I know
why make rebuilds in reverse and it's a valid reason, but as Paul said in
another answer it is an implementation detail and I wouldn't like to rely on
it.
I can provide a minimal working example if the issue is not clear enough.
I see two possible solutions:
0 In main.c:2272 (case us_none) check current mtimes against makefile_mtimes[]
and jump to re_exec if any is newer.
0 If it must not be fixed in code, a small update on the docs to specify that
makefiles rebuilt as prerequisites do not count for restarting make.
Thanks,
André
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60595>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #60595] make doesn't always restart when a makefile is rebuilt,
André Chalella <=