Files
winf-photobooth/package/libabseil-cpp/0002-base-fix-ABSL_ATTRIBUTE_WARN_UNUSED-with-gcc-12.patch
Michael b8783708ae Initial Commit
- initial default booting image
2026-11-06 20:45:42 +01:00

56 lines
2.2 KiB
Diff

From 77326826119439c06e341c9d090633ecd9b520d6 Mon Sep 17 00:00:00 2001
From: Julien Olivain <ju.o@free.fr>
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 <ju.o@free.fr>
---
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