diff mbox series

[meta-oe,25/26] sockperf: fix musl build (libexecinfo dependency, missing includes)

Message ID 20260929225723.1046705-25-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
configure.ac's AC_SEARCH_LIBS([backtrace], [execinfo], ...) fails
with 'libexecinfo not found' on musl, which lacks glibc's
backtrace()/backtrace_symbols(); depend on the libexecinfo compat
library there.
Once configure succeeds, ticks.h's timeval2nsec() needs struct
timeval, which was only pulled in via <sys/time.h> under __FreeBSD__,
and vma-xlio-redirect.cpp calls sscanf()/sprintf() without including
<cstdio>; fix both for musl too.

AI-Generated: Uses Claude Code

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...-includes-for-musl-struct-timeval-ss.patch | 54 +++++++++++++++++++
 .../sockperf/sockperf_git.bb                  | 11 +++-
 2 files changed, 63 insertions(+), 2 deletions(-)
 create mode 100644 meta-oe/recipes-benchmark/sockperf/files/0001-src-fix-missing-includes-for-musl-struct-timeval-ss.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-benchmark/sockperf/files/0001-src-fix-missing-includes-for-musl-struct-timeval-ss.patch b/meta-oe/recipes-benchmark/sockperf/files/0001-src-fix-missing-includes-for-musl-struct-timeval-ss.patch
new file mode 100644
index 0000000000..3a59a8dbbe
--- /dev/null
+++ b/meta-oe/recipes-benchmark/sockperf/files/0001-src-fix-missing-includes-for-musl-struct-timeval-ss.patch
@@ -0,0 +1,54 @@ 
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Tue, 29 Sep 2026 02:40:00 +0000
+Subject: [PATCH] src: fix missing includes for musl (struct timeval,
+ sscanf/sprintf)
+
+ticks.h's timeval2nsec() uses struct timeval, but the header only
+pulled in <sys/time.h> under __FreeBSD__ -- glibc's <time.h> happens
+to declare struct timeval as a side effect of other headers already
+included elsewhere in the build, but musl's does not, so building
+against musl fails:
+
+| ticks.h:115:30: error: member access into incomplete type 'const struct timeval'
+
+Always include <sys/time.h> instead of gating it on __FreeBSD__.
+
+vma-xlio-redirect.cpp uses sscanf()/sprintf() but never includes
+<cstdio>, relying on it being pulled in transitively. That doesn't
+happen on musl either:
+
+| vma-xlio-redirect.cpp:92:14: error: use of undeclared identifier 'sscanf'
+| vma-xlio-redirect.cpp:99:5: error: use of undeclared identifier 'sprintf'
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+diff --git a/src/ticks.h b/src/ticks.h
+index 679f3d9..6e38095 100644
+--- a/src/ticks.h
++++ b/src/ticks.h
+@@ -99,9 +99,10 @@ with simple integral values. The following describes these calculations:
+ #include <stdint.h> // for int64_t
+ #include <stdlib.h> // for qsort
+
+-#ifdef __FreeBSD__
++/* struct timeval is used below (timeval2nsec()); <time.h> alone doesn't
++ * guarantee it, so always pull in <sys/time.h> rather than just on
++ * __FreeBSD__. */
+ #include <sys/time.h>
+-#endif
+
+ #include "ticks_os.h"
+
+diff --git a/src/vma-xlio-redirect.cpp b/src/vma-xlio-redirect.cpp
+index 5554d4a..a54a6c1 100644
+--- a/src/vma-xlio-redirect.cpp
++++ b/src/vma-xlio-redirect.cpp
+@@ -28,6 +28,7 @@
+  */
+
+ #include "vma-xlio-redirect.h"
++#include <cstdio> /* sscanf(), sprintf() */
+ #include <dlfcn.h>
+
+ socket_fptr_t fn_socket = NULL;
diff --git a/meta-oe/recipes-benchmark/sockperf/sockperf_git.bb b/meta-oe/recipes-benchmark/sockperf/sockperf_git.bb
index ab0e35667e..fe285465e6 100644
--- a/meta-oe/recipes-benchmark/sockperf/sockperf_git.bb
+++ b/meta-oe/recipes-benchmark/sockperf/sockperf_git.bb
@@ -5,9 +5,16 @@  SECTION = "console/network"
 LICENSE = "BSD-3-Clause"
 LIC_FILES_CHKSUM = "file://copying;md5=b4563b57c98bc23c8cecbc0b6d9546e9"
 
-SRC_URI = "git://github.com/Mellanox/sockperf;branch=sockperf_v2;protocol=https"
+SRC_URI = "git://github.com/Mellanox/sockperf;branch=sockperf_v2;protocol=https \
+           file://0001-src-fix-missing-includes-for-musl-struct-timeval-ss.patch \
+           "
 SRCREV = "3c65ad99cd385e18f8a2a655c19826e81a4d17e8"
 
 UPSTREAM_CHECK_COMMITS = "1"
 
-inherit autotools
\ No newline at end of file
+# musl lacks glibc's backtrace()/backtrace_symbols(); configure.ac uses
+# AC_SEARCH_LIBS([backtrace], [execinfo], ...) which errors out with
+# "libexecinfo not found" unless the compat library is available.
+DEPENDS:append:libc-musl = " libexecinfo"
+
+inherit autotools