devel::host-compat-toolchain fails for aarch64 targets: gmp.h not found (GCC t-aarch64 ALL_SPPFLAGS typo)
Summary
devel::host-compat-toolchain cannot be built whenever its isolation toolchain targets an aarch64 machine. The build dies in devel::compat::gcc-cross-bare:
In file included from gcc/config/aarch64/aarch64-speculation.cc:22:
gcc/system.h:687:10: fatal error: gmp.h: No such file or directory
687 | #include <gmp.h>
make[2]: *** [gcc/config/aarch64/t-aarch64:81: aarch64-speculation.o] Error 1
Failed package:
devel::host-compat-toolchain/devel::compat::cross-toolchain/devel::compat::gcc-cross/libs::compat::glibc/devel::compat::gcc-cross-bare
Root cause
gcc/config/aarch64/t-aarch64 has a typo in the rule that builds aarch64-speculation.o:
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_SPPFLAGS) $(INCLUDES) \
^^^^^^^^^^^^^^
$(srcdir)/config/aarch64/aarch64-speculation.cc
Every other rule in that very same file uses $(ALL_CPPFLAGS). ALL_SPPFLAGS is undefined, so it expands to nothing and, because
ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS), the whole $(CPPFLAGS) part is silently dropped from that one compile line.
recipes/devel/compat/gcc.yaml locates gmp/mpfr/mpc/isl by appending -I flags to CPPFLAGS (see the loop over $2..$5 in its buildScript), not by passing --with-gmp-include & friends to configure. Those include paths therefore never reach aarch64-speculation.cc.
Verified present in GCC 9.5.0 (the version devel::compat::gcc uses) and in GCC 11.4.0. It is also still present on current GCC master, where it has meanwhile been copy-pasted into a second rule (aarch64-elf-metadata.o), so an upstream GCC fix does not look imminent.
Who is affected
- Native aarch64 build hosts.
recipes/devel/host-compat-toolchain.yaml configures the isolation toolchain with AUTOCONF_TARGET: "$(gen-autoconf,bob_isolation)", and $(gen-autoconf,...) derives the machine from the build machine. On an arm64 host that is aarch64-bob_isolation-linux-gnu, so t-aarch64 is used and the build breaks. As far as I can tell devel::host-compat-toolchain — and therefore basement::rootrecipe — simply cannot be built on aarch64 today.
- Any setup where the sandbox architecture is aarch64 (this is how we ran into it).
Why nobody hit this so far
- With an x86_64 target, GCC uses
config/i386/t-i386 and never reads t-aarch64 at all.
recipes/devel/gcc.yaml (the non-compat GCC) has the identical typo in its 11.4.0 source but is unaffected, because it passes --with-gmp-include=... to configure. That lands in GMPINC, which is part of $(INCLUDES) — and $(INCLUDES) is present on the broken compile line.
Two possible fixes
- Patch the GCC source. Add a patch to the
devel::compat::gcc series that turns $(ALL_SPPFLAGS) into $(ALL_CPPFLAGS). One-line, obviously
correct, applies with zero fuzz.
- Change the recipe. Make
recipes/devel/compat/gcc.yaml pass --with-gmp-include/--with-gmp-lib (and mpfr/mpc/isl) like recipes/devel/gcc.yaml already does, instead of relying on CPPFLAGS. More invasive, but it removes the dependency on a GCC makefile detail and would also fix the linker side.
- Which of the two would you prefer for basement?
- If it is the patch: should the same patch also be added to the
recipes/devel/gcc/ series for consistency, even though that GCC is not affected in practice? That would invalidate the cached artifacts of every GCC build.
- Note that either fix changes the variant-id of
devel::compat::gcc and thus forces a one-time rebuild of the compat toolchain on x86_64 as well (bit-identical result, since t-aarch64 is not used there).
devel::host-compat-toolchain fails for aarch64 targets: gmp.h not found (GCC t-aarch64 ALL_SPPFLAGS typo)
Summary
devel::host-compat-toolchaincannot be built whenever its isolation toolchain targets an aarch64 machine. The build dies indevel::compat::gcc-cross-bare:Failed package:
devel::host-compat-toolchain/devel::compat::cross-toolchain/devel::compat::gcc-cross/libs::compat::glibc/devel::compat::gcc-cross-bareRoot cause
gcc/config/aarch64/t-aarch64has a typo in the rule that buildsaarch64-speculation.o:$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_SPPFLAGS) $(INCLUDES) \ ^^^^^^^^^^^^^^ $(srcdir)/config/aarch64/aarch64-speculation.ccEvery other rule in that very same file uses
$(ALL_CPPFLAGS).ALL_SPPFLAGSis undefined, so it expands to nothing and, becauseALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS), the whole$(CPPFLAGS)part is silently dropped from that one compile line.recipes/devel/compat/gcc.yamllocates gmp/mpfr/mpc/isl by appending-Iflags toCPPFLAGS(see the loop over$2..$5in itsbuildScript), not by passing--with-gmp-include& friends to configure. Those include paths therefore never reachaarch64-speculation.cc.Verified present in GCC 9.5.0 (the version
devel::compat::gccuses) and in GCC 11.4.0. It is also still present on current GCC master, where it has meanwhile been copy-pasted into a second rule (aarch64-elf-metadata.o), so an upstream GCC fix does not look imminent.Who is affected
recipes/devel/host-compat-toolchain.yamlconfigures the isolation toolchain withAUTOCONF_TARGET: "$(gen-autoconf,bob_isolation)", and$(gen-autoconf,...)derives the machine from the build machine. On an arm64 host that isaarch64-bob_isolation-linux-gnu, sot-aarch64is used and the build breaks. As far as I can telldevel::host-compat-toolchain— and thereforebasement::rootrecipe— simply cannot be built on aarch64 today.Why nobody hit this so far
config/i386/t-i386and never readst-aarch64at all.recipes/devel/gcc.yaml(the non-compat GCC) has the identical typo in its 11.4.0 source but is unaffected, because it passes--with-gmp-include=...to configure. That lands inGMPINC, which is part of$(INCLUDES)— and$(INCLUDES)is present on the broken compile line.Two possible fixes
devel::compat::gccseries that turns$(ALL_SPPFLAGS)into$(ALL_CPPFLAGS). One-line, obviouslycorrect, applies with zero fuzz.
recipes/devel/compat/gcc.yamlpass--with-gmp-include/--with-gmp-lib(and mpfr/mpc/isl) likerecipes/devel/gcc.yamlalready does, instead of relying onCPPFLAGS. More invasive, but it removes the dependency on a GCC makefile detail and would also fix the linker side.recipes/devel/gcc/series for consistency, even though that GCC is not affected in practice? That would invalidate the cached artifacts of every GCC build.devel::compat::gccand thus forces a one-time rebuild of the compat toolchain on x86_64 as well (bit-identical result, sincet-aarch64is not used there).