[patch] Fix linking ldconfig when --enable-static-nss (with ChangeLog)

Paul Pluzhnikov ppluzhnikov@google.com
Thu Mar 1 21:46:00 GMT 2012


On Thu, Mar 1, 2012 at 1:05 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Thursday 01 March 2012 15:42:00 Joseph S. Myers wrote:
>> On Sat, 25 Feb 2012, Paul Pluzhnikov wrote:
>> > The patch is much simpler than the one attached to
>> > http://sourceware.org/bugzilla/show_bug.cgi?id=6528, but requires that
>> > a statically-linked binary explicitly list "-lnss_files -lnss_dns
>> > -lresolv" on the link line.
>> >
>> > I *think* Daniel's patch from PR 6528 would not require clients to do
>> > that, so perhaps that's better?
>>
>> As I see it, Daniel's patch has the twin advantages:
>>
>> * It reduces the amount of code involved in supporting
>> --enable-static-nss.
>>
>> * It makes --enable-static-nss easier to use.
>>
>> Thus, I'd prefer Daniel's patch.  What do other people think?
>
> having more .o's in libc.a isn't really a problem and would make things
> simpler, sounds good to me

Thanks.

Attached is Daniel's patch rebased to current git trunk.

I've build glibc on Linux/x86_64 with and without --enable-static-nss.

Could someone please apply it?

Thanks,
-- 
Paul Pluzhnikov

2012-03-01  Daniel Jacobowitz  <dmj@google.com>
            Paul Pluzhnikov  <ppluzhnikov@google.com>

        [BZ #6528]
        * grp/Makefile, inet/Makefile, login/Makefile, nscd/Makefile,
        posix/Makefile, pwd/Makefile, rt/Makefile, sunrpc/Makefile: Do not
        set otherlibs for static NSS.
        * nss/Makefile: Likewise.  Include libnss_files in libc.a for
        --enable-static-nss.  Remove special case for getent.
        * resolv/Makefile: Include libnss_dns in libc.a for
        --enable-static-nss.
-------------- next part --------------
2012-03-01  Daniel Jacobowitz  <dmj@google.com>
	    Paul Pluzhnikov  <ppluzhnikov@google.com>

	    [BZ #6528]
	    * grp/Makefile, inet/Makefile, login/Makefile, nscd/Makefile,
	    posix/Makefile, pwd/Makefile, rt/Makefile, sunrpc/Makefile: Do not
	    set otherlibs for static NSS.
	    * nss/Makefile: Likewise.  Include libnss_files in libc.a for
	    --enable-static-nss.  Remove special case for getent.
	    * resolv/Makefile: Include libnss_dns in libc.a for
	    --enable-static-nss.


diff --git a/grp/Makefile b/grp/Makefile
index f14212e..541bb2b 100644
--- a/grp/Makefile
+++ b/grp/Makefile
@@ -38,12 +38,6 @@ endif
 
 include ../Rules
 
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a
-endif
-
-
 ifeq ($(have-thread-library),yes)
 
 CFLAGS-getgrgid_r.c = -DUSE_NSCD=1 -fexceptions
diff --git a/inet/Makefile b/inet/Makefile
index 1e67cdf..8923473 100644
--- a/inet/Makefile
+++ b/inet/Makefile
@@ -93,8 +93,3 @@ endif
 ifeq ($(build-static-nss),yes)
 CFLAGS += -DSTATIC_NSS
 endif
-
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a
-endif
diff --git a/login/Makefile b/login/Makefile
index 305d334..2d63c3b 100644
--- a/login/Makefile
+++ b/login/Makefile
@@ -49,11 +49,6 @@ include ../Rules
 
 CFLAGS-getpt.c = -fexceptions
 
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a $(common-objpfx)libc.a
-endif
-
 ifeq (yesyes,$(have-fpie)$(build-shared))
 pt_chown-cflags += $(pie-ccflag)
 endif
diff --git a/nscd/Makefile b/nscd/Makefile
index f6965dd..216ae0d 100644
--- a/nscd/Makefile
+++ b/nscd/Makefile
@@ -46,11 +46,6 @@ extra-objs = $(nscd-modules:=.o)
 
 endif
 
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a
-endif
-
 all-nscd-modules := $(nscd-modules) selinux
 ifeq (yes,$(have-selinux))
 ifeq (yes,$(have-libaudit))
diff --git a/nss/Makefile b/nss/Makefile
index 65c094d..143247b 100644
--- a/nss/Makefile
+++ b/nss/Makefile
@@ -46,11 +46,6 @@ xtests			= bug-erange
 
 include ../Makeconfig
 
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a
-endif
-
 # Specify rules for the nss_* modules.  We have some services.
 services		:= files db
 
@@ -79,19 +74,16 @@ distribute		+= $(addprefix nss_db/, db-XXX.c nss_db.h)
 
 install-others		+= $(inst_vardbdir)/Makefile
 
-# Build static module if requested
-ifneq ($(build-static-nss),yes)
+# Build static module into libc if requested
 libnss_files-inhibit-o	= $(filter-out .os,$(object-suffixes))
 libnss_db-inhibit-o	= $(filter-out .os,$(object-suffixes))
+ifeq ($(build-static-nss),yes)
+o-objects.o += $(addsuffix .o,$(libnss_files-routines))
+o-objects.op += $(addsuffix .op,$(libnss_files-routines))
 endif
 
 include ../Rules
 
-
-ifeq (yes,$(build-static-nss))
-$(objpfx)getent: $(objpfx)libnss_files.a
-endif
-
 ifeq (yes,$(have-selinux))
 LDLIBS-makedb		:= -lselinux
 endif
diff --git a/posix/Makefile b/posix/Makefile
index 565861f..bb223b7 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -119,14 +119,6 @@ generated := $(addprefix wordexp-test-result, 1 2 3 4 5 6 7 8 9 10) \
 
 include ../Rules
 
-ifeq (yes,$(build-static-nss))
-# We need it for "make check" only. We can skip them if they haven't
-# been built yet during "make".
-otherlibs += $(wildcard $(nssobjdir)/libnss_files.a \
-			$(resolvobjdir)/libnss_dns.a \
-			$(resolvobjdir)/libresolv.a)
-endif
-
 ifeq (no,$(cross-compiling))
 # globtest and wordexp-test currently only works with shared libraries
 ifeq (yes,$(build-shared))
diff --git a/pwd/Makefile b/pwd/Makefile
index a99099c..1da4059 100644
--- a/pwd/Makefile
+++ b/pwd/Makefile
@@ -39,8 +39,3 @@ CFLAGS-getpw.c = -fexceptions
 CFLAGS-fgetpwent_r.c = -D_IO_MTSAFE_IO
 
 endif
-
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-             $(resolvobjdir)/libresolv.a
-endif
diff --git a/resolv/Makefile b/resolv/Makefile
index 1c7b491..ac4bf48 100644
--- a/resolv/Makefile
+++ b/resolv/Makefile
@@ -57,8 +57,10 @@ subdir-dirs = nss_dns
 vpath %.c nss_dns
 
 libnss_dns-routines	:= dns-host dns-network dns-canon
-ifneq ($(build-static-nss),yes)
 libnss_dns-inhibit-o	= $(filter-out .os,$(object-suffixes))
+ifeq ($(build-static-nss),yes)
+o-objects.o += $(addsuffix .o,$(libnss_dns-routines) $(libresolv-routines))
+o-objects.op += $(addsuffix .op,$(libnss_dns-routines) $(libresolv-routines))
 endif
 
 ifeq (yesyes,$(build-shared)$(have-thread-library))
diff --git a/rt/Makefile b/rt/Makefile
index 14a2df3..8d27040 100644
--- a/rt/Makefile
+++ b/rt/Makefile
@@ -80,8 +80,3 @@ $(tests:%=$(objpfx)%-bp): $(objpfx)librt_b.a $(bounded-thread-library)
 endif
 
 tst-mqueue7-ARGS = -- $(built-program-cmd)
-
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a
-endif
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index b7f63a5..e7c6122 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -102,11 +102,6 @@ xtests += thrsvc
 endif
 distribute += thrsvc.c
 
-ifeq (yes,$(build-static-nss))
-otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
-	     $(resolvobjdir)/libresolv.a
-endif
-
 ifeq (no,$(cross-compiling))
 # We can only build this library if we can run the rpcgen we build.
 headers += $(rpcsvc:%.x=rpcsvc/%.h)


More information about the Libc-alpha mailing list