Skip to content

Commit b581f2a

Browse files
authored
PHPC-1706: Don't try linking against libresolv on AIX (#1172)
On AIX, the resolver functions are in libc, so trying libresolv will cause the checks to fail. The behaviour should be instead like AC_SEARCH_LIBS. This hardcodes a check not to use libresolv on AIX. Better than nothing, but it may not compensate for other systems without a libresolv.
1 parent 075edbf commit b581f2a

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

scripts/autotools/CheckHost.m4

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ os_linux=no
99
os_solaris=no
1010
os_darwin=no
1111
os_gnu=no
12+
os_aix=no
1213

1314
case "$host" in
1415
*-mingw*|*-*-cygwin*)
@@ -44,6 +45,10 @@ case "$host" in
4445
os_darwin=yes
4546
TARGET_OS=unix
4647
;;
48+
*-*-aix*|*-*-os400*)
49+
os_aix=yes
50+
TARGET_OS=unix
51+
;;
4752
gnu*|k*bsd*-gnu*)
4853
os_gnu=yes
4954
TARGET_OS=unix

scripts/autotools/libmongoc/CheckResolv.m4

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
dnl Disable Windows DNSAPI
22
AC_SUBST(MONGOC_HAVE_DNSAPI, 0)
33

4-
found_resolv="no"
4+
need_libresolv="no"
55

66
old_LIBS="$LIBS"
7-
LIBS="$LIBS -lresolv"
7+
dnl On AIX, resolv functions are in libc.
8+
if test "x$os_aix" = "xno"; then
9+
LIBS="$LIBS -lresolv"
10+
fi
811

912
dnl Thread-safe DNS query function for _mongoc_client_get_srv.
1013
dnl Could be a macro, not a function, so check with AC_LINK_IFELSE.
@@ -24,7 +27,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
2427
AC_MSG_RESULT([yes])
2528
AC_SUBST(MONGOC_HAVE_RES_SEARCH, 0)
2629
AC_SUBST(MONGOC_HAVE_RES_NSEARCH, 1)
27-
found_resolv="yes"
2830
2931
dnl We have res_nsearch. Call res_ndestroy (BSD/Mac) or res_nclose (Linux)?
3032
AC_MSG_CHECKING([for res_ndestroy])
@@ -80,7 +82,9 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
8082
]])], [
8183
AC_MSG_RESULT([yes])
8284
AC_SUBST(MONGOC_HAVE_RES_SEARCH, 1)
83-
found_resolv="yes"
85+
if test "x$os_aix" = "xno"; then
86+
need_libresolv="yes"
87+
fi
8488
], [
8589
AC_MSG_RESULT([no])
8690
AC_SUBST(MONGOC_HAVE_RES_SEARCH, 0)
@@ -89,6 +93,6 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
8993

9094
LIBS="$old_LIBS"
9195

92-
AS_IF([test "$found_resolv" = "yes"],[
96+
AS_IF([test "$need_libresolv" = "yes"],[
9397
PHP_ADD_LIBRARY([resolv],,[MONGODB_SHARED_LIBADD])
9498
])

0 commit comments

Comments
 (0)