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): add explanation for test suff-rebuild



details:   https://anonhg.NetBSD.org/src/rev/821a61260732
branches:  trunk
changeset: 1016441:821a61260732
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 21 12:01:16 2020 +0000

description:
make(1): add explanation for test suff-rebuild

diffstat:

 usr.bin/make/suff.c                      |  14 ++++++++++++--
 usr.bin/make/unit-tests/suff-rebuild.exp |   2 +-
 usr.bin/make/unit-tests/suff-rebuild.mk  |  11 ++++++++++-
 3 files changed, 23 insertions(+), 4 deletions(-)

diffs (72 lines):

diff -r 1e475b078560 -r 821a61260732 usr.bin/make/suff.c
--- a/usr.bin/make/suff.c       Sat Nov 21 11:59:22 2020 +0000
+++ b/usr.bin/make/suff.c       Sat Nov 21 12:01:16 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: suff.c,v 1.257 2020/11/21 10:36:01 rillig Exp $        */
+/*     $NetBSD: suff.c,v 1.258 2020/11/21 12:01:16 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,7 +114,7 @@
 #include "dir.h"
 
 /*     "@(#)suff.c     8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.257 2020/11/21 10:36:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.258 2020/11/21 12:01:16 rillig Exp $");
 
 #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
 #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@@ -642,6 +642,16 @@
     if (target->type == OP_TRANSFORM)
        return FALSE;
 
+    /*
+     * XXX: What is the purpose of the 'ptr == target->name' condition here?
+     * In suff-rebuild.mk in the line '.SUFFIXES: .c .b .a', it prevents the
+     * rule '.b.c' from being added again during Suff_AddSuffix(".b").
+     */
+    /*
+     * XXX: What about a transformation ".cpp.c"?  If ".c" is added as a new
+     * suffix, it seems wrong that this transformation would be skipped just
+     * because ".c" happens to be a prefix of ".cpp".
+     */
     if ((ptr = strstr(target->name, suff->name)) == NULL ||
        ptr == target->name)
        return FALSE;
diff -r 1e475b078560 -r 821a61260732 usr.bin/make/unit-tests/suff-rebuild.exp
--- a/usr.bin/make/unit-tests/suff-rebuild.exp  Sat Nov 21 11:59:22 2020 +0000
+++ b/usr.bin/make/unit-tests/suff-rebuild.exp  Sat Nov 21 12:01:16 2020 +0000
@@ -30,7 +30,7 @@
 inserting ".c" (3) at end of list
 inserting "" (0) at end of list
 ParseReadLine (22): '  : Making ${.TARGET} from ${.IMPSRC}.'
-ParseReadLine (35): '.SUFFIXES: .c .b .a'
+ParseReadLine (44): '.SUFFIXES: .c .b .a'
 transformation .c complete
 ParseDoDependency(.SUFFIXES: .c .b .a)
 Adding ".END" to all targets.
diff -r 1e475b078560 -r 821a61260732 usr.bin/make/unit-tests/suff-rebuild.mk
--- a/usr.bin/make/unit-tests/suff-rebuild.mk   Sat Nov 21 11:59:22 2020 +0000
+++ b/usr.bin/make/unit-tests/suff-rebuild.mk   Sat Nov 21 12:01:16 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: suff-rebuild.mk,v 1.5 2020/11/21 11:55:57 rillig Exp $
+# $NetBSD: suff-rebuild.mk,v 1.6 2020/11/21 12:01:16 rillig Exp $
 #
 # Demonstrates what happens to transformation rules (called inference rules
 # by POSIX) when all suffixes are deleted.
@@ -28,6 +28,15 @@
 # As of 2020-09-25, uncommenting the following line results in the error
 # message "don't know how to make suff-rebuild-example" though.
 #
+# If this is a bug, the actual cause is probably that when a suffix
+# transformation rule is defined, it is not added to the global list of
+# targets, see Suff_EndTransform.  Later, UpdateTargets iterates over exactly
+# this global list of targets though.
+#
+# If UpdateTargets were to iterate over 'transforms' as well, it still
+# wouldn't work because the condition 'ptr == target->name' skips these
+# transformation rules.
+
 #.SUFFIXES:
 
 # Add the suffixes back.  It should not matter that the order of the suffixes



Home | Main Index | Thread Index | Old Index