Module Name: src Committed By: rillig Date: Fri Jan 29 22:52:29 UTC 2021
Modified Files: src/usr.bin/make: job.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.398 -r1.399 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.398 src/usr.bin/make/job.c:1.399 --- src/usr.bin/make/job.c:1.398 Tue Jan 19 20:51:46 2021 +++ src/usr.bin/make/job.c Fri Jan 29 22:52:29 2021 @@ -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 @@ JobStart(GNode *gn, Boolean special) * 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)) { /*