[SV 63417] Ensure global .NOTINTERMEDIATE disables all intermediates

Fix .NOTINTERMEDIATE without prerequisites to disable intermediate
status for all targets.

* src/makeint.h: Declare extern no_intermediates.
* src/main.c: Add global definition of no_intermediates.
* src/file.c: Remove static no_intermediates to use global variable.
(remove_intermediates): Check no_intermediates.
* src/implicit.c (pattern_search): For a file found by implicit search
set file->notintermediate if no_intermediates is set.
* src/remake.c (update_file_1): Don't set file->secondary for a
pre-existing file if no_intermediates is set.  The check for
no_intermediates here is redundant, but won't hurt: keep it in case
things change so that it matters.
* tests/scripts/targets/NOTINTERMEDIATE: Fix a test.
This commit is contained in:
Dmitry Goncharov
2022-11-27 15:40:28 -05:00
committed by Paul Smith
parent a99183ed2b
commit 6164608900
6 changed files with 12 additions and 12 deletions

View File

@@ -63,9 +63,6 @@ static struct hash_table files;
/* Whether or not .SECONDARY with no prerequisites was given. */
static int all_secondary = 0;
/* Whether or not .NOTINTERMEDIATE with no prerequisites was given. */
static int no_intermediates = 0;
/* Access the hash table of all file records.
lookup_file given a name, return the struct file * for that name,
or nil if there is none.
@@ -368,7 +365,7 @@ remove_intermediates (int sig)
int doneany = 0;
/* If there's no way we will ever remove anything anyway, punt early. */
if (question_flag || touch_flag || all_secondary)
if (question_flag || touch_flag || all_secondary || no_intermediates)
return;
if (sig && just_print_flag)
@@ -731,7 +728,7 @@ snap_file (const void *item, void *arg)
/* If .NOTINTERMEDIATE is set with no deps, mark all targets as
notintermediate, unless the target is a prereq of .INTERMEDIATE. */
if (no_intermediates && !f->intermediate && !f->secondary)
f->notintermediate = 1;
f->notintermediate = 1;
/* If .EXTRA_PREREQS is set, add them as ignored by automatic variables. */
if (f->variables)

View File

@@ -1008,7 +1008,7 @@ pattern_search (struct file *file, int archive,
f->also_make = imf->also_make;
f->is_target = 1;
f->is_explicit |= imf->is_explicit || pat->is_explicit;
f->notintermediate |= imf->notintermediate;
f->notintermediate |= imf->notintermediate || no_intermediates;
f->intermediate |= !f->is_explicit && !f->notintermediate;
f->tried_implicit = 1;
@@ -1090,7 +1090,7 @@ pattern_search (struct file *file, int archive,
{
if (f->precious)
file->precious = 1;
if (f->notintermediate)
if (f->notintermediate || no_intermediates)
file->notintermediate = 1;
}
}
@@ -1123,7 +1123,7 @@ pattern_search (struct file *file, int archive,
{
if (f->precious)
new->file->precious = 1;
if (f->notintermediate)
if (f->notintermediate || no_intermediates)
new->file->notintermediate = 1;
}

View File

@@ -298,6 +298,9 @@ struct variable shell_var;
char cmd_prefix = '\t';
/* Whether or not .NOTINTERMEDIATE with no prerequisites was given. */
unsigned int no_intermediates;
/* Count the number of commands we've invoked, that might change something in
the filesystem. Start with 1 so calloc'd memory never matches. */

View File

@@ -759,6 +759,8 @@ extern int batch_mode_shell;
#define RECIPEPREFIX_DEFAULT '\t'
extern char cmd_prefix;
extern unsigned int no_intermediates;
#define JOBSERVER_AUTH_OPT "jobserver-auth"
extern char *jobserver_auth;

View File

@@ -871,7 +871,8 @@ update_file_1 (struct file *file, unsigned int depth)
/* Since make has not created this file, make should not remove it,
even if the file is intermediate. */
file->secondary = 1;
if (!file->notintermediate && no_intermediates == 0)
file->secondary = 1;
notice_finished_file (file);

View File

@@ -36,7 +36,6 @@ hello.z:
# Test 4. .NOTINTERMEDIATE without prerequisites makes everything
# notintermediate.
unlink('hello.z');
run_make_test(q!
hello.z:
%.z: %.x; touch $@
@@ -112,8 +111,6 @@ hello.z:
.SECONDARY:
!, '', "touch hello.z\n");
unlink('hello.z');
# This tells the test driver that the perl test script executed properly.
1;