sflow/sflowtool

FreeBSD: fatal error: 'byteswap.h' file not found

nunotexbsd opened this issue · 6 comments

Hello,

I'm updating sflowtool to 6.01 and geting compile error on 12 and 13 (14 current build is fine):

===>  Building for sflowtool-6.01
--- all ---
/usr/bin/make  all-recursive
--- all-recursive ---
Making all in src
--- sflowtool.o ---
cc -DHAVE_CONFIG_H -I. -I..      -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -MT sflowtool.o -MD -MP -MF .deps/sflowtool.Tpo -c -o sflowtool.o sflowtool.c
sflowtool.c:32:10: fatal error: 'byteswap.h' file not found
#include <byteswap.h>
         ^~~~~~~~~~~~
1 error generated.
*** [sflowtool.o] Error code 1

make[3]: stopped in /wrkdirs/usr/ports/net/sflowtool/work/sflowtool-6.01/src
1 error

Old version 5.08 builds fine on 14, 13 and 12.
Any clues since both versions include #include <byteswap.h>?

Thanks

5.08 has that entire code block including byteswap.h commented out.

Nice to know that and now we can focus fixing it on our side on 12 and 13 FreeBSD releases.

Testing a workaround for 12 and 13:

--- src/sflowtool.c.orig        2023-03-24 09:29:58 UTC
+++ src/sflowtool.c
@@ -29,13 +29,18 @@ extern "C" {
 #include <inttypes.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <byteswap.h>
+#include <sys/endian.h>
 #include <getopt.h>

 #include "sflow.h" /* sFlow v5 */
 #include "sflow_v2v4.h" /* sFlow v2/4 */
 #include "assert.h"
 #include "sflow_xdr.h" /* sFlow encode */
+
+#define bswap_16 bswap16
+#define bswap_32 bswap32
+#define bswap_64 bswap64

or

#include <sys/endian.h>
#define __bswap_16(x) __bswap16(x)
#define __bswap_32(x) __bswap32(x)
#define __bswap_64(x) __bswap64(x)

#define bswap_16(x) __bswap16(x)
#define bswap_32(x) __bswap32(x)
#define bswap_64(x) __bswap64(x)

Fixed.

Thanks

sflow commented

Please can you send me a patch or pull request with your solution wrapped in something like "#if FreeBSD" so I can check it into the master branch?

@sflow

FreeBSD current:
byteswap.h: Add a glibc/linux compatible byteswap.h
https://cgit.freebsd.org/src/commit/?id=1761b09bf42d2842e82c1ac614c23d31c4d4c0dc

MFC stable/13 (1301511):
https://cgit.freebsd.org/src/commit/?h=stable/13&id=1dd126163b9448c2dcfe27978fee50649548437c

This support was not MFCed to stable/12.

To fix port I added a patch to be applied on <1301511 that affects 13.1 and 12.x releases.
13.2 next release will include biteswap.h.

net/sflowtool: Update to 6.01

Cheers