Bug 14953

Summary: gcc-cross-canadian-x86-64 do_install failure
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Alexandre Belloni <alexandre.belloni>
Component: devtools / tool chainAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: alexandre.belloni, meta.mr.watcher, meta.watcher, randy.macleod, richard.purdie
Version: unspecified   
Target Milestone: 4.2 M1   
Hardware: x86   
OS: Multiple   
Whiteboard: AB-INT
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Alexandre Belloni 2022-10-31 23:15:01 UTC
do_install fails while building gcc which is weird:

g++  -c -DIN_GCC     -isystem/home/pokybuild/yocto-worker/genericx86-64/build/build/tmp/work/i686-nativesdk-pokysdk-linux/nativesdk-gcc/12.2.0-r0/recipe-sysroot-native/usr/include -O2 -pipe  -DGENERATOR_FILE -I. -Ibuild -I../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc -I../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/build -I../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/../include  -I../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/../libcpp/include  \
| 	-o build/gengtype-lex.o ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc
| In file included from ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc:1:
| ./config.h:4:2: error: #error config.h is for the host, not build, machine.
|     4 | #error config.h is for the host, not build, machine.
|       |  ^~~~~
| ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc:2:2: error: #else without #if
|     2 | #else
|       |  ^~~~
| In file included from ./bconfig.h:3

https://autobuilder.yoctoproject.org/typhoon/#builders/37/builds/6075/steps/11/logs/stdio

genericx86-64 fedora35-ty-2
Comment 1 Alexandre Belloni 2022-10-31 23:16:16 UTC
builddir saved as bug14953 on fedora35-ty-2
Comment 2 Richard Purdie 2022-11-01 14:49:23 UTC
$ cat gengtype-lex.cc 
#include "config.h"
#else
#include "bconfig.h"
#endif
#ifdef HOST_GENERATOR_FILE

which compared to my local build is completely wrong.

Something has corrupted the file which is why the two builds fail, the question then becomes how did this file in the shared workdir become corrupted. It may be related to the presence or lack of presence of flex and the file being regenerated in some cases?
Comment 3 Richard Purdie 2022-11-01 14:52:13 UTC
log.do_install.2834110  contains:

flex  -o../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.l && { \
  echo '#ifdef HOST_GENERATOR_FILE' > ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#include "config.h"'       >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#else'                     >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#include "bconfig.h"'      >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#endif'                    >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  cat ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  mv ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc; \

log.do_install.2834128 contains:

flex  -o../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.l && { \
  echo '#ifdef HOST_GENERATOR_FILE' > ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#include "config.h"'       >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#else'                     >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#include "bconfig.h"'      >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  echo '#endif'                    >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  cat ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc >> ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp; \
  mv ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc.tmp ../../../../../../../work-shared/gcc-12.2.0-r0/gcc-12.2.0/gcc/gengtype-lex.cc; \

so likely a race between them?
Comment 4 Richard Purdie 2022-11-01 14:54:48 UTC
My local build has flex in the recipe sysroot but doesn't regenerate this file. I'm not sure why it thought it needed to regenerate gengtype-lex.cc on the autobuilder build.
Comment 5 Richard Purdie 2022-11-03 12:43:00 UTC
There were several issues. The gengtype regeneration code in gcc hadn't been updated with the .c -> .cc file move in upstream. The gcc shared workdir was also causing timestamp problems in general as the SDE wasn't propagating to the recipe workdir. If that is fixed, the gengtype file deletion can also simply be removed. Patches on the list doing all that which should resolve this issue.