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

unbound: does not compile on macOS 11.1-x86_64 host #14573

Closed
k-ronny opened this issue Jan 26, 2021 · 8 comments
Closed

unbound: does not compile on macOS 11.1-x86_64 host #14573

k-ronny opened this issue Jan 26, 2021 · 8 comments

Comments

@k-ronny
Copy link
Contributor

k-ronny commented Jan 26, 2021

Maintainer: @EricLuehrsen
Environment: all?
Description: cross compiling of unbound on a macOS 11.1-x86_64 host is failing in the configure phase:

...
checking whether CONNECT_RESUME_ON_READ_WRITE is declared... no
configure: error: TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client
...

I think configure is using the wrong target because of the use of uname in configure.ac:

AC_ARG_ENABLE(tfo-client, AS_HELP_STRING([--enable-tfo-client],[Enable TCP Fast Open for client mode]))
case "$enable_tfo_client" in
	yes)
		case `uname` in
			Linux) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])],
			                     [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 
			                     [AC_INCLUDES_DEFAULT 
#include <netinet/tcp.h>
])
					AC_DEFINE_UNQUOTED([USE_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
			  ;;
			Darwin) AC_CHECK_DECL([CONNECT_RESUME_ON_READ_WRITE], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])], 
			                      [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 
			                      [AC_INCLUDES_DEFAULT
#include <sys/socket.h>
])
					AC_DEFINE_UNQUOTED([USE_OSX_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
			  ;;
		esac
	;;
	no|*)
		;;
esac

with this patch it compiles on macOS and Debian Buster:

--- a/configure.ac	2020-12-03 09:31:18.000000000 +0100
+++ b/configure.ac	2021-01-26 01:16:58.000000000 +0100
@@ -120,6 +120,9 @@
 AC_SUBST(LIBUNBOUND_REVISION)
 AC_SUBST(LIBUNBOUND_AGE)
 
+# AC_CANONICAL_HOST is needed to access the 'host_os' variable
+AC_CANONICAL_HOST
+
 
 cmdln="`echo $@ | sed -e 's/\\\\/\\\\\\\\/g' | sed -e 's/"/\\\\"/'g`"
 AC_DEFINE_UNQUOTED(CONFCMDLINE, ["$cmdln"], [Command line arguments used with configure])
@@ -1226,15 +1229,15 @@
 AC_ARG_ENABLE(tfo-client, AC_HELP_STRING([--enable-tfo-client], [Enable TCP Fast Open for client mode]))
 case "$enable_tfo_client" in
 	yes)
-		case `uname` in
-			Linux) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])],
+		case "${host_os}" in
+			linux*) AC_CHECK_DECL([MSG_FASTOPEN], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])],
 			                     [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 
 			                     [AC_INCLUDES_DEFAULT 
 #include <netinet/tcp.h>
 ])
 					AC_DEFINE_UNQUOTED([USE_MSG_FASTOPEN], [1], [Define this to enable client TCP Fast Open.])
 			  ;;
-			Darwin) AC_CHECK_DECL([CONNECT_RESUME_ON_READ_WRITE], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])], 
+			darwin*) AC_CHECK_DECL([CONNECT_RESUME_ON_READ_WRITE], [AC_MSG_WARN([Check the platform specific TFO kernel parameters are correctly configured to support client mode TFO])], 
 			                      [AC_MSG_ERROR([TCP Fast Open is not available for client mode: please rerun without --enable-tfo-client])], 
 			                      [AC_INCLUDES_DEFAULT
 #include <sys/socket.h>
@sdl5086
Copy link

sdl5086 commented Jan 28, 2021

Just ran into this trying to build OpenWrt on 10.15.7 after resolving a few other "curiosities" when using a Mac OS build environment. I'm pretty new to OpenWrt, but it looks like I need to look into implementing this patch..?

@k-ronny
Copy link
Contributor Author

k-ronny commented Jan 29, 2021

@sdl5086
just put the patch as e.g. 999-macos-build.patch into feeds/packages/net/unbound/patches and start a new build

@sdl5086
Copy link

sdl5086 commented Jan 29, 2021

Awesome thank you sooo much!!!

I think I had just barely figured it out on my own when I saw you replied, so I was quite happy to see that I was on the right track (even for what's likely a simple thing lol).

While that worked and the build gets significantly further, unfortunately the worm-can lid has peeled back to expose Undefined symbols for architecture x86_64 in rpc_util and this appears to be a known Mac OS thing, something about Apple changing something in ld or clang or something. I'm soooo far out of my n00b comfort zone as a lowly C# Winforms "enterprise" (read: ugly kludge) dev... and I don't want to clutter the comments here. I posted on the openwrt dev forum but so far the only reply has been another Mac user who gave up! 😭

@k-ronny
Copy link
Contributor Author

k-ronny commented Jan 29, 2021

oh, I do not know anything about rpc_util but I can tell you something about my build environment:

with brew I have installed:

brew install coreutils findutils gawk gnu-getopt gnu-tar grep make wget

my PATH is set to:

export PATH=/usr/local/bin:/usr/bin:/bin

with this environment I have successfully built my targets

@sdl5086
Copy link

sdl5086 commented Jan 29, 2021

That looks like what I have, though if I remember correctly, grep gets installed as ggrep so I symlinked it to grep in one of the toolchain directories in openwrt and added that to the "env.sh" script I run in the console I'm using the build openwrt. (This will hopefully keep Xcode from throwing a temper tantrum when I try to build Mac OS and iOS apps in the future?)

There are a few openwrt packages that still grumble about various things but so far I've just been able to disable them and work around them. Otherwise, I've got openwrt building in Mac OS now thanks to you and some other Mac OS stalwarts who just didn't want to put up with some of the "features" of Ubuntu, like ghost drives not ejecting and requiring a reboot, SMB not working after waking from sleep, and so on. lol

@EricLuehrsen
Copy link
Contributor

This makes sense so I kicked it upstream NLnetLabs/unbound#413

@k-ronny
Copy link
Contributor Author

k-ronny commented Jan 30, 2021

@EricLuehrsen
Thank you for taking the time.

@k-ronny
Copy link
Contributor Author

k-ronny commented Jun 9, 2021

fixed with NLnetLabs/unbound@ad939e5
Thank you @EricLuehrsen @gthess

@k-ronny k-ronny closed this as completed Jun 9, 2021
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

3 participants