diff mbox series

[meta-oe] libunwind: guard unreachable() macro to avoid redefinition with stddef.h

Message ID 20251029054119.3334168-1-quic_sasikuma@quicinc.com
State Under Review
Headers show
Series [meta-oe] libunwind: guard unreachable() macro to avoid redefinition with stddef.h | expand

Commit Message

Sasi Kumar Maddineni Oct. 29, 2025, 5:41 a.m. UTC
The build fails due to a macro redefinition conflict for `unreachable()`.
GCC 15.2.0 defines `unreachable()` in `stddef.h`, and `libunwind_i.h` also
defines it based on the presence of `HAVE__BUILTIN_UNREACHABLE`. This causes
a redefinition error when building with `-Werror`.

Added a guard around the `unreachable()` macro definition in `libunwind_i.h`
to ensure it is only defined if not already present.

Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
---
 ...unreachable-macro-to-avoid-redefinit.patch | 42 +++++++++++++++++++
 .../android-tools/android-tools_29.0.6.r14.bb |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch
diff mbox series

Patch

diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch
new file mode 100644
index 0000000000..1e0f15ddf0
--- /dev/null
+++ b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools/debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch
@@ -0,0 +1,42 @@ 
+From e64495a109eefaf87235729f4dd79fc9121c16a6 Mon Sep 17 00:00:00 2001
+From: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
+Date: Mon, 27 Oct 2025 19:39:05 +0530
+Subject: [PATCH] libunwind: guard unreachable() macro to avoid redefinition
+ with stddef.h
+
+The build fails due to a macro redefinition conflict for `unreachable()`.
+GCC 15.2.0 defines `unreachable()` in `stddef.h`, and `libunwind_i.h` also
+defines it based on the presence of `HAVE__BUILTIN_UNREACHABLE`. This causes
+a redefinition error when building with `-Werror`.
+
+Added a guard around the `unreachable()` macro definition in `libunwind_i.h`
+to ensure it is only defined if not already present.
+
+Upstream-Status: Pending
+
+Signed-off-by: Sasi Kumar Maddineni <quic_sasikuma@quicinc.com>
+---
+ external/libunwind/include/libunwind_i.h | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/external/libunwind/include/libunwind_i.h b/external/libunwind/include/libunwind_i.h
+index c06912a6..59a462df 100644
+--- a/external/libunwind/include/libunwind_i.h
++++ b/external/libunwind/include/libunwind_i.h
+@@ -88,11 +88,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
+ # endif
+ #endif
+ 
++#if !defined(unreachable)
+ #if defined(HAVE__BUILTIN_UNREACHABLE)
+ # define unreachable() __builtin_unreachable()
+ #else
+ # define unreachable() do { } while (1)
+ #endif
++#endif
+ 
+ #ifdef DEBUG
+ # define UNW_DEBUG	1
+-- 
+2.34.1
+
diff --git a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb
index 63e31e90cc..24b6822433 100644
--- a/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb
+++ b/meta-oe/dynamic-layers/selinux/recipes-devtool/android-tools/android-tools_29.0.6.r14.bb
@@ -21,6 +21,7 @@  SRC_URI += " \
     file://debian/external/libunwind/user_pt_regs.patch \
     file://debian/external/libunwind/legacy_built-in_sync_functions.patch \
     file://debian/external/libunwind/20150704-CVE-2015-3239_dwarf_i.h.patch \
+    file://debian/external/libunwind/libunwind-guard-unreachable-macro-to-avoid-redefinit.patch \
     \
     file://debian/system/core/move-log-file-to-proper-dir.patch \
     file://debian/system/core/Added-missing-headers.patch \