diff --git a/patches/pkgbuild/gcc.sh b/patches/pkgbuild/gcc.sh index 8af489e..b22f87d 100755 --- a/patches/pkgbuild/gcc.sh +++ b/patches/pkgbuild/gcc.sh @@ -182,3 +182,22 @@ else echo "gcc: libgccjit ENABLED (second full build of the tree)" fi echo "gcc: front ends reduced, multilib off, lib32 removed" +# Bound the parallelism of gcc's own bootstrap, INSIDE the PKGBUILD. +# +# With MAKEFLAGS=-j16 the stage-2 bootstrap raced against itself: +# +# /usr/include/strings.h:23:10: fatal error: +# .../gcc-build/prev-gcc/include/stddef.h: No such file or directory +# +# The file was PRESENT when the tree was inspected afterwards. It is not +# missing -- it is generated by a rule another rule consumes without +# declaring the dependency, and sixteen jobs win that race often enough to +# fail. Read as an absent header, it sends you hunting through include paths +# for nothing. +# +# The setting has to go into build(): this hook runs in its own bash process, +# so exporting MAKEFLAGS here would never reach makepkg. gcc is the only +# package in the list that bootstraps itself three times, so the bound is +# applied here rather than globally. +sed -i '0,/^build() {$/s//build() {\n export MAKEFLAGS="-j8"/' PKGBUILD +grep -A1 '^build() {' PKGBUILD | head -2 | sed 's/^/ /'