From 9c99bce054c67c59435f2ef0e5dfc6698bebe2dc Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 4 Jan 2012 17:59:41 -0800 Subject: [PATCH] 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 | 16 +++++++++------- driver/Makefile.in | 10 ++++++---- ivlpp/Makefile.in | 2 +- vhdlpp/Makefile.in | 8 +++++--- vpi/Makefile.in | 18 +++++++++++------- vvp/Makefile.in | 6 +++--- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Makefile.in b/Makefile.in index cac099f67..3abafbe55 100644 --- a/Makefile.in +++ b/Makefile.in @@ -150,8 +150,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 @@ -244,15 +244,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 - mv parse.cc.h parse.h 2>/dev/null || mv parse.hh parse.h +# 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 $@ 2>/dev/null || mv parse.hh $@ 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) -s -olexor.cc $(srcdir)/lexor.lex + $(LEX) -s -t $< > $@ lexor_keyword.o: lexor_keyword.cc parse.h diff --git a/driver/Makefile.in b/driver/Makefile.in index 7a1930bb9..c6f3e4922 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -79,11 +79,13 @@ dep: iverilog@EXEEXT@: $O $(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@ @EXTRALIBS@ -cflexor.c: cflexor.lex - $(LEX) -s -ocflexor.c $(srcdir)/cflexor.lex +cflexor.c: $(srcdir)/cflexor.lex + $(LEX) -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: $(srcdir)/cfparse.y + $(YACC) --verbose -t -p cf -d -o $@ $< +cfparse.h: cfparse.c %.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o diff --git a/ivlpp/Makefile.in b/ivlpp/Makefile.in index 9245bf18e..226d5fb51 100644 --- a/ivlpp/Makefile.in +++ b/ivlpp/Makefile.in @@ -70,7 +70,7 @@ ivlpp@EXEEXT@: $O $(CC) $(LDFLAGS) $O -o ivlpp@EXEEXT@ @EXTRALIBS@ lexor.c: $(srcdir)/lexor.lex - $(LEX) -olexor.c $(srcdir)/lexor.lex + $(LEX) -s -t $< > $@ install: all installdirs $(libdir)/ivl$(suffix)/ivlpp@EXEEXT@ diff --git a/vhdlpp/Makefile.in b/vhdlpp/Makefile.in index 92b159fb6..b7c9115c8 100644 --- a/vhdlpp/Makefile.in +++ b/vhdlpp/Makefile.in @@ -110,9 +110,11 @@ parse.o: parse.cc lexor.cc: $(srcdir)/lexor.lex $(LEX) -s -olexor.cc $(srcdir)/lexor.lex -parse.cc parse.h: $(srcdir)/parse.y - $(YACC) --verbose -t -d -o parse.cc $(srcdir)/parse.y - mv parse.cc.h parse.h 2>/dev/null || mv parse.hh parse.h +# Build this in two steps to avoid parallel build issues (see pr3462585) +parse.cc: $(srcdir)/parse.y + $(YACC) --verbose -t -d -o $@ $< +parse.h: parse.cc + mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@ lexor_keyword.o: lexor_keyword.cc parse.h diff --git a/vpi/Makefile.in b/vpi/Makefile.in index 45dd03fee..7ce19bd14 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -125,23 +125,27 @@ system.vpi: $O $(OPP) ../vvp/libvpi.a $(CXX) @shared@ -o $@ $O $(OPP) -L../vvp $(LDFLAGS) -lvpi $(SYSTEM_VPI_LDFLAGS) sys_readmem_lex.c: $(srcdir)/sys_readmem_lex.lex - $(LEX) -t $(srcdir)/sys_readmem_lex.lex > sys_readmem_lex.c + $(LEX) -s -t $< > $@ sdf_lexor.o: sdf_lexor.c sdf_parse.h sdf_lexor.c: $(srcdir)/sdf_lexor.lex - $(LEX) -t $(srcdir)/sdf_lexor.lex > sdf_lexor.c + $(LEX) -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 table_mod_lexor.o: table_mod_lexor.c table_mod_parse.h table_mod_lexor.c: $(srcdir)/table_mod_lexor.lex - $(LEX) -t $< > $@ + $(LEX) -s -t $< > $@ -table_mod_parse.c table_mod_parse.h: $(srcdir)/table_mod_parse.y - $(YACC) --verbose -d -p tblmod -o table_mod_parse.c $< +# Build this in two steps to avoid parallel build issues (see pr3462585) +table_mod_parse.c: $(srcdir)/table_mod_parse.y + $(YACC) --verbose -t -p tblmod -d -o $@ $< +table_mod_parse.h: table_mod_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 beaf67387..4f3a59a80 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -157,11 +157,11 @@ parse.o: parse.cc tables.o: tables.cc +# Build this in two steps to avoid parallel build issues (see pr3462585) 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