From d40358a1c52079e238c48bf40bff504e55a9f758 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Fri, 22 Jan 2021 22:24:05 +0100 Subject: Makefile.flags: fix the OS detection for libresolv 054493350 ("Do not add -lresolv on non-Linux systems") adds a condition to link with libresolv only on linux systems. The check requires that CONFIG_UNAME_OSNAME equals Linux. This works only if the uname applet is enabled. Otherwise, CONFIG_UNAME_OSNAME is empty, regardless of the platform. By default, CONFIG_UNAME_OSNAME is the output of uname -o. For most linux systems, uname -o returns "GNU/Linux" and the check fails. In this case, linking a static busybox fails because of missing symbols from libresolv. networking/lib.a(nslookup.o): In function `add_query': nslookup.c:789: undefined reference to `__res_mkquery' networking/lib.a(nslookup.o): In function `parse_reply': nslookup.c:355: undefined reference to `ns_initparse' nslookup.c:361: undefined reference to `ns_parserr' nslookup.c:404: undefined reference to `ns_name_uncompress' nslookup.c:418: undefined reference to `ns_get16' nslookup.c:419: undefined reference to `ns_name_uncompress' .. nslookup.c:456: undefined reference to `ns_get16' ... nslookup.c:469: undefined reference to `ns_name_uncompress' ... nslookup.c:489: undefined reference to `ns_get32' ... collect2: error: ld returned 1 exit status This patch uses the output of $CC -dumpmachine to detect the target platform for which we compile. Both gcc and clang support -dumpmachine. Like the original patch, we link against libresolv only if our target platform is linux-based. Fixes: 054493350 ("Do not add -lresolv on non-Linux systems") Signed-off-by: Martin Kaiser Signed-off-by: Bernhard Reutner-Fischer --- Makefile.flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.flags b/Makefile.flags index 5673bc48a..7a445c3b5 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -181,7 +181,7 @@ LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=% endif ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y) -ifeq ($(CONFIG_UNAME_OSNAME),Linux) +ifneq (,$(findstring linux,$(shell $(CC) $(CFLAGS) -dumpmachine))) LDLIBS += resolv endif endif -- cgit v1.2.3