From b47fad7d19c9a853cb9cd3f08f486901122b1c86 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 4 Jan 2012 18:39:27 -0800 Subject: [PATCH] V0.9: Update lex/yacc builds to be consistent and to support parallel builds Not all the lex/yacc (flex/bison) targets were using a consistent syntax. This patch fixes that and explicitly serializes the *.c/*.cc and *.h build. Not doing this was causing problem when using make -j. The issue appears to be that if two targets are specified for a rule (e.g. file.cc file.h: file.y) make does not realize they are both built by the same call so the rule is executed twice. Once for the .cc target and once for the .h target. This is not a problem for a serial build. To work around this only use the .c/.cc file in the main target and then make the .h file depend on the .c/.cc file as a sub-target. --- Makefile.in | 14 ++++++++------ driver/Makefile.in | 8 +++++--- ivlpp/Makefile.in | 2 +- vpi/Makefile.in | 10 ++++++---- vvp/Makefile.in | 5 ++--- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Makefile.in b/Makefile.in index 71cd5ffed..d66542702 100644 --- a/Makefile.in +++ b/Makefile.in @@ -118,8 +118,8 @@ endif clean: $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true rm -f *.o parse.cc parse.h lexor.cc - rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps parse.output - rm -f syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp + rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps + rm -f parse.output syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc rm -rf dep rm -f version.exe @@ -223,15 +223,17 @@ lexor.o: lexor.cc parse.h parse.o: parse.cc -parse.cc parse.h: $(srcdir)/parse.y - $(YACC) --verbose -t -p VL -d -o parse.cc $(srcdir)/parse.y +# Build this in two steps to avoid parallel build issues (see pr3462585) +parse.cc: $(srcdir)/parse.y + $(YACC) --verbose -t -p VL -d -o $@ $< +parse.h: parse.cc mv parse.cc.h parse.h 2>/dev/null || mv parse.hh parse.h syn-rules.cc: $(srcdir)/syn-rules.y - $(YACC) --verbose -p syn_ -o syn-rules.cc $(srcdir)/syn-rules.y + $(YACC) --verbose -t -p syn_ -o $@ $< lexor.cc: $(srcdir)/lexor.lex - $(LEX) -PVL -s -olexor.cc $(srcdir)/lexor.lex + $(LEX) -PVL -s -t $< > $@ lexor_keyword.o: lexor_keyword.cc parse.h diff --git a/driver/Makefile.in b/driver/Makefile.in index 39cf94ff6..f53f7acff 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -68,10 +68,12 @@ iverilog@EXEEXT@: $O $(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@ @EXTRALIBS@ cflexor.c: cflexor.lex - $(LEX) -s -Pcf -ocflexor.c $(srcdir)/cflexor.lex + $(LEX) -Pcf -s -t $< > $@ -cfparse.h cfparse.c: cfparse.y - $(YACC) --verbose -t -d -o cfparse.c --name-prefix=cf $(srcdir)/cfparse.y +# Build this in two steps to avoid parallel build issues (see pr3462585) +cfparse.c: cfparse.y + $(YACC) --verbose -t -p cf -d -o $@ $< +cfparse.h: cfparse.c dep: mkdir dep diff --git a/ivlpp/Makefile.in b/ivlpp/Makefile.in index d4b4d2cc6..13841c7eb 100644 --- a/ivlpp/Makefile.in +++ b/ivlpp/Makefile.in @@ -61,7 +61,7 @@ ivlpp@EXEEXT@: $O $(CC) $(LDFLAGS) $O -o ivlpp@EXEEXT@ @EXTRALIBS@ lexor.c: lexor.lex - $(LEX) -olexor.c $(srcdir)/lexor.lex + $(LEX) -s -t $< > $@ install: all installdirs $(libdir)/ivl$(suffix)/ivlpp@EXEEXT@ diff --git a/vpi/Makefile.in b/vpi/Makefile.in index 7fdb8a432..68b58ef9b 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -87,15 +87,17 @@ system.vpi: $O ../vvp/libvpi.a $(CC) @shared@ -o $@ $O -L../vvp $(LDFLAGS) -lvpi $(SYSTEM_VPI_LDFLAGS) sys_readmem_lex.c: sys_readmem_lex.lex - $(LEX) -t -Preadmem $(srcdir)/sys_readmem_lex.lex > sys_readmem_lex.c + $(LEX) -Preadmem -s -t $< > $@ sdf_lexor.o: sdf_lexor.c sdf_parse.h sdf_lexor.c: sdf_lexor.lex - $(LEX) -t -Psdf $(srcdir)/sdf_lexor.lex > sdf_lexor.c + $(LEX) -Psdf -s -t $< > $@ -sdf_parse.c sdf_parse.h: $(srcdir)/sdf_parse.y - $(YACC) --verbose -d -p sdf -o sdf_parse.c $(srcdir)/sdf_parse.y +# Build this in two steps to avoid parallel build issues (see pr3462585) +sdf_parse.c: $(srcdir)/sdf_parse.y + $(YACC) --verbose -t -p sdf -d -o $@ $< +sdf_parse.h: sdf_parse.c v2005_math.vpi: $M ../vvp/libvpi.a $(CC) @shared@ -o $@ $M -L../vvp $(LDFLAGS) -lvpi $(VA_MATH_VPI_LDFLAGS) diff --git a/vvp/Makefile.in b/vvp/Makefile.in index d55478794..e0b04c36a 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -140,10 +140,9 @@ parse.o: parse.cc tables.o: tables.cc parse.cc: $(srcdir)/parse.y - $(YACC) --verbose -t -d -o parse.cc $(srcdir)/parse.y - + $(YACC) --verbose -t -d -o $@ $< parse.h: parse.cc - mv parse.cc.h parse.h 2>/dev/null || mv parse.hh parse.h + mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@ lexor.cc: $(srcdir)/lexor.lex $(LEX) -s -olexor.cc $(srcdir)/lexor.lex