Bug 57125 - Build not SMP safe; fails to build bconfig.h
Summary: Build not SMP safe; fails to build bconfig.h
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2013-04-30 12:30 UTC by enrico.scholz
Modified: 2015-08-10 10:10 UTC (History)
9 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:

Full build log (19.49 KB, text/plain)
2013-04-30 12:30 UTC, enrico.scholz
Possible fix (433 bytes, patch)
2014-08-29 20:58 UTC, Andrew Oakley
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description enrico.scholz 2013-04-30 12:30:11 UTC
Created attachment 29983 [details]
Full build log

When building gcc-4.8 (patched by OpenEmbedded) with '-j 8', the build fails from time to time because bconfig.h can not be found.  A subsequent make succeeds in these cases.
Comment 1 Ryan Hill 2013-10-12 05:42:16 UTC
This was partially fixed by http://gcc.gnu.org/ml/gcc-patches/2012-11/msg01682.html but gengtype.c, gengtype-parse.c, and gengtype-state.c also include bconfig.h if -DGENERATOR_FILE is defined.
Comment 2 Vladimír Čunát 2014-01-03 09:23:03 UTC
In this matter I'm quite confused by the intentions of http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00273.html

It states that host object files depend on CONFIG_H, but these seem to get in fact built with -DGENERATOR_FILE (according to build log), so through gentype.c, they include bconfig.h instead of config.h. I don't see that reflected in build dependencies, and more importantly, I'm not even sure this consequence was intended/correct.
Comment 3 Volker Braun 2014-03-24 17:59:24 UTC
As another data point, I have randomly encountered this issue on ia64 with gcc-4.7.3 

gcc -c  -DUSE_LIBUNWIND_EXCEPTIONS  -O0 -DIN_GCC   -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common -Wno-error -DHAVE_CONFIG_H -I. -I. -I../../src/gcc -I../../src/gcc/. -I../../src/gcc/../include -I../../src/gcc/../libcpp/include -I/home/buildbot/build/sage/iras-1/sage_git/build/local/include -I/home/buildbot/build/sage/iras-1/sage_git/build/local/include -I/home/buildbot/build/sage/iras-1/sage_git/build/local/include  -I../../src/gcc/../libdecnumber -I../../src/gcc/../libdecnumber/dpd -I../libdecnumber    ../../src/gcc/gengtype-lex.c -o gengtype-lex.o
../../src/gcc/gengtype-lex.c:1:21: fatal error: bconfig.h: No such file or directory
compilation terminated.
make[6]: *** [gengtype-lex.o] Error 1
Comment 5 Andrew Oakley 2014-08-29 20:58:29 UTC
Created attachment 33419 [details]
Possible fix

Attached is a patch which appears to fix this issue for me (on gcc 4.8.3).

In gcc/Makefile.in there is a comment:
# The gengtype generator program is special: Two versions are built.
# One is for the build machine, and one is for the host to allow
# plugins to define their types and generate the supporting GGC
# datastructures and routines with GTY markers.
# The host object files depend on CONFIG_H, and the build objects
# on BCONFIG_H.  For the build objects, add -DGENERATOR_FILE manually,
# the build-%: rule doesn't apply to them.

The change I chose to make swaps the make dependencies around, alternatively GENERATOR_FILE may defined in the wrong case.  I'm not sure what the right behaviour is here, or which set of objects is which!
Comment 6 Andrew Oakley 2014-08-29 22:15:52 UTC
Sorry, this patch doesn't seem sufficient (perhaps I was just lucky for a while).  Apologies for the noise.
Comment 7 Cody P Schafer 2014-11-05 22:54:45 UTC
I'm seeing this with gentoo's gcc-4.9.2
Comment 8 Mike Frysinger 2015-03-31 03:30:47 UTC
(In reply to Vladimír Čunát from comment #2)

i think you're spot on -- the logic is inverted

(In reply to Andrew Oakley from comment #5)

i think this patch is incorrect.  you're inverting what the Makefile explicitly is saying to do.  namely, build/%.o should be depending on $(BCONFIG_H) and they should be building with -DGENERATOR_FILE.  so the CFLAGS- lines need fixing.

looking at trunk, this appears to be fixed here:

the compile logic was inverted so that bconfig.h is included by default, and to get config.h you have to define HOST_GENERATOR_FILE.  then the CFLAGS-xxx line was updated to use that.

i guess we keep this open so hopefully it'll get backported to gcc-4.9 ?
Comment 9 Mike Frysinger 2015-08-10 10:10:03 UTC
after having the backport deployed in Gentoo, we found an edge case with the fix in trunk ...

we still have this rule in gcc/Makefile.in:
# Generated source files for gengtype.  Prepend inclusion of
# bconfig.h because AIX requires _LARGE_FILES to be defined before
# any system header is included.
gengtype-lex.c : gengtype-lex.l
    -$(FLEX) $(FLEXFLAGS) -o$@ $< && { \
      echo '#include "bconfig.h"' > $@.tmp; \
      cat $@ >> $@.tmp; \
      mv $@.tmp $@; \

so even though gengtype-lex.l was adapted to not include bconfig.h when HOST_GENERATOR_FILE is defined, and the bconfig.h dep on that file was dropped, the source still tries to always include it for both host & build modes.

i don't really understand the comment ... it seems to me that the lex file will include the right config.h header files first already, so we should drop the explicit insertion of bconfig.h here.