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: extract commands-ok check from JobWriteSh...



details:   https://anonhg.NetBSD.org/src/rev/0bf99776568e
branches:  trunk
changeset: 1021753:0bf99776568e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jun 16 03:56:59 2021 +0000

description:
make: extract commands-ok check from JobWriteShellCommands

This piece of code did not match the function name and thus could not
reasonably be expected in that function.

In job.c 1.399 from 2021-01-29 I missed exactly this little detail when
I added code to skip the apparently unnecessary creation of empty shell
files.  The code I added only handled the happy case, not the case where
the target could not be made.

That code path then differed, leading to a much more verbose error
message than before.

before:
don't know how to make ../missing/no-such.o. Stop

after:
don't know how to make ../missing/no-such.o. Stop
...
`../missing/no-such.o' was not built (made BEINGMADE, ...)!
`muck' was not built (made DEFERRED, type OP_DEPENDS|...)!
    `muck' has .ORDER dependency against build-all (made DEFERRED, ...)

Thanks to sjg for finding and reproducing this unintended change of
behavior.

diffstat:

 usr.bin/make/job.c |  26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diffs (61 lines):

diff -r 85bb34cee04d -r 0bf99776568e usr.bin/make/job.c
--- a/usr.bin/make/job.c        Wed Jun 16 03:15:47 2021 +0000
+++ b/usr.bin/make/job.c        Wed Jun 16 03:56:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.433 2021/06/16 03:15:47 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.434 2021/06/16 03:56:59 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.433 2021/06/16 03:15:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.434 2021/06/16 03:56:59 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1585,7 +1585,7 @@
 }
 
 static void
-JobWriteShellCommands(Job *job, GNode *gn, bool cmdsOK, bool *out_run)
+JobWriteShellCommands(Job *job, GNode *gn, bool *out_run)
 {
        /*
         * tfile is the name of a file into which all shell commands
@@ -1595,15 +1595,6 @@
        char tfile[MAXPATHLEN];
        int tfd;                /* File descriptor to the temp file */
 
-       /*
-        * We're serious here, but if the commands were bogus, we're
-        * also dead...
-        */
-       if (!cmdsOK) {
-               PrintOnError(gn, NULL); /* provide some clue */
-               DieHorribly();
-       }
-
        tfd = Job_TempFile(TMPPAT, tfile, sizeof tfile);
 
        job->cmdFILE = fdopen(tfd, "w+");
@@ -1681,7 +1672,16 @@
                 * virtual targets.
                 */
 
-               JobWriteShellCommands(job, gn, cmdsOK, &run);
+               /*
+                * We're serious here, but if the commands were bogus, we're
+                * also dead...
+                */
+               if (!cmdsOK) {
+                       PrintOnError(gn, NULL); /* provide some clue */
+                       DieHorribly();
+               }
+
+               JobWriteShellCommands(job, gn, &run);
                (void)fflush(job->cmdFILE);
        } else if (!GNode_ShouldExecute(gn)) {
                /*



Home | Main Index | Thread Index | Old Index