[PATCH] build system: fix linking on Red Hat systems

Michael Tokarev mjt at tls.msk.ru
Sat Dec 31 09:43:38 UTC 2022


31.12.2022 11:48, Ron Yorston wrote:
> Commit 77216c368 (Fix non-Linux builds) made linking with libresolv
> conditional on the output of 'gcc -dumpmachine' containing 'gnu'.
> 
> This broke builds on Red Hat systems (Fedora, RHEL) and derivatives
> (CentOS, Rocky).  Such systems report a machine type of the form
> 'x86_64-redhat-linux'.
> 
> Check for 'linux' as well as 'gnu'.

This is - in my opinion - both wrong test to begin with, and a wrong
fix. -lresolv is needed when nslookup applet is enabled, because it
uses res_XXX functions, - this is regardless of the system, I think.
I submitted a patch about this a few months ago.  If anything, this
can be made a test whenever we actually have and need -lresolv by
doing a small compile test.

Also, conditionals around linux are also wrong in my opinion, it should
check (maybe with dumpmachine, - I used cpp check for __linux__ define
instead) if it is being compiled for linux, and disable a bunch of
linux-only applets as it has been before 2015 iirc. I also submitted
a fix for this a few months back.

/mjt

> Signed-off-by: Ron Yorston <rmy at pobox.com>
> ---
>   Makefile.flags | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/Makefile.flags b/Makefile.flags
> index 50137a78e..e484ab6c7 100644
> --- a/Makefile.flags
> +++ b/Makefile.flags
> @@ -186,6 +186,8 @@ endif
>   ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y)
>   ifneq (,$(findstring gnu,$(shell $(CC) $(CFLAGS) -dumpmachine)))
>   LDLIBS += resolv
> +else ifneq (,$(findstring linux,$(shell $(CC) $(CFLAGS) -dumpmachine)))
> +LDLIBS += resolv
>   endif
>   endif
>   



More information about the busybox mailing list