From 7ab046e1f1b382bc125699b0c0d589273adcd420 Mon Sep 17 00:00:00 2001 From: "Simon J. Gerraty" Date: Thu, 15 Nov 2012 22:01:30 +0000 Subject: [PATCH] Import bmake-20121111 - pick up fix for .ORDER Approved by: marcel (mentor) --- ChangeLog | 25 +++++++++++++++++++++++++ FILES | 1 + Makefile.in | 6 +++--- cond.c | 37 ++++++++++++++++++++----------------- make.c | 10 +++++----- unit-tests/Makefile.in | 6 ++++-- unit-tests/order | 20 ++++++++++++++++++++ unit-tests/test.exp | 3 +++ 8 files changed, 81 insertions(+), 27 deletions(-) create mode 100644 unit-tests/order diff --git a/ChangeLog b/ChangeLog index 933e43565dfc..b17fcb5cb282 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2012-11-11 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): 20121111 + fix generation of bmake.cat1 + +2012-11-09 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): 20121109 + Merge with NetBSD make, pick up + o make.c: MakeBuildChild: return 0 so search continues if a + .ORDER dependency is detected. + o unit-tests/order: test the above + +2012-11-02 Simon J. Gerraty + + * Makefile.in (MAKE_VERSION): 20121102 + Merge with NetBSD make, pick up + o cond.c: allow cond_state[] to grow. + In meta mode with a very large tree, we can hit the limit + while processing dirdeps. + +2012-10-25 Simon J. Gerraty + + * Makefile.in: we need to use ${srcdir} not ${.CURDIR} + 2012-10-10 Simon J. Gerraty * Makefile.in (MAKE_VERSION): 20121010 diff --git a/FILES b/FILES index 397d3a277beb..e7c786156cff 100644 --- a/FILES +++ b/FILES @@ -110,6 +110,7 @@ unit-tests/modmisc unit-tests/modorder unit-tests/modts unit-tests/modword +unit-tests/order unit-tests/phony-end unit-tests/posix unit-tests/qequals diff --git a/Makefile.in b/Makefile.in index 4cb55dd85fb5..7936d3be97ec 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.56 2012/05/30 21:54:23 sjg Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 -# $Id: Makefile.in,v 1.174 2012/10/10 18:46:24 sjg Exp $ +# $Id: Makefile.in,v 1.178 2012/11/15 16:48:59 sjg Exp $ PROG= bmake SRCS= arch.c buf.c compat.c cond.c dir.c for.c hash.c job.c main.c \ @@ -21,7 +21,7 @@ srcdir= @srcdir@ CC?= @CC@ # Base version on src date -MAKE_VERSION= 20121010 +MAKE_VERSION= 20121111 MACHINE=@machine@ MACHINE_ARCH=@machine_arch@ DEFAULT_SYS_PATH = @default_sys_path@ @@ -114,7 +114,7 @@ ${MAN}: make.1 my.history @echo making ${PROG}.1 @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \ -e '/^.Sh HISTORY/rmy.history' \ - -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${.CURDIR}/make.1 > $@ + -e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@ .endif diff --git a/cond.c b/cond.c index 6d0b965e6841..a1c6705df601 100644 --- a/cond.c +++ b/cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $ */ +/* $NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.64 2012/06/12 19:21:50 joerg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $"); #endif #endif /* not lint */ #endif @@ -1227,7 +1227,8 @@ do_Cond_EvalExpression(Boolean *value) int Cond_Eval(char *line) { - #define MAXIF 128 /* maximum depth of .if'ing */ +#define MAXIF 128 /* maximum depth of .if'ing */ +#define MAXIF_BUMP 32 /* how much to grow by */ enum if_states { IF_ACTIVE, /* .if or .elif part active */ ELSE_ACTIVE, /* .else part active */ @@ -1235,7 +1236,8 @@ Cond_Eval(char *line) SKIP_TO_ELSE, /* has been true, but not seen '.else' */ SKIP_TO_ENDIF /* nothing else to execute */ }; - static enum if_states cond_state[MAXIF + 1] = { IF_ACTIVE }; + static enum if_states *cond_state = NULL; + static unsigned int max_if_depth = MAXIF; const struct If *ifp; Boolean isElif; @@ -1244,7 +1246,10 @@ Cond_Eval(char *line) enum if_states state; level = PARSE_FATAL; - + if (!cond_state) { + cond_state = bmake_malloc(max_if_depth * sizeof(*cond_state)); + cond_state[0] = IF_ACTIVE; + } /* skip leading character (the '.') and any whitespace */ for (line++; *line == ' ' || *line == '\t'; line++) continue; @@ -1261,8 +1266,6 @@ Cond_Eval(char *line) } /* Return state for previous conditional */ cond_depth--; - if (cond_depth > MAXIF) - return COND_SKIP; return cond_state[cond_depth] <= ELSE_ACTIVE ? COND_PARSE : COND_SKIP; } @@ -1275,8 +1278,6 @@ Cond_Eval(char *line) return COND_PARSE; } - if (cond_depth > MAXIF) - return COND_SKIP; state = cond_state[cond_depth]; switch (state) { case SEARCH_FOR_ELIF: @@ -1325,9 +1326,6 @@ Cond_Eval(char *line) Parse_Error(level, "if-less elif"); return COND_PARSE; } - if (cond_depth > MAXIF) - /* Error reported when we saw the .if ... */ - return COND_SKIP; state = cond_state[cond_depth]; if (state == SKIP_TO_ENDIF || state == ELSE_ACTIVE) { Parse_Error(PARSE_WARNING, "extra elif"); @@ -1341,10 +1339,15 @@ Cond_Eval(char *line) } } else { /* Normal .if */ - if (cond_depth >= MAXIF) { - cond_depth++; - Parse_Error(PARSE_FATAL, "Too many nested if's. %d max.", MAXIF); - return COND_SKIP; + if (cond_depth + 1 >= max_if_depth) { + /* + * This is rare, but not impossible. + * In meta mode, dirdeps.mk (only runs at level 0) + * can need more than the default. + */ + max_if_depth += MAXIF_BUMP; + cond_state = bmake_realloc(cond_state, max_if_depth * + sizeof(*cond_state)); } state = cond_state[cond_depth]; cond_depth++; diff --git a/make.c b/make.c index 4fa4ff9ee8e7..7905f8c1910c 100644 --- a/make.c +++ b/make.c @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $ */ +/* $NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $"; +static char rcsid[] = "$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: make.c,v 1.87 2012/06/12 19:21:51 joerg Exp $"); +__RCSID("$NetBSD: make.c,v 1.88 2012/11/09 18:53:05 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -1032,7 +1032,7 @@ MakeBuildChild(void *v_cn, void *toBeMade_next) if (cn->order_pred && Lst_ForEach(cn->order_pred, MakeCheckOrder, 0)) { /* Can't build this (or anything else in this child list) yet */ cn->made = DEFERRED; - return 1; + return 0; /* but keep looking */ } if (DEBUG(MAKE)) @@ -1055,7 +1055,7 @@ MakeBuildChild(void *v_cn, void *toBeMade_next) return cn->type & OP_WAIT && cn->unmade > 0; } -/* When a .ORDER RHS node completes we do this on each LHS */ +/* When a .ORDER LHS node completes we do this on each RHS */ static int MakeBuildParent(void *v_pn, void *toBeMade_next) { diff --git a/unit-tests/Makefile.in b/unit-tests/Makefile.in index 4e3592d94695..e5bf9b261b74 100644 --- a/unit-tests/Makefile.in +++ b/unit-tests/Makefile.in @@ -1,6 +1,6 @@ -# $Id: Makefile.in,v 1.38 2012/06/19 23:38:48 sjg Exp $ +# $Id: Makefile.in,v 1.39 2012/11/09 19:16:10 sjg Exp $ # -# $NetBSD: Makefile,v 1.34 2012/06/19 23:25:53 sjg Exp $ +# $NetBSD: Makefile,v 1.35 2012/11/09 19:08:28 sjg Exp $ # # Unit tests for make(1) # The main targets are: @@ -40,6 +40,7 @@ SUBFILES= \ modorder \ modts \ modword \ + order \ phony-end \ posix \ qequals \ @@ -52,6 +53,7 @@ SUBFILES= \ all: ${SUBFILES} flags.doterror= +flags.order=-j1 # the tests are actually done with sub-makes. .PHONY: ${SUBFILES} diff --git a/unit-tests/order b/unit-tests/order new file mode 100644 index 000000000000..175da471fe36 --- /dev/null +++ b/unit-tests/order @@ -0,0 +1,20 @@ +# $NetBSD: order,v 1.1 2012/11/09 19:08:28 sjg Exp $ + +# Test that .ORDER is handled correctly. +# The explicit dependency the.o: the.h will make us examine the.h +# the .ORDER will prevent us building it immediately, +# we should then examine the.c rather than stop. + +all: the.o + +.ORDER: the.c the.h + +the.c the.h: + @echo Making $@ + +.SUFFIXES: .o .c + +.c.o: + @echo Making $@ from $? + +the.o: the.h diff --git a/unit-tests/test.exp b/unit-tests/test.exp index 932d84e305a6..368dc3156dbb 100644 --- a/unit-tests/test.exp +++ b/unit-tests/test.exp @@ -310,6 +310,9 @@ LIST:tw:C/ /,/g="one two three four five six" LIST:tw:C/ /,/1g="one two three four five six" LIST:tw:tW:C/ /,/="one,two three four five six" LIST:tW:tw:C/ /,/="one two three four five six" +Making the.c +Making the.h +Making the.o from the.h the.c .TARGET="phony" .PREFIX="phony" .IMPSRC="" .TARGET="all" .PREFIX="all" .IMPSRC="" .TARGET="ok" .PREFIX="ok" .IMPSRC=""