Subject: bug#55665: GCC fails to cross-compile

From: Pavel Shlyak <[email-masked]>
Date: Thu, 26 May 2022 20:21:19 +0300

GCC fails to cross-compile. X86_64 host, aarch64 target.
Reproducer:
guix build gcc-toolchain --target=aarch64-linux-gnu
Log:
../../../gcc-12.1.0/libgcc/libgcc2.c: In function ‘__divsc3’:
../../../gcc-12.1.0/libgcc/libgcc2.c:1874:16: error: ‘__LIBGCC_SF_MAX__’ undeclared (first use in this function)
 1874 | # define RBIG (__LIBGCC_SF_MAX__ / 2)
      |                ^~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2063:23: note: in expansion of macro ‘RBIG’
 2063 |       if (FABS (d) >= RBIG)
      |                       ^~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:1874:16: note: each undeclared identifier is reported only once for each function it appears in
 1874 | # define RBIG (__LIBGCC_SF_MAX__ / 2)
      |                ^~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2063:23: note: in expansion of macro ‘RBIG’
 2063 |       if (FABS (d) >= RBIG)
      |                       ^~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:1876:17: error: ‘__LIBGCC_SF_EPSILON__’ undeclared (first use in this function)
 1876 | # define RMIN2 (__LIBGCC_SF_EPSILON__)
      |                 ^~~~~~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2073:22: note: in expansion of macro ‘RMIN2’
 2073 |       if (FABS (d) < RMIN2)
      |                      ^~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:1875:16: error: ‘__LIBGCC_SF_MIN__’ undeclared (first use in this function)
 1875 | # define RMIN (__LIBGCC_SF_MIN__)
      |                ^~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2082:21: note: in expansion of macro ‘RMIN’
 2082 |    if (((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (d) < RMAX2))
      |                     ^~~~
make[2]: *** [Makefile:501: _divsc3.o] Error 1
../../../gcc-12.1.0/libgcc/libgcc2.c: In function ‘__divdc3’:
make[2]: *** Waiting for unfinished jobs....
../../../gcc-12.1.0/libgcc/libgcc2.c:1885:16: error: ‘__LIBGCC_DF_MAX__’ undeclared (first use in this function)
 1885 | # define RBIG (__LIBGCC_DF_MAX__ / 2)
      |                ^~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2063:23: note: in expansion of macro ‘RBIG’
 2063 |       if (FABS (d) >= RBIG)
      |                       ^~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:1885:16: note: each undeclared identifier is reported only once for each function it appears in
 1885 | # define RBIG (__LIBGCC_DF_MAX__ / 2)
      |                ^~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2063:23: note: in expansion of macro ‘RBIG’
 2063 |       if (FABS (d) >= RBIG)
      |                       ^~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:1887:17: error: ‘__LIBGCC_DF_EPSILON__’ undeclared (first use in this function)
 1887 | # define RMIN2 (__LIBGCC_DF_EPSILON__)
      |                 ^~~~~~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2073:22: note: in expansion of macro ‘RMIN2’
 2073 |       if (FABS (d) < RMIN2)
      |                      ^~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:1886:16: error: ‘__LIBGCC_DF_MIN__’ undeclared (first use in this function)
 1886 | # define RMIN (__LIBGCC_DF_MIN__)
      |                ^~~~~~~~~~~~~~~~~
../../../gcc-12.1.0/libgcc/libgcc2.c:2082:21: note: in expansion of macro ‘RMIN’
 2082 |    if (((FABS (a) < RMIN) && (FABS (b) < RMAX2) && (FABS (d) < RMAX2))
      |                     ^~~~
make[2]: *** [Makefile:501: _divdc3.o] Error 1
make[2]: Leaving directory '/tmp/guix-build-gcc-12.1.0.drv-0/build/aarch64-linux-gnu/libgcc'
make[1]: *** [Makefile:14447: all-target-libgcc] Error 2