src: fix build with musl libc
PATCH 1/1 src: fix build with musl libc
The GNU version of 'struct tcphdr' is not exposed by musl libc headers unless _GNU_SOURCE is defined. Without this definition, the build fails with:
rpc.c: In function 'rpc_helper_cb':
rpc.c:351:15: error: 'struct tcphdr' has no member named 'doff'
offset += th->doff * 4;
^--- src/helpers/rpc.c | 1 + 1 file changed, 1 insertion(+)
src/helpers/rpc.c +1 -0
@@ -28,6 +28,7 @@#include <rpc/rpc_msg.h> #include <rpc/pmap_prot.h> +#define _GNU_SOURCE#include <netinet/tcp.h> #include <netinet/udp.h>
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerQuoted 8 lines · Rodrigo Rebello
The GNU version of 'struct tcphdr' is not exposed by musl libc headers unless
_GNU_SOURCEis defined. Without this definition, the build fails with:
rpc.c: In function 'rpc_helper_cb':
rpc.c:351:15: error: 'struct tcphdr' has no member named 'doff'offset += th->doff * 4; ^
You can probably update the code to use the non-GNU version, that should work both with musl, libc and any other new version that sticks to the standard.
Thanks.
Pablo,
2015-11-23 9:07 GMT-02:00 Pablo Neira Ayuso <[email protected]>:
Quoted 10 lines · Rodrigo Rebello
Quoted 8 lines
The GNU version of 'struct tcphdr' is not exposed by musl libc headers unless
_GNU_SOURCEis defined. Without this definition, the build fails with:
rpc.c: In function 'rpc_helper_cb':
rpc.c:351:15: error: 'struct tcphdr' has no member named 'doff'offset += th->doff * 4; ^
Quoted 5 lines
You can probably update the code to use the non-GNU version, that should work both with musl, libc and any other new version that sticks to the standard.
Thanks.
I could change 'doff' to 'th_off' in rpc.c:351, which is the name used in the BSD version of 'struct tcphdr', but then I'd have to define the macro __FAVOR_BSD in order to get the code to compile with uClibc (in contrast to musl, uClibc only exposes the GNU version by default).
So, I don't see any advantages in doing that (changing the member name
+ defining __FAVOR_BSD) instead of simply defining _GNU_SOURCE. Besides, I've noticed that a similar issue has been solved before by using the same approach (commit fe1f2d58add1e56e651c43de8cd60db8123d49bb).
Regards,
Rodrigo
Pablo Neira Ayuso
maintainerQuoted 24 lines · Rodrigo Rebello
Pablo,
2015-11-23 9:07 GMT-02:00 Pablo Neira Ayuso <[email protected]>:
Quoted 10 lines · Rodrigo Rebello
Quoted 8 lines
The GNU version of 'struct tcphdr' is not exposed by musl libc headers unless
_GNU_SOURCEis defined. Without this definition, the build fails with:
rpc.c: In function 'rpc_helper_cb':
rpc.c:351:15: error: 'struct tcphdr' has no member named 'doff'offset += th->doff * 4; ^Quoted 5 lines
You can probably update the code to use the non-GNU version, that should work both with musl, libc and any other new version that sticks to the standard.
Thanks.
I could change 'doff' to '
th_off' in rpc.c:351, which is the name used in the BSD version of 'struct tcphdr', but then I'd have to define the macro__FAVOR_BSDin order to get the code to compile with uClibc (in contrast to musl, uClibc only exposes the GNU version by default).
Quoted 5 lines
So, I don't see any advantages in doing that (changing the member name
+ defining__FAVOR_BSD) instead of simply defining_GNU_SOURCE. Besides, I've noticed that a similar issue has been solved before by using the same approach (commitfe1f2d58add1e56e651c43de8cd60db8123d49bb).
OK, I have pushed out your patch. Thanks.