Module Name: src Committed By: rillig Date: Sun Nov 28 00:02:07 UTC 2021
Modified Files: src/usr.bin/make: job.c src/usr.bin/make/unit-tests: opt-debug-errors-jobs.exp Log Message: make: with the option -de in jobs mode, output expanded commands This helps tracking down the actual cause of build failures in build systems like NetBSD's build.sh that use highly abstracted commands that are mainly defined in terms of variables. To generate a diff of this commit: cvs rdiff -u -r1.436 -r1.437 src/usr.bin/make/job.c cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp 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.436 src/usr.bin/make/job.c:1.437 --- src/usr.bin/make/job.c:1.436 Sun Oct 24 18:45:46 2021 +++ src/usr.bin/make/job.c Sun Nov 28 00:02:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg Exp $ */ +/* $NetBSD: job.c,v 1.437 2021/11/28 00:02:07 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.436 2021/10/24 18:45:46 sjg Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.437 2021/11/28 00:02:07 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1068,10 +1068,20 @@ DebugFailedJob(const Job *job) if (!DEBUG(ERROR)) return; - debug_printf("\n*** Failed target: %s\n*** Failed commands:\n", - job->node->name); - for (ln = job->node->commands.first; ln != NULL; ln = ln->next) - debug_printf("\t%s\n", (const char *)ln->datum); + debug_printf("\n"); + debug_printf("*** Failed target: %s\n", job->node->name); + debug_printf("*** Failed commands:\n"); + for (ln = job->node->commands.first; ln != NULL; ln = ln->next) { + const char *unexpanded = (const char *)ln->datum; + debug_printf("\t%s\n", unexpanded); + + if (strchr(unexpanded, '$') != NULL) { + char *expanded; + (void)Var_Subst((const char *)ln->datum, job->node, + VARE_WANTRES, &expanded); + debug_printf("\t=> %s\n", expanded); + } + } } static void Index: src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp:1.3 src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp:1.4 --- src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp:1.3 Sat Nov 27 23:56:11 2021 +++ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp Sun Nov 28 00:02:07 2021 @@ -24,6 +24,8 @@ line2 *** Failed target: fail-newline *** Failed commands: echo 'line1${.newline}line2'; false + => echo 'line1 +line2'; false *** [fail-newline] Error code 1 make: stopped in unit-tests @@ -49,6 +51,7 @@ make: stopped in unit-tests *** Failed target: fail-vars *** Failed commands: @${COMPILE_C} ${COMPILE_C_FLAGS} + => @false c-compiler flag1 -macro="several words" *** [fail-vars] Error code 1 make: stopped in unit-tests