Subject: VPATH build fails

From: Bruno Haible <[email-masked]>
Date: Sat, 05 Jul 2025 11:59:19 +0200

Hi,

The coreutils CI build part that does a "make distcheck" today fails,
whereas on 2025-06-30 it succeeded [1].

The problem can be reproduced as follows:

1)
$ ./bootstrap --no-git --gnulib-srcdir=$GNULIB_SRCDIR
$ ./configure
$ make
$ make dist

2)
Unpack the tarball, cd into its directory.

3)
$ mkdir bb
$ cd bb
$ ../configure
$ make V=1
...
depbase=`echo src/pinky.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc  -I. -I.. -I./lib  -Ilib -I../lib -Isrc -I../src    -g -O2 -MT src/pinky.o -MD -MP -MF $depbase.Tpo -c -o src/pinky.o ../src/pinky.c &&\
mv -f $depbase.Tpo $depbase.Po
gcc   -g -O2 -Wl,--as-needed  -o src/pinky src/pinky.o src/libver.a lib/libcoreutils.a   lib/libcoreutils.a   
rm -f src/speedlist.h
/arch/local/x86_64-linux/bin/mkdir -p src
( for opt in -dM -xdumpmacros -qshowmacros -PD; do \
                gcc  -I. -I.. -I./lib  -Ilib -I../lib -Isrc -I../src    -g -O2 -E $opt ../src/termios.c 2>&1 && break; \
            done ) | /bin/bash ../src/speedgen src/speedlist.ht
chmod a-w src/speedlist.ht
mv src/speedlist.ht src/speedlist.h
depbase=`echo src/stty.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc  -I. -I.. -I./lib  -Ilib -I../lib -Isrc -I../src    -g -O2 -MT src/stty.o -MD -MP -MF $depbase.Tpo -c -o src/stty.o src/stty.c &&\
mv -f $depbase.Tpo $depbase.Po
cc1: fatal error: src/stty.c: No such file or directory
compilation terminated.
make[2]: *** [Makefile:13092: src/stty.o] Error 1
make[2]: Leaving directory '/COREUTILS/coreutils/coreutils-20250411/bb'
make[1]: *** [Makefile:23441: all-recursive] Error 1
make[1]: Leaving directory '/COREUTILS/coreutils/coreutils-20250411/bb'
make: *** [Makefile:9356: all] Error 2

Comparing the compilation commands for pinky.c and stty.c, you can see
that ../src/pinky.c and src/stty.c are referenced. But in a VPATH build,
src/stty.c does not exist.

This is caused by commit 017fc50bb6797ac2d71e46fef8f559acb0f44c5d.
If I locally revert this commit, "make V=1" succeeds.

Bruno

[1] https://github.com/coreutils/ci-check/actions