Bug 96160 - Building gcc with multiple make jobs fails with: gcc/xgcc: No such file or directory
Summary: Building gcc with multiple make jobs fails with: gcc/xgcc: No such file or di...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 10.1.0
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL: https://bugs.gentoo.org/728304
Keywords: build
: 95840 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-07-10 20:53 UTC by plevine457
Modified: 2021-08-03 16:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
build.log.bz2 (228.29 KB, application/x-bzip)
2020-07-10 20:53 UTC, plevine457
Details
gcc-10.1.0-xgcc-selftest-makeopts.patch (274 bytes, patch)
2020-07-10 20:56 UTC, plevine457
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description plevine457 2020-07-10 20:53:47 UTC
Created attachment 48860 [details]
build.log.bz2

Building GCC with multiple make jobs appears to trigger a race condition.  The build often fails with:

> /var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/build/./gcc/xgcc -B/var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/build/./gcc/ -xc++ -nostdinc /dev/null -S -o /dev/null -fself-test=/var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/gcc-10.1.0/gcc/testsuite/selftests
> /bin/bash: /var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/build/./gcc/xgcc: No such file or directory
> make[3]: *** [/var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/gcc-10.1.0/gcc/cp/Make-lang.in:178: s-selftest-c++] Error 127

This has been noticeable at least since GCC-9.x.

Reported downstream at https://bugs.gentoo.org/728304.
Likely related to https://github.com/cirosantilli/linux-kernel-module-cheat/issues/108

uname: Linux Laptop-PC 5.7.8-gentoo #1 SMP Fri Jul 10 04:05:05 EDT 2020 x86_64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz GenuineIntel GNU/Linux
Comment 1 plevine457 2020-07-10 20:56:16 UTC
Created attachment 48861 [details]
gcc-10.1.0-xgcc-selftest-makeopts.patch

This patch appears to resolve the issue on my end
Comment 2 Andrew Pinski 2020-07-10 21:17:46 UTC
Makefile.in:
GCC_PASSES=xgcc$(exeext) specs

SELFTEST_DEPS = $(GCC_PASSES) stmp-int-hdrs $(srcdir)/testsuite/selftests


c/Make-lang.in

C_SELFTEST_DEPS = cc1$(exeext) $(SELFTEST_DEPS)
...

s-selftest-c: $(C_SELFTEST_DEPS)

cp/Make-lang.in:
CPP_SELFTEST_DEPS = cc1plus$(exeext) $(SELFTEST_DEPS)
...
selftest-c++: s-selftest-c++
...
s-selftest-c++: $(CPP_SELFTEST_DEPS)

---- CUT ---

This looks correct to me.  xgcc is there already in the depends of s-selftest-c++.
Which make version are you using?
Comment 3 plevine457 2020-07-10 21:57:05 UTC
> Which make version are you using?
GNU Make 4.3
Comment 4 plevine457 2020-07-11 03:05:46 UTC
The offending command is
> /var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/build/./gcc/xgcc -B/var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/build/./gcc/ -xc++ -nostdinc /dev/null -S -o /dev/null -fself-test=/var/tmp/portage/sys-devel/gcc-10.1.0-r1/work/gcc-10.1.0/gcc/testsuite/selftests

I would presume that there's no reason why gcc would emit "-o /dev/null"  though I have seen it whaile using ccache.  

Looking further at https://github.com/buildroot/buildroot/commit/58ecbbc3ef18c43ae1c02a5c4bf30aa7ef2d8092, with regard to s-selftest-c:

> The problem only occurs when ccache is used with gcc 9 and 10,
> probably due to a race condition.
> 
> While debuging with "make -p" we can notice that s-selftest-c target
> contain only "cc1" as dependency instead of cc1 and SELFTEST_DEPS [4].
> 
>   s-selftest-c: cc1
> 
> While the build is failing, the s-selftest-c dependencies recipe is
> still running and reported as a bug by make.
> 
>   "Dependencies recipe running (THIS IS A BUG)."
> 
> A change [5] in gcc 9 seems to introduce the problem since we can't
> reproduce this problem with gcc 8.

So this is likely a ccache bug.
Comment 5 Andrew Pinski 2021-05-30 23:33:55 UTC
Has been fixed since June of last year with r11-881.
Comment 6 Andrew Pinski 2021-08-03 16:02:10 UTC
*** Bug 95840 has been marked as a duplicate of this bug. ***