Skip to contentSkip to conversation

iperf2: Add _GNU_SOURCE define to cflags on musl

PATCH New Khem Raj 1 participant 1 message Mar 29, 2025

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 iperf2: Add _GNU_SOURCE define to cflags on musl

glibc defines struct udphdr as a union where members have aliased names

uh_sport -> source
uh_dport -> uh_dport
uh_dport -> len
check -> check

But musl only defines the aliases if _GNU_SOURCE is defined, ideally iperf2 should be using uh_* names of the members so it is portable across musl and glibc but thats for upstream to consider.

Fixes

| ../../iperf-2.2.1/src/checksums.c:175:19: error: no member named 'check' in 'struct udphdr'
|   175 |     if (!udp_hdr->check) {
|       |          ~~~~~~~  ^
| 1 error generated.
| make[2]: *** [Makefile:539: checksums.o] Error 1
Cc Randy MacLeod <[email protected]>
---
 meta-oe/recipes-benchmark/iperf2/iperf2_2.2.1.bb | 2 ++
 1 file changed, 2 insertions(+)
meta-oe/recipes-benchmark/iperf2/iperf2_2.2.1.bb +2 -0
index a439616ba4..b31532d4ea 100644
@@ -15,6 +15,8 @@ inherit autotools pkgconfig
 
 EXTRA_OECONF = "--exec-prefix=${STAGING_DIR_HOST}${layout_exec_prefix}"
 
+CFLAGS:append:libc-musl = " -D_GNU_SOURCE"
+
 PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'ipv6', 'ipv6', '', d)}"
 PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"