sockperf: fix musl build (libexecinfo dependency, missing includes)

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>
This commit is contained in:
Khem Raj committed 2026-09-29 15:35:17 -07:00
1 parent 255a09ab7f
commit e61923ed72
2 files changed
+63 -2

No files matched your search

@@ -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;
@@ -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
# 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