Discussion:
Parallel build sometimes resulting in "fatal error: config.h: No such file or directory"
Simon Sobisch
2017-10-16 19:16:04 UTC
Permalink
This only occurs sometimes but it is reproducible if I try often enough
- and I have absolutely no clue why.
I haven't spotted the executed (wrong) rule in the generated Makefiles
so I have no idea why this rule kicked in at all - maybe it is the
standard in-built C compilation rule?

Does someone else encountered this issue before or is this specific to
our sources?

This error was produced by a build scripts created by Automake 1.12.2.


Some background:
GnuCOBOL consist of one main directory with 4 sub-directories
(concerning the actual source/compilation): lib, libcob, cobc, cobcrun.

Running without `make -j` always work but using parallel builds sometime
break with the mentioned error.


The output from a testing machine can be seen below (note: the build
worked 3 times - I've always used `make clean` and ran `configure`again,
but then the error happened multiple times, 1x libcob, 1x cobc, 2x
cobcrun, then finished clean), the issue is always the same, the
*compilation command* is wrong:

~~~
gcc -O2 -pipe -finline-functions -fsigned-char -Wall -Wwrite-strings
-Wmissing-prototypes -Wno-format-y2k -U_FORTIFY_SOURCE
-Wl,-z,relro,-z,now,-O1 /home/simon/gnucobol/cobc/../cobc/cobc.c -o
../cobc/cobc
/home/simon/gnucobol/cobc/../cobc/cobc.c:26:10: fatal error: config.h:
No such file or directory
#include "config.h"
^~~~~~~~~~
compilation terminated.
~~~

where it should be (and normally does and also does on a second/third try):

~~~
gcc -DHAVE_CONFIG_H -I. -I/home/simon/gnucobol/cobc -I..
-I/home/simon/gnucobol -O2 -pipe -finline-functions -fsigned-char -Wall
-Wwrite-strings -Wmissing-prototypes -Wno-format-y2k -U_FORTIFY_SOURCE
-MT cobc-cobc.o -MD -MP -MF .deps/cobc-cobc.Tpo -c -o cobc-cobc.o `test
-f 'cobc.c' || echo '/home/simon/gnucobol/cobc/'`cobc.c
~~~

The include options and defines (and other options) are missing and I
have no clue why...


Full output (snipped the 2nd failing cobcrun as the messages was 100%
identical to the first one) is attached.


The actual .am files are in vcs at
svn://svn.code.sf.net/p/open-cobol/code/trunk
and recently hand-mirrored to git at
https://gitlab.com/GNU/cobol/tree/master


If there's anything else missing in this information please drop a note
Nick Bowler
2017-10-16 20:19:34 UTC
Permalink
Hi Simon,

On 10/16/17, Simon Sobisch <***@web.de> wrote:
[...]
Post by Simon Sobisch
Running without `make -j` always work but using parallel builds sometime
break with the mentioned error.
[...]
Post by Simon Sobisch
~~~
gcc -O2 -pipe -finline-functions -fsigned-char -Wall -Wwrite-strings
-Wmissing-prototypes -Wno-format-y2k -U_FORTIFY_SOURCE
-Wl,-z,relro,-z,now,-O1 /home/simon/gnucobol/cobc/../cobc/cobc.c -o
../cobc/cobc
No such file or directory
#include "config.h"
^~~~~~~~~~
compilation terminated.
I took a quick look at your project. The problem is likely this bit
from cobc/Makefile.am:

COBC = $(top_builddir)/cobc/cobc$(EXEEXT)

cobc.1: [...] $(COBC)

The problem is that this COBC macro does not match the Automake generated
target name. When it gets pulled in as a prerequisite for cobc.1 and the
file does not already exist, the built-in GNU make rule applies, which
produces cobc from cobc.c.

This is the wrong rule, so the compilation fails.

The prerequisites in make rules typically should match the target names
exactly. In this case, it should be:

cobc.1: [...] cobc$(EXEEXT)

Hope that helps,
Nick
Simon Sobisch
2017-10-19 19:54:36 UTC
Permalink
This worked like a charm. While the full path is needed later (when
invoking help2man) it should not be used as prerequisite.

Thank you very much!
Simon
Post by Nick Bowler
Hi Simon,
[...]
Post by Simon Sobisch
Running without `make -j` always work but using parallel builds sometime
break with the mentioned error.
[...]
Post by Simon Sobisch
~~~
gcc -O2 -pipe -finline-functions -fsigned-char -Wall -Wwrite-strings
-Wmissing-prototypes -Wno-format-y2k -U_FORTIFY_SOURCE
-Wl,-z,relro,-z,now,-O1 /home/simon/gnucobol/cobc/../cobc/cobc.c -o
../cobc/cobc
No such file or directory
#include "config.h"
^~~~~~~~~~
compilation terminated.
I took a quick look at your project. The problem is likely this bit
COBC = $(top_builddir)/cobc/cobc$(EXEEXT)
cobc.1: [...] $(COBC)
The problem is that this COBC macro does not match the Automake generated
target name. When it gets pulled in as a prerequisite for cobc.1 and the
file does not already exist, the built-in GNU make rule applies, which
produces cobc from cobc.c.
This is the wrong rule, so the compilation fails.
The prerequisites in make rules typically should match the target names
cobc.1: [...] cobc$(EXEEXT)
Hope that helps,
Nick
Loading...