From 5588bdec022dbc0d3eded0f7ad29d67f9d0c8466 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 23 Nov 2025 18:39:52 +0100 Subject: [PATCH] package/gnutls: add patch to fix build with gcc < 11 Since Buildroot commit [1] (package/gnutls: security bump to version 3.8.11), gnutls fails to build with gcc or host-gcc version < 11, with error: In file included from audit.h:22, from audit.c:26: crau/crau.h:255:23: error: missing binary operator before token "(" __has_c_attribute (__maybe_unused__) This commit adds a patch fixing the issue. [1] https://gitlab.com/buildroot.org/buildroot/-/commit/81dbfe1c2ae848b4eb1f896198d13455df50e548 Reported-by: Neal Frager Reviewed-by: Neal Frager Tested-by: Neal Frager Signed-off-by: Julien Olivain (cherry picked from commit 5cd1fe636cd9a420241da5fe79995d149d467f59) Signed-off-by: Thomas Perale --- ...dit-crau-fix-compilation-with-gcc-11.patch | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 package/gnutls/0001-audit-crau-fix-compilation-with-gcc-11.patch diff --git a/package/gnutls/0001-audit-crau-fix-compilation-with-gcc-11.patch b/package/gnutls/0001-audit-crau-fix-compilation-with-gcc-11.patch new file mode 100644 index 0000000000..0551d5c4fd --- /dev/null +++ b/package/gnutls/0001-audit-crau-fix-compilation-with-gcc-11.patch @@ -0,0 +1,67 @@ +From 2bbae7644a2292410b53f98fd0035c40bf8750a5 Mon Sep 17 00:00:00 2001 +From: Julien Olivain +Date: Sun, 23 Nov 2025 18:17:19 +0100 +Subject: [PATCH] audit: crau: fix compilation with gcc < 11 + +If the CRAU_MAYBE_UNUSED macro is unset, the crau.h file tries to +automatically detect an appropriate value for it. + +This autodetection is using the cpp special operator +`__has_c_attribute` [1], introduced in gcc 11 [2]. + +When compiling with a gcc older than version 11, the compilation fails +with the error: + + In file included from audit.h:22, + from audit.c:26: + crau/crau.h:255:23: error: missing binary operator before token "(" + __has_c_attribute (__maybe_unused__) + ^ + +This has been observed, for example, in Rocky Linux 8.10, which +contains a gcc v8.5.0. + +The issue happens because the test for the `__has_c_attribute` +availability and the test for the `__maybe_unused__` attribute +are in the same directive. Those tests should be separated in +two different directives, following the same logic described in +the `__has_builtin` documentation [3]. + +This issue was found in Buildroot, after updating gnutls to +version 3.8.11 in [4]. + +This commit fixes the issue by splitting the test in two. + +[1] https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fc_005fattribute.html +[2] https://gcc.gnu.org/gcc-11/changes.html#c +[3] https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fbuiltin.html +[4] https://gitlab.com/buildroot.org/buildroot/-/commit/81dbfe1c2ae848b4eb1f896198d13455df50e548 + +Upstream: https://gitlab.com/gnutls/gnutls/-/merge_requests/2045 +Reported-by: Neal Frager +Signed-off-by: Julien Olivain +--- + lib/crau/crau.h | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/lib/crau/crau.h b/lib/crau/crau.h +index 0d4f9f13e..53d33555b 100644 +--- a/lib/crau/crau.h ++++ b/lib/crau/crau.h +@@ -251,9 +251,10 @@ void crau_data(struct crau_context_stack_st *stack, ...) + # else + + # ifndef CRAU_MAYBE_UNUSED +-# if defined(__has_c_attribute) && \ +- __has_c_attribute (__maybe_unused__) +-# define CRAU_MAYBE_UNUSED [[__maybe_unused__]] ++# if defined(__has_c_attribute) ++# if __has_c_attribute (__maybe_unused__) ++# define CRAU_MAYBE_UNUSED [[__maybe_unused__]] ++# endif + # elif defined(__GNUC__) + # define CRAU_MAYBE_UNUSED __attribute__((__unused__)) + # endif +-- +2.51.1 +