diff mbox series

[meta-networking,21/26] ot-br-posix: reference sCrashCallback on non-glibc

Message ID 20260929225723.1046705-21-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe,01/26] canvenient: include <sys/time.h> for struct timeval on musl | expand

Commit Message

Khem Raj Sept. 29, 2026, 10:57 p.m. UTC
backtrace.cpp sets sCrashCallback but only reads it back inside a
glibc-only execinfo backtrace path, so on musl (no backtrace()) clang
flags it as -Wunused-but-set-variable under -Werror. Reference it in
the non-glibc branch too.

AI-Generated: Uses Claude Code

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...-Reference-sCrashCallback-on-non-gli.patch | 34 +++++++++++++++++++
 .../openthread/ot-br-posix_git.bb             |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-posix-backtrace-Reference-sCrashCallback-on-non-gli.patch
diff mbox series

Patch

diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-posix-backtrace-Reference-sCrashCallback-on-non-gli.patch b/meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-posix-backtrace-Reference-sCrashCallback-on-non-gli.patch
new file mode 100644
index 0000000000..88c3b67314
--- /dev/null
+++ b/meta-networking/recipes-connectivity/openthread/ot-br-posix/0001-posix-backtrace-Reference-sCrashCallback-on-non-gli.patch
@@ -0,0 +1,34 @@ 
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Tue, 29 Sep 2026 01:57:51 +0000
+Subject: [PATCH] posix/backtrace: Reference sCrashCallback on non-glibc,
+ non-Android builds
+
+sCrashCallback is set unconditionally by otSysRegisterCrashCallback()
+whenever OPENTHREAD_POSIX_CONFIG_BACKTRACE_ENABLE is set, but it is
+only read from signalCritical(), which is compiled solely under the
+`OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE || defined(__GLIBC__)` branch.
+On musl (neither Android nor glibc) that branch is replaced by an
+empty platformBacktraceInit() stub, so the variable is set but never
+used, which clang's -Wunused-but-set-global (promoted to -Werror)
+turns into a hard build failure. Use the existing OT_UNUSED_VARIABLE()
+idiom already used elsewhere in this file (e.g. in signalCritical())
+to acknowledge the variable on this code path too.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ src/posix/platform/backtrace.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/posix/platform/backtrace.cpp b/src/posix/platform/backtrace.cpp
+index 1111111..2222222 100644
+--- a/src/posix/platform/backtrace.cpp
++++ b/src/posix/platform/backtrace.cpp
+@@ -185,6 +185,6 @@ void platformBacktraceInit(void)
+     }
+ }
+ #else  // OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE || defined(__GLIBC__)
+-void platformBacktraceInit(void) {}
++void platformBacktraceInit(void) { OT_UNUSED_VARIABLE(sCrashCallback); }
+ #endif // OPENTHREAD_POSIX_CONFIG_ANDROID_ENABLE || defined(__GLIBC__)
+ #endif // OPENTHREAD_POSIX_CONFIG_BACKTRACE_ENABLE
diff --git a/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb b/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb
index 8c49a30327..59e1dae2a3 100644
--- a/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb
+++ b/meta-networking/recipes-connectivity/openthread/ot-br-posix_git.bb
@@ -17,6 +17,7 @@  SRC_URI = "gitsm://github.com/openthread/ot-br-posix.git;protocol=https;branch=m
            file://0001-cmake-Disable-nonnull-compare-warning-on-gcc.patch \
            file://default-cxx-std.patch \
            file://0001-x509_crt-Zero-initialize-mbedtls_x509_time-at-declar.patch;patchdir=third_party/openthread/repo \
+           file://0001-posix-backtrace-Reference-sCrashCallback-on-non-gli.patch;patchdir=third_party/openthread/repo \
            "

 SYSTEMD_SERVICE:${PN} = "otbr-agent.service"