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/c77231c64db6
branches:  trunk
changeset: 959027:c77231c64db6
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 7c715ec5f786 -r c77231c64db6 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