summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2022-10-02 10:18:21 -0400
committerPaul Smith <psmith@gnu.org>2022-10-02 10:18:21 -0400
commit7296991d6c2feec34099934af75c35b5c0a47e3a (patch)
tree8d0be5d6a99ecfe900dcf64c04345f6983b0d983 /src
parentd51ac701227e89cbab8c88668d71198ff52f92a7 (diff)
downloadmake-git-7296991d6c2feec34099934af75c35b5c0a47e3a.tar.gz
[SV 63098] Temporarily revert the change to pattern rule behavior
The fix for SV 12078 caused a backward-compatibility issue with some makefiles. In order to allow users to resolve this issue, revert that change for this release cycle: it will be reinstated in the next release cycle. Introduce a warning if we detect that the recipe of a multi-target pattern rule doesn't create all the targets. * NEWS: Announce the future backward-incompatibility. * doc/make.texi (Pattern Intro): Describe the behavior and that it will change in the future. * src/remake.c (check_also_make): Check for also_make targets that were not created and generate a warning. (update_goal_chain): Call the new function. (check_dep): Ditto. (update_file_1): Defer implicit rule detection until after we check all the also_make files (as it used to be). * tests/scripts/features/patternrules: Add tests of the new warning. Skip the tests for SV 12078.
Diffstat (limited to 'src')
-rw-r--r--src/remake.c61
1 files changed, 42 insertions, 19 deletions
diff --git a/src/remake.c b/src/remake.c
index a97431b9..e536c8b5 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -78,6 +78,24 @@ static FILE_TIMESTAMP name_mtime (const char *name);
static const char *library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr);
+static void
+check_also_make (const struct file *file)
+{
+ /* If the target was created by an implicit rule, and it exists and was
+ updated, warn about any of its also_make targets that don't exist. */
+ if (file->tried_implicit && is_ordinary_mtime (file->last_mtime)
+ && file->last_mtime > file->mtime_before_update)
+ {
+ struct dep *ad;
+
+ for (ad = file->also_make; ad; ad = ad->next)
+ if (ad->file->last_mtime == NONEXISTENT_MTIME)
+ OS (error, file->cmds ? &file->cmds->fileinfo : NILF,
+ _("warning: pattern recipe did not update peer target '%s'."),
+ ad->file->name);
+ }
+}
+
/* Remake all the goals in the 'struct dep' chain GOALS. Return update_status
representing the totality of the status of the goals.
@@ -187,6 +205,8 @@ update_goal_chain (struct goaldep *goaldeps)
FILE_TIMESTAMP mtime = MTIME (file);
check_renamed (file);
+ check_also_make (file);
+
if (file->updated && mtime != file->mtime_before_update)
{
/* Updating was done. If this is a makefile and
@@ -502,21 +522,6 @@ update_file_1 (struct file *file, unsigned int depth)
this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns;
}
- /* If file was specified as a target with no commands, come up with some
- default commands. This may also add more also_make files. */
-
- if (!file->phony && file->cmds == 0 && !file->tried_implicit)
- {
- try_implicit_rule (file, depth);
- file->tried_implicit = 1;
- }
- if (file->cmds == 0 && !file->is_target
- && default_file != 0 && default_file->cmds != 0)
- {
- DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n"));
- file->cmds = default_file->cmds;
- }
-
/* If any also_make target doesn't exist, we must remake this one too.
If they do exist choose the oldest mtime so they will rebuild. */
@@ -525,18 +530,35 @@ update_file_1 (struct file *file, unsigned int depth)
struct file *adfile = ad->file;
FILE_TIMESTAMP fmtime = file_mtime (adfile);
- check_renamed (adfile);
noexist = fmtime == NONEXISTENT_MTIME;
if (noexist)
- DBS (DB_BASIC,
- (_("Grouped target peer '%s' of file '%s' does not exist.\n"),
- adfile->name, file->name));
+ {
+ check_renamed (adfile);
+ DBS (DB_BASIC,
+ (_("Grouped target peer '%s' of file '%s' does not exist.\n"),
+ adfile->name, file->name));
+ }
else if (fmtime < this_mtime)
this_mtime = fmtime;
}
must_make = noexist;
+ /* If file was specified as a target with no commands, come up with some
+ default commands. This may also add more also_make files. */
+
+ if (!file->phony && file->cmds == 0 && !file->tried_implicit)
+ {
+ try_implicit_rule (file, depth);
+ file->tried_implicit = 1;
+ }
+ if (file->cmds == 0 && !file->is_target
+ && default_file != 0 && default_file->cmds != 0)
+ {
+ DBF (DB_IMPLICIT, _("Using default recipe for '%s'.\n"));
+ file->cmds = default_file->cmds;
+ }
+
/* Update all non-intermediate files we depend on, if necessary, and see
whether any of them is more recent than this file. We need to walk our
deps, AND the deps of any also_make targets to ensure everything happens
@@ -1072,6 +1094,7 @@ check_dep (struct file *file, unsigned int depth,
check_renamed (file);
if (mtime == NONEXISTENT_MTIME || mtime > this_mtime)
*must_make_ptr = 1;
+ check_also_make (file);
}
else
{