File 0813-Avoid-unnecessary-linking-against-libnsl.patch of Package erlang
From 9c869776946b2160a1bec79c968a4060186f23f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Holger=20Wei=C3=9F?= <holger@zedat.fu-berlin.de>
Date: Thu, 30 Dec 2021 11:52:07 +0100
Subject: [PATCH] Avoid unnecessary linking against libnsl
The Autoconf documentation says:
| AC_CHECK_LIB requires some care in usage, and should be avoided in
| some common cases. Many standard functions like gethostbyname appear
| in the standard C library on some hosts, and in special libraries
| like nsl on other hosts. On some hosts the special libraries contain
| variant implementations that you may not want to use. These days it
| is normally better to use AC_SEARCH_LIBS([gethostbyname], [nsl])
| instead of AC_CHECK_LIB([nsl], [gethostbyname]).
[ https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Libraries.html ]
Another issue with glibc specifically is that the usual backward
compatibility isn't offered for libnsl, so binaries linked against
older libnsl versions may not work with newer libnsl versions.
Therefore, don't link against libnsl if gethostbyname is provided by
the standard libc. While at it, avoid unnecessary linking against
libsocket as well.
---
lib/erl_interface/configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/erl_interface/configure.in b/lib/erl_interface/configure.in
index 79a0e9843b..887453c6a5 100644
--- a/lib/erl_interface/configure.in
+++ b/lib/erl_interface/configure.in
@@ -160,8 +160,8 @@ case $host_os in
esac
# Checks for libraries.
-AC_CHECK_LIB([nsl], [gethostbyname])
-AC_CHECK_LIB([socket], [getpeername])
+AC_SEARCH_LIBS([gethostbyname], [nsl])
+AC_SEARCH_LIBS([getpeername], [socket])
# Checks for header files.
AC_HEADER_STDC
--
2.31.1