[SOLVED] ERROR: tools/m4 failed to build

On Arch Linux a new OpenWrt compilation crashes almost instantaneously:

sil@laptop:~/openwrt$ make
WARNING: Makefile 'package/feeds/packages/glib2/Makefile' has a build dependency on 'pcre2/host', which does not exist
make[2]: Entering directory '/home/sil/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/home/sil/openwrt/scripts/config'
make[4]: Entering directory '/home/sil/openwrt/target/linux'
make[5]: Entering directory '/home/sil/openwrt/target/linux/ramips'
make[6]: Entering directory '/home/sil/openwrt/target/linux/ramips/image'
make[6]: Leaving directory '/home/sil/openwrt/target/linux/ramips/image'
make[5]: Leaving directory '/home/sil/openwrt/target/linux/ramips'
make[4]: Leaving directory '/home/sil/openwrt/target/linux'
time: target/linux/prereq#1.10#0.16#1.25
 make[1] world
 make[2] tools/compile
 make[3] -C tools/flock compile
 make[3] -C tools/xz compile
 make[3] -C tools/sed compile
 make[3] -C tools/tar compile
 make[3] -C tools/patch compile
 make[3] -C tools/m4 compile
    ERROR: tools/m4 failed to build.
make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on
make: *** [/home/sil/openwrt/include/toplevel.mk:230: world] Error 1
sil@laptop:~/openwrt$ make -j1 V=s
WARNING: Makefile 'package/feeds/packages/glib2/Makefile' has a build dependency on 'pcre2/host', which does not exist
make[2]: Entering directory '/home/sil/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/home/sil/openwrt/scripts/config'
make[1]: Entering directory '/home/sil/openwrt'
make[2]: Entering directory '/home/sil/openwrt'
+ mkdir -p /home/sil/openwrt/staging_dir/target-mipsel_24kc_musl
+ cd /home/sil/openwrt/staging_dir/target-mipsel_24kc_musl
+ mkdir -p bin lib stamp usr/include usr/lib
mkdir -p /home/sil/openwrt/build_dir/target-mipsel_24kc_musl/stamp
touch /home/sil/openwrt/staging_dir/target-mipsel_24kc_musl/.prepared
+ mkdir -p /home/sil/openwrt/staging_dir/host
+ cd /home/sil/openwrt/staging_dir/host
+ mkdir -p bin lib stamp usr/include usr/lib
mkdir -p /home/sil/openwrt/build_dir/host/stamp /home/sil/openwrt/staging_dir/host/include/sys
install -m0644 /home/sil/openwrt/tools/include/*.h /home/sil/openwrt/staging_dir/host/include/
install -m0644 /home/sil/openwrt/tools/include/sys/*.h /home/sil/openwrt/staging_dir/host/include/sys/
ln -snf lib /home/sil/openwrt/staging_dir/host/lib64
touch /home/sil/openwrt/staging_dir/host/.prepared
make[3]: Entering directory '/home/sil/openwrt/tools/flock'
make[3]: Leaving directory '/home/sil/openwrt/tools/flock'
time: tools/flock/compile#0.07#0.04#0.11
make[3]: Entering directory '/home/sil/openwrt/tools/xz'
make[3]: Leaving directory '/home/sil/openwrt/tools/xz'
time: tools/xz/compile#0.06#0.08#0.14
make[3]: Entering directory '/home/sil/openwrt/tools/sed'
make[3]: Leaving directory '/home/sil/openwrt/tools/sed'
time: tools/sed/compile#0.06#0.09#0.14
make[3]: Entering directory '/home/sil/openwrt/tools/tar'
make[3]: Leaving directory '/home/sil/openwrt/tools/tar'
time: tools/tar/compile#0.08#0.07#0.14
make[3]: Entering directory '/home/sil/openwrt/tools/patch'
make[3]: Leaving directory '/home/sil/openwrt/tools/patch'
time: tools/patch/compile#0.06#0.08#0.14
make[3]: Entering directory '/home/sil/openwrt/tools/m4'
CFLAGS="-O2 -I/home/sil/openwrt/staging_dir/host/include " CPPFLAGS="-I/home/sil/openwrt/staging_dir/host/include " CXXFLAGS="" LDFLAGS="-L/home/sil/openwrt/staging_dir/host/lib " make  -C /home/sil/openwrt/build_dir/host/m4-1.4.19  
make[4]: Entering directory '/home/sil/openwrt/build_dir/host/m4-1.4.19'
make  all-recursive
make[5]: Entering directory '/home/sil/openwrt/build_dir/host/m4-1.4.19'
Making all in .
make[6]: Entering directory '/home/sil/openwrt/build_dir/host/m4-1.4.19'
make[6]: Nothing to be done for 'all-am'.
make[6]: Leaving directory '/home/sil/openwrt/build_dir/host/m4-1.4.19'
Making all in examples
make[6]: Entering directory '/home/sil/openwrt/build_dir/host/m4-1.4.19/examples'
make[6]: Nothing to be done for 'all'.
make[6]: Leaving directory '/home/sil/openwrt/build_dir/host/m4-1.4.19/examples'
Making all in lib
make[6]: Entering directory '/home/sil/openwrt/build_dir/host/m4-1.4.19/lib'
make  all-am
make[7]: Entering directory '/home/sil/openwrt/build_dir/host/m4-1.4.19/lib'
depbase=`echo asyncsafe-spin.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc  -I.   -I/home/sil/openwrt/staging_dir/host/include   -O2 -I/home/sil/openwrt/staging_dir/host/include  -MT asyncsafe-spin.o -MD -MP -MF $depbase.Tpo -c -o asyncsafe-spin.o asyncsafe-spin.c &&\
mv -f $depbase.Tpo $depbase.Po
depbase=`echo openat-proc.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc  -I.   -I/home/sil/openwrt/staging_dir/host/include   -O2 -I/home/sil/openwrt/staging_dir/host/include  -MT openat-proc.o -MD -MP -MF $depbase.Tpo -c -o openat-proc.o openat-proc.c &&\
mv -f $depbase.Tpo $depbase.Po
depbase=`echo gl_avltree_oset.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc  -I.   -I/home/sil/openwrt/staging_dir/host/include   -O2 -I/home/sil/openwrt/staging_dir/host/include  -MT gl_avltree_oset.o -MD -MP -MF $depbase.Tpo -c -o gl_avltree_oset.o gl_avltree_oset.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from gl_avltree_oset.h:21,
                 from gl_avltree_oset.c:21:
gl_oset.h:275:1: warning: 'nodiscard' attribute ignored [-Wattributes]
  275 | GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
      | ^~~~~~~~~~~~~~
gl_oset.h:275:40: error: expected identifier or '(' before 'int'
  275 | GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
      |                                        ^~~
make[7]: *** [Makefile:2866: gl_avltree_oset.o] Error 1
make[7]: Leaving directory '/home/sil/openwrt/build_dir/host/m4-1.4.19/lib'
make[6]: *** [Makefile:2481: all] Error 2
make[6]: Leaving directory '/home/sil/openwrt/build_dir/host/m4-1.4.19/lib'
make[5]: *** [Makefile:2018: all-recursive] Error 1
make[5]: Leaving directory '/home/sil/openwrt/build_dir/host/m4-1.4.19'
make[4]: *** [Makefile:1974: all] Error 2
make[4]: Leaving directory '/home/sil/openwrt/build_dir/host/m4-1.4.19'
make[3]: *** [Makefile:30: /home/sil/openwrt/build_dir/host/m4-1.4.19/.built] Error 2
make[3]: Leaving directory '/home/sil/openwrt/tools/m4'
time: tools/m4/compile#0.53#0.27#0.80
    ERROR: tools/m4 failed to build.
make[2]: *** [tools/Makefile:166: tools/m4/compile] Error 1
make[2]: Leaving directory '/home/sil/openwrt'
make[1]: *** [tools/Makefile:162: /home/sil/openwrt/staging_dir/host/stamp/.tools_compile_yyynyynnyyyynyyyyyynyynyyynynyyyyyyyyyyyyyyyyynynnyyyyyyy] Error 2
make[1]: Leaving directory '/home/sil/openwrt'
make: *** [/home/sil/openwrt/include/toplevel.mk:230: world] Error 2

m4 is installed:

sil@laptop:~/openwrt$ sudo pacman -Ss m4
core/m4 1.4.20-1 [installed]
    The GNU macro processor

but version 1.4.20 where OpenWrt seems to be looking for m4-1.4.19.

So I downgraded to 1.4.19-3. Same error.

Any ideas?

What is the OpenWrt version you are trying to compile, and your host compiler version?

Thank you for taking the time to help.

I tried to compile v24.10.0 first and then v22.03.7. They compiled before without any problem. Now they don't anymore.

You mean gcc?

sil@laptop:~$ gcc --version
gcc (GCC) 15.1.1 20250425
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Everything is up-to-date. Maybe that's the problem. v24.10.0 compiled perfectly six weeks ago. Something has broken since then, e.g. m4. I don't even know what it is.

Its failling due to your update to GCC15, and 24.10.0 does not have the required fixes.

Just use the openwrt-24.10 branch as 24.10.1 was also released before the fixes for GCC15

Sorry for my ignorance but how do I do that?

sil@laptop:~$ git clone https://git.openwrt.org/openwrt/openwrt.git
sil@laptop:~$ cd openwrt
sil@laptop:~/openwrt$ git tag
sil@laptop:~/openwrt$ git branch
sil@laptop:~/openwrt$ git checkout v24.10.0

You can't checkout 24.10, can you?

git checkout openwrt-24.10

1 Like

That works! Thank you. I had never found out without help.

Can I purge the complete build that was compiled with 1.4.19 then?

And how to avoid this problem in the future? Isn't it better to essentially block updates to gcc for as long as I wish to reuse a certain firmware build?

I mean, there is really no way you can avoid this other than using some kind of LTS distro that moves at a glacial pace.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.