Hi all! I have some trouble building a yacc parser with Automake (using ylwrap) in a parallel build. Usually, make -j runs fine on my project with no errors, but it fails occasionally when trying to build the parser. Here is a stripped down test case that demonstrates what I'm doing (using Autoconf 2.63, Automake 1.10.2):
=============== configure.ac: --------------- AC_PREREQ([2.63]) AC_INIT([testing],[0.1],[d...@not.exist]) AM_INIT_AUTOMAKE([-Wall foreign]) AC_CONFIG_SRCDIR([parser.y]) AC_CONFIG_HEADERS([config.h]) AC_PROG_CC AM_PROG_LEX AC_PROG_YACC AC_PROG_RANLIB YFLAGS="${YFLAGS} -d" AC_CONFIG_FILES([Makefile]) AC_OUTPUT =============== =============== Makefile.am: --------------- noinst_LIBRARIES=libparser.a libparser_a_SOURCES=parser.y scanner.l =============== =============== parser.y --------------- %{ #ifdef HAVE_CONFIG_H #include <config.h> #endif /* HAVE_CONFIG_H */ int yylex (void); void yyerror (char const *); %} %token NUM %token STRING %token OP %% input: NUM ; =============== =============== scanner.l --------------- %{ #ifdef HAVE_CONFIG_H #include <config.h> #endif /* HAVE_CONFIG_H */ #include <stdio.h> #include "parser.h" %} %% [0-9]+ return NUM; %% int yyerror(const char *err) { fprintf(stderr,"Error.\n"); return -1; } =============== With only these four files in some directory, execute the following commands: $ autoreconf -i configure.ac:3: installing `./install-sh' configure.ac:3: installing `./missing' Makefile.am: installing `./depcomp' configure.ac: installing `./ylwrap' $ ./configure ... $ STOP=0; while test $STOP -eq 0; do make clean && rm -f parser.[ch] scanner.c && make -j || STOP=1; done The last line cleans up the project and performs a parallel build again and again until it fails -- and it does fail after a couple of runs, sometimes straight after the first one, sometimes after 10 or even more, like this: [...] /bin/bash ./ylwrap parser.y y.tab.c parser.c y.tab.h parser.h y.output parser.output -- bison -y -d /bin/bash ./ylwrap scanner.l lex.yy.c scanner.c -- flex gcc -DHAVE_CONFIG_H -I. -g -O2 -MT scanner.o -MD -MP -MF .deps/scanner.Tpo -c -o scanner.o scanner.c scanner.l:6:20: error: parser.h: No such file or directory updating parser.h gcc -DHAVE_CONFIG_H -I. -g -O2 -MT parser.o -MD -MP -MF .deps/parser.Tpo -c -o parser.o parser.c scanner.l: In function `yylex': scanner.l:9: error: `NUM' undeclared (first use in this function) scanner.l:9: error: (Each undeclared identifier is reported only once scanner.l:9: error: for each function it appears in.) make[1]: *** [scanner.o] Error 1 [...] The file parser.h should have been generated by ylwrap/bison before compiling scanner.c, but apparently this is not always the case. I can reproduce this on Linux/amd64 (Ubuntu 8.10, dual core) and on Solaris 10/i386 (dual core), using GNU Make 3.81 on both machines. The problem seems to go away, however, when using pmake -j 4 (NetBSD make) on my Linux machine. Now, did I forget to add some additional rules to Makefile.am? Or do you think I have hit a bug in ylwrap or in GNU Make? Best regards, Robert Homann -- Windows is not the answer. Windows is the question. The answer is "No".