Re: [PATCH] build system: fix linking on Red Hat systems
31.12.2022 14:23, David Laight wrote: [] You don't need to check whether libresolv is needed just whether it exists. We only need to worry about all this only if nslookup applet is in use (this is already the case in the Makefile), - this is what I mean, if we don't have nslookup we don't have to check for -lresolv. Checking for -lresolv existance is done by trying to link with -lresolv because it can be in different system-specific place which is known by the linker but not by the Makefile. The linker won't (usually) add the NEEDED entry unless the library actually defines some undefined symbols. It is only true when --when-needed is in effect. Historically, for many decades, it werent. I think ubuntu turned it on some years back (maybe when switching from ld to gold), but that's details. FWIW. /mjt ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
RE: [PATCH] build system: fix linking on Red Hat systems
From: Michael Tokarev > Sent: 31 December 2022 09:44 > > 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. You don't need to check whether libresolv is needed just whether it exists. The linker won't (usually) add the NEEDED entry unless the library actually defines some undefined symbols. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [PATCH] build system: fix linking on Red Hat systems
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 --- 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 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[PATCH] build system: fix linking on Red Hat systems
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'. Signed-off-by: Ron Yorston --- 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 -- 2.38.1 ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox