Subject: bug#57631: Coreutils 9.1 build error with glibc 2.23

From: Satadru Pramanik <[email-masked]>
Date: Tue, 6 Sep 2022 13:45:47 -0400

Hello all,

I'm a dev for the Chromebrew distribution. We're supporting older hardware
with ChromeOS, and we're having some trouble building Coreutils 9.1 against
the glibc 2.23 which comes on older i686 Chromebooks. We are using GCC
12.2, and the mold linker. We have no problems building this with the same
arguments on x86_64 and armv7l with glibc 2.27.

Configure line is:
./configure --prefix=/usr/local --libdir=/usr/local/lib
--mandir=/usr/local/share/man --build=i686-cros-linux-gnu
--host=i686-cros-linux-gnu --target=i686-cros-linux-gnu --program-prefix=''
--program-suffix=''"

The error we are seeing is below. Any ideas on what we should do to work
around this?

(Due to the nature of this hardware, we are unable to update the glibc on
these machines.)

  GEN      src/coreutils.h
  GEN      src/version.c
  GEN      src/version.h
make  all-recursive
make[1]: Entering directory
'/usr/local/tmp/crew/coreutils.20220906165907.dir/coreutils-9.1'
Making all in po
make[2]: Entering directory
'/usr/local/tmp/crew/coreutils.20220906165907.dir/coreutils-9.1/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory
'/usr/local/tmp/crew/coreutils.20220906165907.dir/coreutils-9.1/po'
Making all in .
make[2]: Entering directory
'/usr/local/tmp/crew/coreutils.20220906165907.dir/coreutils-9.1'
  CC       lib/libcoreutils_a-long-options.o
  CC       lib/libcoreutils_a-malloca.o
  CC       lib/libcoreutils_a-mbchar.o
  CC       lib/libcoreutils_a-math.o
In file included from /usr/local/include/string.h:630,
                 from ./lib/string.h:41,
                 from lib/mbchar.h:148,
                 from lib/mbchar.c:23:
./lib/string.h:1091:1: error: expected identifier or '(' before
'__extension__'
 1091 | _GL_FUNCDECL_SYS (strndup, char *,
      | ^~~~~~~~~~~~~~~~
make[2]: *** [Makefile:14554: lib/libcoreutils_a-mbchar.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory
'/usr/local/tmp/crew/coreutils.20220906165907.dir/coreutils-9.1'
make[1]: *** [Makefile:21011: all-recursive] Error 1
make[1]: Leaving directory
'/usr/local/tmp/crew/coreutils.20220906165907.dir/coreutils-9.1'
make: *** [Makefile:8269: all] Error 2
coreutils failed to build: `CFLAGS="-O2 -pipe -ffat-lto-objects -fPIC
-fuse-ld=mold  -flto" CXXFLAGS="-O2 -pipe -ffat-lto-objects -fPIC
-fuse-ld=mold  -flto" FCFLAGS="-O2 -pipe -ffat-lto-objects -fPIC
-fuse-ld=mold  -flto" FFLAGS="-O2 -pipe -ffat-lto-objects -fPIC
-fuse-ld=mold  -flto" LDFLAGS="-flto " bash -c make

(We can also provide the docker commands to replicate the docker build
environment we use for this architecture if that would help.)