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

Bundled system headers are not compatible with macOS #230

Open
ryandesign opened this issue Jul 7, 2023 · 0 comments
Open

Bundled system headers are not compatible with macOS #230

ryandesign opened this issue Jul 7, 2023 · 0 comments

Comments

@ryandesign
Copy link
Contributor

Compiling bahamut fails on macOS 12.6.7 (and other versions) when linking ircd:

Undefined symbols for architecture x86_64:
  "_res_mkquery", referenced from:
      _query_name in res.o
ld: symbol(s) not found for architecture x86_64

This problem was previously reported to MacPorts for version 2.0.7 back in 2014 but the problem remains with version 2.2.2.

One problem is that the -lresolv flag has not been supplied to the linker due to #229. Working around that is necessary but not sufficient to fix this issue.

As explained in #229, the symbol name in libresolv on macOS is not _res_mkquery but _res_9_mkquery, and getting this to work requires that the resolv.h header be included.

res.c does include resolv.h, but includes the local copy of resolv.h in bahamut's include directory. The include directory contains some other local copies of system headers: inet.h, nameser.h, queue.h, and cdefs.h (which doesn't even appear to be used anywhere). Trying to use these local non-macOS-compatible versions of system headers is the problem; deleting them and fixing everything to use the real system headers solved the problem for me. To get it to build, I did the following:

  • In the include directory, delete cdefs.h, inet.h, nameser.h, queue.h, and resolv.h.
  • In src/Makefile.in, delete all occurrences of ../include/inet.h, ../include/nameser.h, ../include/queue.h, and ../include/resolv.h.
  • In src/*.c and include/*.h, change all #includes of the deleted local headers to use the system ones:
Change this... ...to this:
#include "inet.h" #include <arpa/inet.h>
#include "nameser.h" #include <arpa/nameser.h>
#include "queue.h" #include <sys/queue.h>
#include "resolv.h" #include <resolv.h>
  • Remove these conflicting externs in src/res.c:
--- src/res.c.orig
+++ src/res.c
@@ -58,15 +58,6 @@
 
 #define RES_HOSTLEN 127 /* big enough to handle addresses in in6.arpa */
 
-extern int  dn_expand(char *, char *, char *, char *, int);
-extern int  dn_skipname(char *, char *);
-extern int
-res_mkquery(int, char *, int, int, char *, int,
-	    struct rrec *, char *, int);
-
-#ifndef AIX
-extern int  errno, h_errno;
-#endif
 extern int  highest_fd;
 extern aClient *local[];
 
  • Add -DBIND_8_COMPAT to CPPFLAGS since otherwise the headers to not define old BIND 8 stuff like HEADER which bahamut uses.

I'm not sure why bahamut has local copies of system headers. They've been there ever since the initial import into this repository in 1999. I can speculate that back then, some operating systems may have had broken system headers and that bahamut was attempting to provide fixed versions. If you don't need to support those old systems anymore, I suggest deleting the bundled system headers and fixing things up as indicated. If you do still need to support old systems, is there a way that you could use the local system headers only on those old systems so that modern systems are not impacted?

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

1 participant