Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nunotexbsd opened this issue Mar 24, 2023 · 6 comments
Closed

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

nunotexbsd opened this issue Mar 24, 2023 · 6 comments

Comments

@nunotexbsd
Copy link

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

@ghost
Copy link

ghost commented Mar 24, 2023

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

@nunotexbsd
Copy link
Author

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

@nunotexbsd
Copy link
Author

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)

@nunotexbsd
Copy link
Author

Fixed.

Thanks

@sflow
Copy link
Owner

sflow commented Mar 27, 2023

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?

@nunotexbsd
Copy link
Author

nunotexbsd commented Mar 28, 2023

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants