Cannot build OpenWrt 21.02.1 under Ubuntu 22.04 LTS due to ccache-4.1 compilation error

Hello,
I'm currently trying to compile OpenWrt 21.02.1 under Ubuntu 22.04 LTS, but compilation unfortunately fails with the following error, due to ccache-4.1:

[ 72%] Built target ccache
[ 73%] Building CXX object unittest/CMakeFiles/unittest.dir/main.cpp.o
In file included from /home/phd/OpenWrt-V2X/build_dir/host/ccache-4.1/unittest/main.cpp:27:
/home/phd/OpenWrt-V2X/build_dir/host/ccache-4.1/unittest/../src/third_party/doctest.h:4084:47: error: size of array 'altStackMem' is not an integral constant-expression
 4084 |         static char             altStackMem[4 * SIGSTKSZ];
      |                                               ^
make[6]: *** [unittest/CMakeFiles/unittest.dir/build.make:95: unittest/CMakeFiles/unittest.dir/main.cpp.o] Error 1
make[6]: Leaving directory '/home/phd/OpenWrt-V2X/build_dir/host/ccache-4.1'
make[5]: *** [CMakeFiles/Makefile2:360: unittest/CMakeFiles/unittest.dir/all] Error 2
make[5]: Leaving directory '/home/phd/OpenWrt-V2X/build_dir/host/ccache-4.1'
make[4]: *** [Makefile:182: all] Error 2
make[4]: Leaving directory '/home/phd/OpenWrt-V2X/build_dir/host/ccache-4.1'
make[3]: *** [Makefile:43: /home/phd/OpenWrt-V2X/build_dir/host/ccache-4.1/.built] Error 2
make[3]: Leaving directory '/home/phd/OpenWrt-V2X/tools/ccache'
time: tools/ccache/compile#0.80#0.12#0.89
    ERROR: tools/ccache failed to build.
make[2]: *** [tools/Makefile:159: tools/ccache/compile] Error 1
make[2]: Leaving directory '/home/phd/OpenWrt-V2X'
make[1]: *** [tools/Makefile:155: /home/phd/OpenWrt-V2X/staging_dir/host/stamp/.tools_compile_yyyyyynnyyyynyyyyyynyynnyyyynyyyyyyyyyyyyyyyynynnyyyyyyy] Error 2
make[1]: Leaving directory '/home/phd/OpenWrt-V2X'
make: *** [/home/phd/OpenWrt-V2X/include/toplevel.mk:230: world] Error 2

Unfortunately, for the time being, I need to keep working with OpenWrt 21.02.1, and I cannot upgrade to newer versions, as I have a set of custom additional patches which would probably need to be upgraded when moving to a new OpenWrt release (which is a quite time-consuming activity).

Do you know if there is any workaround to enable building again under Ubuntu 22 LTS, with gcc version 11.3.0?

Thank you very much in advance.

This occurs because of an ABI change introduced in glibc 2.34. SIGSTKSZ is indeed no longer constant.

A couple of patches seems to substitute code using SIGSTKSZ with a const expression

static constexpr std::size_t sigStackSize = 32768;
static char altStackMem[sigStackSize];

Others are doing something like this

#undef SIGSTKSZ
#define SIGSTKSZ 32768

And here's how they solved the problem for emacs


diff --git a/src/sysdep.c b/src/sysdep.c
index 941b4e2..24d8832 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1785,7 +1785,15 @@ handle_arith_signal (int sig)
 
 /* Alternate stack used by SIGSEGV handler below.  */
 
-static unsigned char sigsegv_stack[SIGSTKSZ];
+/* Storage for the alternate signal stack.
+   64 KiB is not too large for Emacs, and is large enough
+   for all known platforms.  Smaller sizes may run into trouble.
+   For example, libsigsegv 2.6 through 2.8 have a bug where some
+   architectures use more than the Linux default of an 8 KiB alternate
+   stack when deciding if a fault was caused by stack overflow.  */
+static max_align_t sigsegv_stack[(64 * 1024
+				  + sizeof (max_align_t) - 1)
+				 / sizeof (max_align_t)];
 
 
 /* Return true if SIGINFO indicates a stack overflow.  */
1 Like

Thank you very much for your reply and your indications.

I solved the issue by creating the following patch (110-fix-SIGSTKSZ-constant.patch), based on one of your suggestions:

--- a/src/third_party/doctest.h
+++ b/src/third_party/doctest.h
@@ -54,6 +54,10 @@
 #define DOCTEST_VERSION                                                                            \
     (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH)

+// glibc 2.34+ fix
+#undef SIGSTKSZ
+#define SIGSTKSZ 32768
+
 // =================================================================================================
 // == COMPILER VERSION =============================================================================
 // =================================================================================================

And placing the 110-fix-SIGSTKSZ-constant.patch file inside tools/ccache/patches.

Would have been nice if you'd marked the actual solution as the solution instead of your own post...

1 Like

Sorry, I thought about marking that post as it is where I posted the final patch I added to the OpenWrt build system. But, indeed, it makes much more sense to mark your reply... I just modified the "Solution" mark.

Sorry and thank you again for your support!

1 Like

or you can just....not use ccache, we have many issues with it in many different aspects