Module Name:    src
Committed By:   rillig
Date:           Sat Nov 27 23:56:11 UTC 2021

Modified Files:
        src/usr.bin/make/unit-tests: opt-debug-errors-jobs.exp
            opt-debug-errors-jobs.mk

Log Message:
tests/make: demonstrate unhelpful debug log in case of errors

The releng build job that runs lint fails.  It outputs the usage message
of lint, which doesn't include the failing option.  After that, make
outputs:

        *** Failed target: lint-cgdconfig
        *** Failed commands:
                ${LINT} ${LINTFLAGS} \
                    ${_LDFLAGS.${:Ucgdconfig}:C/-L[  ]*/-L/Wg:M-L*} \
                    ${LOBJS.${:Ucgdconfig}} ${_LDADD.${:Ucgdconfig}}

Make doesn't output the expanded command, therefore the log doesn't show
the offending option '-pthread' that leads to the usage message.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
    src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk

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/unit-tests/opt-debug-errors-jobs.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp:1.2 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.2	Tue Apr 27 16:23:21 2021
+++ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp	Sat Nov 27 23:56:11 2021
@@ -45,4 +45,11 @@ word1 word2
 *** [fail-multiline-intention] Error code 1
 
 make: stopped in unit-tests
+
+*** Failed target: fail-vars
+*** Failed commands:
+	@${COMPILE_C} ${COMPILE_C_FLAGS}
+*** [fail-vars] Error code 1
+
+make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk:1.2
--- src/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk:1.1	Tue Apr 27 16:20:06 2021
+++ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk	Sat Nov 27 23:56:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-errors-jobs.mk,v 1.1 2021/04/27 16:20:06 rillig Exp $
+# $NetBSD: opt-debug-errors-jobs.mk,v 1.2 2021/11/27 23:56:11 rillig Exp $
 #
 # Tests for the -de command line option, which adds debug logging for
 # failed commands and targets; since 2021-04-27 also in jobs mode.
@@ -10,6 +10,7 @@ all: fail-escaped-space
 all: fail-newline
 all: fail-multiline
 all: fail-multiline-intention
+all: fail-vars
 
 fail-spaces:
 	echo '3   spaces'; false
@@ -34,3 +35,14 @@ fail-multiline:
 fail-multiline-intention:
 	echo	'word1'							\
 		'word2'; false
+
+# In makefiles that rely heavily on abstracted variables, it is not possible
+# to determine the actual command from the unexpanded command alone. To help
+# debugging these issues (for example in NetBSD's build.sh), output the
+# expanded command as well whenever it differs from the unexpanded command.
+# Since 2021-11-28.
+COMPILE_C=	false c-compiler
+COMPILE_C_DEFS=	macro="several words"
+COMPILE_C_FLAGS=flag1 ${COMPILE_C_DEFS:@def@-${def}@}
+fail-vars:
+	@${COMPILE_C} ${COMPILE_C_FLAGS}

Reply via email to