From 955fb2f7c41f49e8d7fc8c60b8557f6f7c1d84c4 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Mon, 27 Apr 2026 22:16:06 +0200 Subject: [PATCH] package/libabseil-cpp: add patch to fix build with gcc <= 12 libabseil-cpp headers can break some packages build, like protobuf, when compiled with gcc 12. See [1] [2]. The issue has been reported in protobuf upstream, in [3]. The issue is due to gcc <= 12 not supporting the mix of standard C++ attributes with GNU attributes. See [4]. Gcc 12 has been removed from Buildroot internal toolchains in commit [5], but gcc 12 can still be present in external toolchains or on the host. This is currently the case of the Buildroot Docker reference image, based on Debian 12 (Bookworm). This commit fixes the issue by adding a package patch. Fixes: - [1] [2] and many more. [1] https://gitlab.com/buildroot.org/buildroot/-/jobs/13904066346 [2] https://autobuild.buildroot.org/results/33f6cfd37cb48c15a53b3e7123d5ce8388a0f2ab [3] https://github.com/protocolbuffers/protobuf/issues/26383 [4] https://gcc.gnu.org/PR69585 [5] https://gitlab.com/buildroot.org/buildroot/-/commit/58cf7c51da3ae4804332f68ee934e153d695d047 [6] https://github.com/abseil/abseil-cpp/pull/2044 Signed-off-by: Julien Olivain Signed-off-by: Romain Naour --- ...SL_ATTRIBUTE_WARN_UNUSED-with-gcc-12.patch | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 package/libabseil-cpp/0002-base-fix-ABSL_ATTRIBUTE_WARN_UNUSED-with-gcc-12.patch diff --git a/package/libabseil-cpp/0002-base-fix-ABSL_ATTRIBUTE_WARN_UNUSED-with-gcc-12.patch b/package/libabseil-cpp/0002-base-fix-ABSL_ATTRIBUTE_WARN_UNUSED-with-gcc-12.patch new file mode 100644 index 0000000000..8f5e255795 --- /dev/null +++ b/package/libabseil-cpp/0002-base-fix-ABSL_ATTRIBUTE_WARN_UNUSED-with-gcc-12.patch @@ -0,0 +1,55 @@ +From 77326826119439c06e341c9d090633ecd9b520d6 Mon Sep 17 00:00:00 2001 +From: Julien Olivain +Date: Mon, 27 Apr 2026 19:38:19 +0200 +Subject: [PATCH] base: fix ABSL_ATTRIBUTE_WARN_UNUSED with gcc <= 12 + +Gcc <= 12 does not support mixing standard C++ attributes with +GNU attributes. See [1]. + +This can lead to build failures such as [2] [3] and [4]. In those +situations, the compilation fails with error such as: + + /usr/include/absl/base/attributes.h:1076:36: error: expected identifier before '[' token + +Gcc maintainers mentioned in [1] comment 9 that this bugfix will +not be backported in Gcc 12. Gcc 12 is still used in LTS +distributions. For example, it is included in Debian 12 (Bookworm), +which is still supported until 2028. See [5]. + +This commit adds a workaround for gcc <= 12 which uses +__attribute__ in that case, which fixes the compilation failure. + +[1] https://gcc.gnu.org/PR69585 +[2] https://github.com/protocolbuffers/protobuf/issues/26383 +[3] https://autobuild.buildroot.org/results/33f6cfd37cb48c15a53b3e7123d5ce8388a0f2ab/build-end.log +[4] https://gitlab.com/buildroot.org/buildroot/-/jobs/13904066346 +[5] https://www.debian.org/releases/bookworm/ + +Upstream: https://github.com/abseil/abseil-cpp/pull/2044 +Signed-off-by: Julien Olivain +--- + absl/base/attributes.h | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/absl/base/attributes.h b/absl/base/attributes.h +index 5887fcaf..a26143e1 100644 +--- a/absl/base/attributes.h ++++ b/absl/base/attributes.h +@@ -1092,7 +1092,14 @@ struct AbslInternal_YouForgotToExplicitlyInitializeAField { + // See https://clang.llvm.org/docs/AttributeReference.html#warn-unused and + // https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html#index-warn_005funused-type-attribute + #if ABSL_HAVE_CPP_ATTRIBUTE(gnu::warn_unused) ++// Only GCC >= 13 allows mixing standard and gnu attributes. ++// In case of gcc < 13, fallback on using __attribute__. ++// https://gcc.gnu.org/PR69585 ++#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 13 ++#define ABSL_ATTRIBUTE_WARN_UNUSED __attribute__((warn_unused)) ++#else + #define ABSL_ATTRIBUTE_WARN_UNUSED [[gnu::warn_unused]] ++#endif + #else + #define ABSL_ATTRIBUTE_WARN_UNUSED + #endif +-- +2.54.0 +