Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): do not create empty shell files in job...



details:   https://anonhg.NetBSD.org/src/rev/c5c109a9f9d0
branches:  trunk
changeset: 980251:c5c109a9f9d0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 29 22:52:29 2021 +0000

description:
make(1): do not create empty shell files in jobs mode

In a chain of dependencies such as "all: build; build: do-build", the
intermediate targets do not have any commands.  In jobs mode,
nevertheless, an empty file was created and fed to the shell.  This was
unnecessary.  See jobs-empty-commands.mk.

The case of the special command line "...", which was suggested on
current-users, is not optimized since it doesn't occur in practice.

Suggested by Mateusz Guzik on current-users:
https://mail-index.netbsd.org/current-users/2021/01/26/msg040215.html

diffstat:

 usr.bin/make/job.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r afce5222ac29 -r c5c109a9f9d0 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Fri Jan 29 22:38:17 2021 +0000
+++ b/usr.bin/make/job.c        Fri Jan 29 22:52:29 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.398 2021/01/19 20:51:46 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.399 2021/01/29 22:52:29 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -143,7 +143,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.398 2021/01/19 20:51:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.399 2021/01/29 22:52:29 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1666,8 +1666,13 @@
         * we don't need to reopen it to feed it to the shell. If the -n
         * flag *was* given, we just set the file to be stdout. Cute, huh?
         */
-       if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) ||
+       if (Lst_IsEmpty(&gn->commands)) {
+               /* XXX: No need to flush stdout here */
+               job->cmdFILE = stdout;
+               run = FALSE;
+       } else if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) ||
            (!opts.noExecute && !opts.touchFlag)) {
+               /* XXX: The above conditions are needlessly repeated */
                JobOpenTmpFile(job, gn, cmdsOK, &run);
        } else if (!GNode_ShouldExecute(gn)) {
                /*



Home | Main Index | Thread Index | Old Index