* Link extra-libs consistently with libc and ld.so @ 2013-05-09 0:22 Joseph S. Myers 2013-05-10 0:01 ` David Holsgrove 2013-05-14 0:32 ` Joseph S. Myers 0 siblings, 2 replies; 11+ messages in thread From: Joseph S. Myers @ 2013-05-09 0:22 UTC (permalink / raw) To: libc-alpha; +Cc: libc-ports As has been discussed on various occasions, it's desirable in principle for miscellaneous shared objects and executables installed by glibc to be built in as similar a way as possible to such objects built with an installed libc: there should only be differences from how something would be built with an installed libc where there is a good reason for those differences, which is mainly the case for libc and ld.so but not for other libraries. In particular, shared objects built outside of a glibc build are generally linked with libc.so, which is installed as a linker script with contents of the form /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf64-x86-64) GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) ) so indicating that appropriate linker options and libraries should be passed for a link as part of a glibc build to replicate the effects of such a linker script. At present, links of libraries in extra-libs do not generally link with libc or ld.so, but various individual makefiles contain code to make particular libraries link that way. This patch moves such code into the toplevel Makerules, eliminating the cases in subdirectory makefiles. Tested x86_64 and x86; also tested for ARM (GCC configured --with-tls=gnu2) that glibc builds OK. I haven't tested the changes for PowerPC or MicroBlaze. Some unresolved issues with this patch about how best to do certain things: * In Makerules I link with ld.so in the form $(common-objpfx)elf/ld.so. Other versions used in removed code include $(elf-objpfx)$(rtld-installed-name) and $(elfobjdir)/ld.so. Which is the best form to use in glibc makefiles? * Some libraries need to link with the internal linkobj/libc.so, rather than the normal libc.so, because of use of obsolete RPC interfaces. To support this, the rule in Makerules allows $($(@F)-libc) to be used instead of the default $(common-objpfx)libc.so. But a previous arrangement where dependencies were generated for every library listed in $(services) in nis/Makefile and nss/Makefile has been replaced by one where a variable for each library is set separately (libnss_nis.so-libc, libnss_nisplus.so-libc etc.) - is there a good way, without unduly increasing complexity, to set such variables for everything in $(services) without the repetition of the list of elements of $(services)? * This patch doesn't add libc.so, libc_nonshared.a and ld.so to the makefile dependencies of the objects being linked with them. Dependencies would get automatically included in the list of objects to link, via build-shlib-objlist and build-module-helper-objlist used therein - and so not inside the --start-group / --end-group pair and --as-needed / --no-as-needed used to replicate how linking with an installed library would operate. Filtering them out in build-module-helper-objlist would affect build-module. Should I make build-module-helper-objlist filter them out, and change also how modules are built, so that build-module includes the same sequence of arguments for linking with libc/ld.so as used after this patch in lib%.so? (Changing also build-module-asneeded would allow eliminating the special-case dependencies in elf/Makefile for sotruss-lib.so.) 2013-05-09 Joseph Myers <joseph@codesourcery.com> * Makerules (lib%.so): Link with shared libc, libc_nonshared, and (with --as-needed) ld.so. * crypt/Makefile ($(objpfx)libcrypt.so): Remove dependencies on libc. * debug/Makefile ($(objpfx)libSegFault.so): Remove dependencies on libc and ld.so. ($(objpfx)libpcprofile.so): Likewise. * dlfcn/Makefile ($(objpfx)libdl.so): Likewise. * hesiod/Makefile ($(objpfx)libnss_hesiod.so): Likewise. * locale/Makefile ($(objpfx)libBrokenLocale.so): Likewise. * login/Makefile ($(objpfx)libutil.so): Likewise. * malloc/Makefile ($(objpfx)libmemusage.so): Likewise. * math/Makefile ($(objpfx)libm.so): Likewise. * nis/Makefile (libnss_nis.so-libc): New variable. (libnss_nisplus.so-libc): Likewise. (libnss_compat.so-libc): Likewise. (libnsl.so-libc): Likewise. ($(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so): Remove dependencies on libc. * nss/Makefile (libnss_files.so-libc): New variable. (libnss_db.so-libc): Likewise. ($(services:%=$(objpfx)libnss_%.so)): Remove dependencies on libc. * resolv/Makefile ($(objpfx)libresolv.so): Remove dependencies on libc. [$(have-ssp) = yes] (LDLIBS-resolv.so): Remove variable. ($(objpfx)libnss_dns.so): Remove dependencies on libc. ($(objpfx)libanl.so): Likewise. * rt/Makefile ($(objpfx)librt.so): Remove dependencies on libc and ld.so. * sysdeps/i386/fpu/Makefile: Remove file. * sysdeps/powerpc/fpu/Makefile [$(subdir) = math] ($(objpfx)libm.so): Remove dependency on ld.so. libidn/ChangeLog: 2013-05-08 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libcidn.so): Remove dependencies on libc. nptl/ChangeLog: 2013-05-08 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libpthread.so): Remove dependencies on libc and ld.so. nptl_db/ChangeLog: 2013-05-08 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libthread_db.so): Remove dependencies on libc. ports/ChangeLog.arm: 2013-05-08 Joseph Myers <joseph@codesourcery.com> * sysdeps/arm/Makefile [$(subdir) = malloc] ($(objpfx)libmemusage.so): Remove dependency on libc_nonshared. [$(subdir) = math] ($(objpfx)libm.so): Remove dependency on ld.so. ports/ChangeLog.microblaze 2013-05-08 Joseph Myers <joseph@codesourcery.com> * sysdeps/microblaze/Makefile ($(objpfx)libm.so): Remove dependency on ld.so. ($(objpfx)libcrypt.so): Likewise. ($(objpfx)libresolv.so): Likewise. ($(objpfx)libnss_dns.so): Likewise. ($(objpfx)libnss_files.so): Likewise. ($(objpfx)libnss_db.so): Likewise. ($(objpfx)libnss_nis.so): Likewise. ($(objpfx)libnss_nisplus.so): Likewise. ($(objpfx)libnss_hesiod.so): Likewise. ($(objpfx)libnss_compat.so): Likewise. ($(objpfx)libanl.so): Likewise. ($(objpfx)libnsl.so): Likewise. ($(objpfx)libcidn.so): Likewise. ($(objpfx)libutil.so): Likewise. diff --git a/Makerules b/Makerules index d88bb62..2ea47c8 100644 --- a/Makerules +++ b/Makerules @@ -436,9 +436,15 @@ endif # This must come after the installation rules so Make doesn't try to # build shared libraries in place from the installed *_pic.a files. # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies -# on other shared objects. +# on other shared objects. The linking with libc and ld.so is intended +# to be as similar as possible to a default link with an installed libc. lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) - $(build-shlib) + $(build-shlib) -Wl,--start-group \ + $(if $($(@F)-libc),$($(@F)-libc),\ + $(common-objpfx)libc.so) \ + $(common-objpfx)libc_nonshared.a \ + $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) \ + -Wl,--end-group define build-shlib-helper $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \ diff --git a/crypt/Makefile b/crypt/Makefile index 0f5f099..238e527 100644 --- a/crypt/Makefile +++ b/crypt/Makefile @@ -69,8 +69,3 @@ $(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.so else $(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.a endif - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libcrypt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/debug/Makefile b/debug/Makefile index 9b5afb4..779741f 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -186,13 +186,3 @@ $(objpfx)xtrace: xtrace.sh -e 's|@PKGVERSION@|$(PKGVERSION)|' \ -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \ && rm -f $@ && mv $@.new $@ && chmod +x $@ - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libSegFault.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elf-objpfx)$(rtld-installed-name) -$(objpfx)libpcprofile.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elf-objpfx)$(rtld-installed-name) diff --git a/dlfcn/Makefile b/dlfcn/Makefile index cf4428c..1e7b7c1 100644 --- a/dlfcn/Makefile +++ b/dlfcn/Makefile @@ -121,10 +121,3 @@ LDLIBS-bug-atexit3-lib.so = -lstdc++ -lgcc_eh $(elfobjdir)/ld.so \ $(common-objpfx)libc_nonshared.a $(objpfx)bug-atexit3: $(libdl) $(objpfx)bug-atexit3.out: $(objpfx)bug-atexit3-lib.so - - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libdl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(elfobjdir)/ld.so diff --git a/hesiod/Makefile b/hesiod/Makefile index 95ec252..b7a13c2 100644 --- a/hesiod/Makefile +++ b/hesiod/Makefile @@ -33,12 +33,7 @@ libnss_hesiod-inhibit-o = $(filter-out .os,$(object-suffixes)) include ../Rules -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -# The Hesiod NSS modules also needs the resolver and some help from +# The Hesiod NSS module also needs the resolver and some help from # the file service. $(objpfx)libnss_hesiod.so: $(common-objpfx)resolv/libresolv.so \ - $(common-objpfx)nss/libnss_files.so \ - $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a + $(common-objpfx)nss/libnss_files.so diff --git a/libidn/Makefile b/libidn/Makefile index 1c578c1..de26051 100644 --- a/libidn/Makefile +++ b/libidn/Makefile @@ -33,5 +33,3 @@ include $(..)Makeconfig libcidn-inhibit-o = $(filter-out .os,$(object-suffixes)) include $(..)Rules - -$(objpfx)libcidn.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/locale/Makefile b/locale/Makefile index 8bab9a0..8ccc603 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -98,9 +98,3 @@ cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \ $(locale-modules) $(lib-modules)) lib := locale-programs include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libBrokenLocale.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a diff --git a/login/Makefile b/login/Makefile index 61c9d7e..0bfe643 100644 --- a/login/Makefile +++ b/login/Makefile @@ -68,8 +68,3 @@ endif $(inst_libexecdir)/pt_chown: $(objpfx)pt_chown $(+force) $(make-target-directory) -$(INSTALL_PROGRAM) -m 4755 -o root $< $@ - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libutil.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/malloc/Makefile b/malloc/Makefile index 05f9b15..0fe31a4 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -141,7 +141,7 @@ $(objpfx)memusage: memusage.sh # The implementation uses `dlsym' -$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so $(elfobjdir)/ld.so +$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so # Extra dependencies $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c diff --git a/math/Makefile b/math/Makefile index 5bbf9d3..3ed78fc 100644 --- a/math/Makefile +++ b/math/Makefile @@ -229,8 +229,3 @@ gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\ $(objpfx)atest-exp: $(gmp-objs) $(objpfx)atest-sincos: $(gmp-objs) $(objpfx)atest-exp2: $(gmp-objs) - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libm.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/nis/Makefile b/nis/Makefile index 0b3b6a2..45a36c9 100644 --- a/nis/Makefile +++ b/nis/Makefile @@ -76,12 +76,11 @@ $(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \ $(common-objpfx)nss/libnss_files.so $(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. libnsl-libc = $(common-objpfx)linkobj/libc.so -$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: $(libnsl-libc) \ - $(common-objpfx)libc_nonshared.a +libnss_nis.so-libc = $(libnsl-libc) +libnss_nisplus.so-libc = $(libnsl-libc) +libnss_compat.so-libc = $(libnsl-libc) +libnsl.so-libc = $(libnsl-libc) ifeq ($(build-shared),yes) diff --git a/nptl/Makefile b/nptl/Makefile index 6af4b37..7fa991b 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -507,14 +507,6 @@ $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs)) $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs)) $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs)) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -# Depend on ld.so too to get proper versions of ld.so symbols. -$(objpfx)libpthread.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elfobjdir)/ld.so - # Make sure we link with the thread library. ifeq ($(build-shared),yes) $(addprefix $(objpfx), \ diff --git a/nptl_db/Makefile b/nptl_db/Makefile index 533fbae..77ea46e 100644 --- a/nptl_db/Makefile +++ b/nptl_db/Makefile @@ -51,12 +51,6 @@ libthread_db.so-no-z-defs = yes include ../Rules -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libthread_db.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a - tests: $(objpfx)db-symbols.out $(objpfx)db-symbols.out: $(objpfx)db-symbols.v.i \ $(common-objpfx)nptl/libpthread.so diff --git a/nss/Makefile b/nss/Makefile index 449a258..2c7da13 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -84,12 +84,9 @@ ifeq (yes,$(have-selinux)) LDLIBS-makedb := -lselinux endif -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. libnss-libc = $(common-objpfx)linkobj/libc.so -$(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \ - $(common-objpfx)libc_nonshared.a +libnss_files.so-libc = $(libnss-libc) +libnss_db.so-libc = $(libnss-libc) $(objpfx)libnss_db.so: $(objpfx)libnss_files.so diff --git a/ports/sysdeps/arm/Makefile b/ports/sysdeps/arm/Makefile index 3bdb6b3..b218e76 100644 --- a/ports/sysdeps/arm/Makefile +++ b/ports/sysdeps/arm/Makefile @@ -25,11 +25,6 @@ sysdep_routines += $(aeabi_constants) $(aeabi_routines) static-only-routines += $(aeabi_constants) endif -# to pull in __aeabi_read_tp, needed for tls -ifeq ($(subdir),malloc) -$(objpfx)libmemusage.so: $(common-objpfx)libc_nonshared.a -endif - ifeq ($(subdir),gmon) sysdep_routines += arm-mcount endif @@ -37,7 +32,3 @@ endif ifeq ($(subdir),debug) CFLAGS-backtrace.c += -funwind-tables endif - -ifeq ($(subdir),math) -$(objpfx)libm.so: $(elfobjdir)/ld.so -endif diff --git a/ports/sysdeps/microblaze/Makefile b/ports/sysdeps/microblaze/Makefile index cc82a74..f7c95ae 100644 --- a/ports/sysdeps/microblaze/Makefile +++ b/ports/sysdeps/microblaze/Makefile @@ -9,18 +9,3 @@ endif ifeq ($(subdir),resource) sysdep_routines += backtrace_linux endif - -$(objpfx)libm.so: $(elfobjdir)/ld.so -$(objpfx)libcrypt.so: $(elfobjdir)/ld.so -$(objpfx)libresolv.so: $(elfobjdir)/ld.so -$(objpfx)libnss_dns.so: $(elfobjdir)/ld.so -$(objpfx)libnss_files.so: $(elfobjdir)/ld.so -$(objpfx)libnss_db.so: $(elfobjdir)/ld.so -$(objpfx)libnss_nis.so: $(elfobjdir)/ld.so -$(objpfx)libnss_nisplus.so: $(elfobjdir)/ld.so -$(objpfx)libnss_hesiod.so: $(elfobjdir)/ld.so -$(objpfx)libnss_compat.so: $(elfobjdir)/ld.so -$(objpfx)libanl.so: $(elfobjdir)/ld.so -$(objpfx)libnsl.so: $(elfobjdir)/ld.so -$(objpfx)libcidn.so: $(elfobjdir)/ld.so -$(objpfx)libutil.so: $(elfobjdir)/ld.so diff --git a/resolv/Makefile b/resolv/Makefile index d3635bc..51dcf21 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -83,23 +83,11 @@ CFLAGS-res_hconf.c = -fexceptions # The BIND code elicits some harmless warnings. +cflags += -Wno-strict-prototypes -Wno-write-strings -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libresolv.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a -# Some hosts need '__stack_chk_guard', so pull in the definition from -# ld.so if required. -ifeq (yes,$(have-ssp)) -LDLIBS-resolv.so += $(as-needed) $(elfobjdir)/ld.so $(no-as-needed) -endif - # The DNS NSS modules needs the resolver. -$(objpfx)libnss_dns.so: $(objpfx)libresolv.so $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a +$(objpfx)libnss_dns.so: $(objpfx)libresolv.so # The asynchronous name lookup code needs the thread library. -$(objpfx)libanl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(shared-thread-library) +$(objpfx)libanl.so: $(shared-thread-library) $(objpfx)ga_test: $(objpfx)libanl.so $(shared-thread-library) diff --git a/rt/Makefile b/rt/Makefile index ef356d0..b1392f2 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -64,12 +64,7 @@ CFLAGS-librt-cancellation.c = -fasynchronous-unwind-tables LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)librt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(shared-thread-library) \ - $(elfobjdir)/ld.so +$(objpfx)librt.so: $(shared-thread-library) ifeq (yes,$(build-shared)) $(addprefix $(objpfx),$(tests)): $(objpfx)librt.so $(shared-thread-library) diff --git a/sysdeps/i386/fpu/Makefile b/sysdeps/i386/fpu/Makefile deleted file mode 100644 index 1309b64..0000000 --- a/sysdeps/i386/fpu/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(subdir),math) -$(objpfx)libm.so: $(elfobjdir)/ld.so -endif diff --git a/sysdeps/powerpc/fpu/Makefile b/sysdeps/powerpc/fpu/Makefile index fda59f9..53470a9 100644 --- a/sysdeps/powerpc/fpu/Makefile +++ b/sysdeps/powerpc/fpu/Makefile @@ -1,8 +1,5 @@ ifeq ($(subdir),math) libm-support += fenv_const fe_nomask fe_mask t_sqrt - -# libm needs ld.so to access dl_hwcap -$(objpfx)libm.so: $(elfobjdir)/ld.so endif ifeq ($(subdir),stdlib) -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-09 0:22 Link extra-libs consistently with libc and ld.so Joseph S. Myers @ 2013-05-10 0:01 ` David Holsgrove 2013-05-14 0:32 ` Joseph S. Myers 1 sibling, 0 replies; 11+ messages in thread From: David Holsgrove @ 2013-05-10 0:01 UTC (permalink / raw) To: Joseph S. Myers; +Cc: libc-alpha, libc-ports Hi Joseph, On 9 May 2013 10:22, Joseph S. Myers <joseph@codesourcery.com> wrote: [--snip--] > > Tested x86_64 and x86; also tested for ARM (GCC configured > --with-tls=gnu2) that glibc builds OK. I haven't tested the changes > for PowerPC or MicroBlaze. > I've tested your patch for MicroBlaze - no build issues, and all my tests so far look good. From my point of view this is good for MicroBlaze, and great to see. thanks again, David > > -- > Joseph S. Myers > joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-09 0:22 Link extra-libs consistently with libc and ld.so Joseph S. Myers 2013-05-10 0:01 ` David Holsgrove @ 2013-05-14 0:32 ` Joseph S. Myers 2013-05-14 1:12 ` Roland McGrath 2013-05-17 20:24 ` Roland McGrath 1 sibling, 2 replies; 11+ messages in thread From: Joseph S. Myers @ 2013-05-14 0:32 UTC (permalink / raw) To: libc-alpha; +Cc: libc-ports I haven't seen any comments on the substance of this patch. Here is a revised version that deals with ensuring dependencies on libc and ld.so are present when they are used in linking, sharing the relevant linker arguments and dependencies with the handling of "modules" (.so files that aren't built with a SONAME). Tested x86_64 and x86. The other two questions from the previous version <http://sourceware.org/ml/libc-alpha/2013-05/msg00231.html> remain: * In Makerules I link with ld.so in the form $(common-objpfx)elf/ld.so. Other versions used in removed code include $(elf-objpfx)$(rtld-installed-name) and $(elfobjdir)/ld.so. Which is the best form to use in glibc makefiles? * Some libraries need to link with the internal linkobj/libc.so, rather than the normal libc.so, because of use of obsolete RPC interfaces. To support this, the rule in Makerules allows $($(@F)-libc) to be used instead of the default $(common-objpfx)libc.so. But a previous arrangement where dependencies were generated for every library listed in $(services) in nis/Makefile and nss/Makefile has been replaced by one where a variable for each library is set separately (libnss_nis.so-libc, libnss_nisplus.so-libc etc.) - is there a good way, without unduly increasing complexity, to set such variables for everything in $(services) without the repetition of the list of elements of $(services)? 2013-05-14 Joseph Myers <joseph@codesourcery.com> * Makerules (link-libc-args): New variable. (link-libc-deps): Likewise. (lib%.so): Depend in $(link-libc-deps). Link with $(link-libc-args). (build-module): Link with $(link-libc-args). (build-module-asneeded): Likewise. (build-module-helper-objlist): Filter out $(link-libc-deps) from list of objects unless $($(@F)-no-libc-filter). (libc.so-no-libc-filter): New variable. ($(extra-modules-build:%=$(objpfx)%.so)): Depend on $(link-libc-deps) instead of libc.so and libc_nonshared.a. * crypt/Makefile ($(objpfx)libcrypt.so): Remove dependencies on libc. * debug/Makefile ($(objpfx)libSegFault.so): Remove dependencies on libc and ld.so. ($(objpfx)libpcprofile.so): Likewise. * dlfcn/Makefile (LDLIBS-bug-atexit3-lib.so): Remove ld.so and libc_nonshared.a. ($(objpfx)libdl.so): Remove dependencies on libc and ld.so. * hesiod/Makefile ($(objpfx)libnss_hesiod.so): Likewise. * locale/Makefile ($(objpfx)libBrokenLocale.so): Likewise. * login/Makefile ($(objpfx)libutil.so): Likewise. * malloc/Makefile ($(objpfx)libmemusage.so): Likewise. * math/Makefile ($(objpfx)libm.so): Likewise. * nis/Makefile (libnss_nis.so-libc): New variable. (libnss_nisplus.so-libc): Likewise. (libnss_compat.so-libc): Likewise. (libnsl.so-libc): Likewise. ($(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so): Remove dependencies on libc. * nss/Makefile (libnss_files.so-libc): New variable. (libnss_db.so-libc): Likewise. ($(services:%=$(objpfx)libnss_%.so)): Remove dependencies on libc. ($(objpfx)/libnss_test1.so): Change dependencies on libc to $(link-libc-deps). * resolv/Makefile ($(objpfx)libresolv.so): Remove dependencies on libc. [$(have-ssp) = yes] (LDLIBS-resolv.so): Remove variable. ($(objpfx)libnss_dns.so): Remove dependencies on libc. ($(objpfx)libanl.so): Likewise. * rt/Makefile ($(objpfx)librt.so): Remove dependencies on libc and ld.so. * stdlib/Makefile ($(objpfx)tst-putenvmod.so): Depend on $(link-libc-deps). * sysdeps/i386/fpu/Makefile: Remove file. * sysdeps/powerpc/fpu/Makefile [$(subdir) = math] ($(objpfx)libm.so): Remove dependency on ld.so. libidn/ChangeLog: 2013-05-14 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libcidn.so): Remove dependencies on libc. nptl/ChangeLog: 2013-05-14 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libpthread.so): Remove dependencies on libc and ld.so. nptl_db/ChangeLog: 2013-05-14 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libthread_db.so): Remove dependencies on libc. ports/ChangeLog.arm: 2013-05-14 Joseph Myers <joseph@codesourcery.com> * sysdeps/arm/Makefile [$(subdir) = malloc] ($(objpfx)libmemusage.so): Remove dependency on libc_nonshared. [$(subdir) = math] ($(objpfx)libm.so): Remove dependency on ld.so. ports/ChangeLog.microblaze 2013-05-14 Joseph Myers <joseph@codesourcery.com> * sysdeps/microblaze/Makefile ($(objpfx)libm.so): Remove dependency on ld.so. ($(objpfx)libcrypt.so): Likewise. ($(objpfx)libresolv.so): Likewise. ($(objpfx)libnss_dns.so): Likewise. ($(objpfx)libnss_files.so): Likewise. ($(objpfx)libnss_db.so): Likewise. ($(objpfx)libnss_nis.so): Likewise. ($(objpfx)libnss_nisplus.so): Likewise. ($(objpfx)libnss_hesiod.so): Likewise. ($(objpfx)libnss_compat.so): Likewise. ($(objpfx)libanl.so): Likewise. ($(objpfx)libnsl.so): Likewise. ($(objpfx)libcidn.so): Likewise. ($(objpfx)libutil.so): Likewise. diff --git a/Makerules b/Makerules index d88bb62..c7a4720 100644 --- a/Makerules +++ b/Makerules @@ -432,13 +432,29 @@ map-file = $(firstword $($(@F:.so=-map)) \ load-map-file = $(map-file:%=-Wl,--version-script=%) endif +# Compiler arguments to use to link a shared object with libc and +# ld.so. This is intended to be as similar as possible to a default +# link with an installed libc. +link-libc-args = -Wl,--start-group \ + $(if $($(@F)-libc),$($(@F)-libc),$(common-objpfx)libc.so) \ + $(common-objpfx)libc_nonshared.a \ + $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) \ + -Wl,--end-group + +# The corresponding dependencies. As these are used in dependencies, +# not just commands, they cannot use $(@F) so need to name both +# possible libc.so objects. +link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \ + $(common-objpfx)libc_nonshared.a $(common-objpfx)elf/ld.so + # Pattern rule to build a shared object from an archive of PIC objects. # This must come after the installation rules so Make doesn't try to # build shared libraries in place from the installed *_pic.a files. # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies -# on other shared objects. -lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) - $(build-shlib) +# on other shared objects. The linking with libc and ld.so is intended +# to be as similar as possible to a default link with an installed libc. +lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) $(link-libc-deps) + $(build-shlib) $(link-libc-args) define build-shlib-helper $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \ @@ -513,17 +529,20 @@ endef # not for shared objects define build-module $(build-module-helper) -o $@ $(shlib-lds-flags) \ - $(csu-objpfx)abi-note.o $(build-module-objlist) + $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args) endef define build-module-asneeded $(build-module-helper) -o $@ $(shlib-lds-flags) \ $(csu-objpfx)abi-note.o \ - -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed + -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \ + $(link-libc-args) endef build-module-helper-objlist = \ $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\ - $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^)) + $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \ + $(if $($(@F)-no-libc-filter),,\ + $(link-libc-deps)),$^)) build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so) build-shlib-objlist = $(build-module-helper-objlist) \ @@ -567,6 +586,7 @@ libc_pic_clean := .clean endif # Use our own special initializer and finalizer files for libc.so. +libc.so-no-libc-filter = yes $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \ $(common-objpfx)libc_pic.os$(libc_pic_clean) \ $(elfobjdir)/sofini.os \ @@ -621,8 +641,7 @@ include $(patsubst %,$(..)extra-modules.mk,$(modules-names)) extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names)) $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \ - $(objpfx)%.os $(shlib-lds) \ - $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a + $(objpfx)%.os $(shlib-lds) $(link-libs-deps) $(build-module) endif \f diff --git a/crypt/Makefile b/crypt/Makefile index 0f5f099..238e527 100644 --- a/crypt/Makefile +++ b/crypt/Makefile @@ -69,8 +69,3 @@ $(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.so else $(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.a endif - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libcrypt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/debug/Makefile b/debug/Makefile index 9b5afb4..779741f 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -186,13 +186,3 @@ $(objpfx)xtrace: xtrace.sh -e 's|@PKGVERSION@|$(PKGVERSION)|' \ -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \ && rm -f $@ && mv $@.new $@ && chmod +x $@ - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libSegFault.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elf-objpfx)$(rtld-installed-name) -$(objpfx)libpcprofile.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elf-objpfx)$(rtld-installed-name) diff --git a/dlfcn/Makefile b/dlfcn/Makefile index cf4428c..c2ebdca 100644 --- a/dlfcn/Makefile +++ b/dlfcn/Makefile @@ -117,14 +117,6 @@ $(objpfx)bug-atexit1.out: $(objpfx)bug-atexit1-lib.so $(objpfx)bug-atexit2: $(libdl) $(objpfx)bug-atexit2.out: $(objpfx)bug-atexit2-lib.so -LDLIBS-bug-atexit3-lib.so = -lstdc++ -lgcc_eh $(elfobjdir)/ld.so \ - $(common-objpfx)libc_nonshared.a +LDLIBS-bug-atexit3-lib.so = -lstdc++ -lgcc_eh $(objpfx)bug-atexit3: $(libdl) $(objpfx)bug-atexit3.out: $(objpfx)bug-atexit3-lib.so - - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libdl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(elfobjdir)/ld.so diff --git a/hesiod/Makefile b/hesiod/Makefile index 95ec252..b7a13c2 100644 --- a/hesiod/Makefile +++ b/hesiod/Makefile @@ -33,12 +33,7 @@ libnss_hesiod-inhibit-o = $(filter-out .os,$(object-suffixes)) include ../Rules -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -# The Hesiod NSS modules also needs the resolver and some help from +# The Hesiod NSS module also needs the resolver and some help from # the file service. $(objpfx)libnss_hesiod.so: $(common-objpfx)resolv/libresolv.so \ - $(common-objpfx)nss/libnss_files.so \ - $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a + $(common-objpfx)nss/libnss_files.so diff --git a/libidn/Makefile b/libidn/Makefile index 1c578c1..de26051 100644 --- a/libidn/Makefile +++ b/libidn/Makefile @@ -33,5 +33,3 @@ include $(..)Makeconfig libcidn-inhibit-o = $(filter-out .os,$(object-suffixes)) include $(..)Rules - -$(objpfx)libcidn.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/locale/Makefile b/locale/Makefile index 8bab9a0..8ccc603 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -98,9 +98,3 @@ cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \ $(locale-modules) $(lib-modules)) lib := locale-programs include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libBrokenLocale.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a diff --git a/login/Makefile b/login/Makefile index 61c9d7e..0bfe643 100644 --- a/login/Makefile +++ b/login/Makefile @@ -68,8 +68,3 @@ endif $(inst_libexecdir)/pt_chown: $(objpfx)pt_chown $(+force) $(make-target-directory) -$(INSTALL_PROGRAM) -m 4755 -o root $< $@ - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libutil.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/malloc/Makefile b/malloc/Makefile index 05f9b15..0fe31a4 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -141,7 +141,7 @@ $(objpfx)memusage: memusage.sh # The implementation uses `dlsym' -$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so $(elfobjdir)/ld.so +$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so # Extra dependencies $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c diff --git a/math/Makefile b/math/Makefile index 5bbf9d3..3ed78fc 100644 --- a/math/Makefile +++ b/math/Makefile @@ -229,8 +229,3 @@ gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\ $(objpfx)atest-exp: $(gmp-objs) $(objpfx)atest-sincos: $(gmp-objs) $(objpfx)atest-exp2: $(gmp-objs) - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libm.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/nis/Makefile b/nis/Makefile index 0b3b6a2..45a36c9 100644 --- a/nis/Makefile +++ b/nis/Makefile @@ -76,12 +76,11 @@ $(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \ $(common-objpfx)nss/libnss_files.so $(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. libnsl-libc = $(common-objpfx)linkobj/libc.so -$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: $(libnsl-libc) \ - $(common-objpfx)libc_nonshared.a +libnss_nis.so-libc = $(libnsl-libc) +libnss_nisplus.so-libc = $(libnsl-libc) +libnss_compat.so-libc = $(libnsl-libc) +libnsl.so-libc = $(libnsl-libc) ifeq ($(build-shared),yes) diff --git a/nptl/Makefile b/nptl/Makefile index 6af4b37..7fa991b 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -507,14 +507,6 @@ $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs)) $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs)) $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs)) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -# Depend on ld.so too to get proper versions of ld.so symbols. -$(objpfx)libpthread.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elfobjdir)/ld.so - # Make sure we link with the thread library. ifeq ($(build-shared),yes) $(addprefix $(objpfx), \ diff --git a/nptl_db/Makefile b/nptl_db/Makefile index 533fbae..77ea46e 100644 --- a/nptl_db/Makefile +++ b/nptl_db/Makefile @@ -51,12 +51,6 @@ libthread_db.so-no-z-defs = yes include ../Rules -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libthread_db.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a - tests: $(objpfx)db-symbols.out $(objpfx)db-symbols.out: $(objpfx)db-symbols.v.i \ $(common-objpfx)nptl/libpthread.so diff --git a/nss/Makefile b/nss/Makefile index 449a258..0cd80b1 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -84,12 +84,9 @@ ifeq (yes,$(have-selinux)) LDLIBS-makedb := -lselinux endif -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. libnss-libc = $(common-objpfx)linkobj/libc.so -$(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \ - $(common-objpfx)libc_nonshared.a +libnss_files.so-libc = $(libnss-libc) +libnss_db.so-libc = $(libnss-libc) $(objpfx)libnss_db.so: $(objpfx)libnss_files.so @@ -107,8 +104,7 @@ $(inst_vardbdir)/Makefile: db-Makefile $(+force) $(do-install) CFLAGS-nss_test1.c = -DNOT_IN_libc=1 -$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a +$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) $(build-module) ifdef libnss_test1.so-version $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so diff --git a/ports/sysdeps/arm/Makefile b/ports/sysdeps/arm/Makefile index 3bdb6b3..b218e76 100644 --- a/ports/sysdeps/arm/Makefile +++ b/ports/sysdeps/arm/Makefile @@ -25,11 +25,6 @@ sysdep_routines += $(aeabi_constants) $(aeabi_routines) static-only-routines += $(aeabi_constants) endif -# to pull in __aeabi_read_tp, needed for tls -ifeq ($(subdir),malloc) -$(objpfx)libmemusage.so: $(common-objpfx)libc_nonshared.a -endif - ifeq ($(subdir),gmon) sysdep_routines += arm-mcount endif @@ -37,7 +32,3 @@ endif ifeq ($(subdir),debug) CFLAGS-backtrace.c += -funwind-tables endif - -ifeq ($(subdir),math) -$(objpfx)libm.so: $(elfobjdir)/ld.so -endif diff --git a/ports/sysdeps/microblaze/Makefile b/ports/sysdeps/microblaze/Makefile index cc82a74..f7c95ae 100644 --- a/ports/sysdeps/microblaze/Makefile +++ b/ports/sysdeps/microblaze/Makefile @@ -9,18 +9,3 @@ endif ifeq ($(subdir),resource) sysdep_routines += backtrace_linux endif - -$(objpfx)libm.so: $(elfobjdir)/ld.so -$(objpfx)libcrypt.so: $(elfobjdir)/ld.so -$(objpfx)libresolv.so: $(elfobjdir)/ld.so -$(objpfx)libnss_dns.so: $(elfobjdir)/ld.so -$(objpfx)libnss_files.so: $(elfobjdir)/ld.so -$(objpfx)libnss_db.so: $(elfobjdir)/ld.so -$(objpfx)libnss_nis.so: $(elfobjdir)/ld.so -$(objpfx)libnss_nisplus.so: $(elfobjdir)/ld.so -$(objpfx)libnss_hesiod.so: $(elfobjdir)/ld.so -$(objpfx)libnss_compat.so: $(elfobjdir)/ld.so -$(objpfx)libanl.so: $(elfobjdir)/ld.so -$(objpfx)libnsl.so: $(elfobjdir)/ld.so -$(objpfx)libcidn.so: $(elfobjdir)/ld.so -$(objpfx)libutil.so: $(elfobjdir)/ld.so diff --git a/resolv/Makefile b/resolv/Makefile index d3635bc..51dcf21 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -83,23 +83,11 @@ CFLAGS-res_hconf.c = -fexceptions # The BIND code elicits some harmless warnings. +cflags += -Wno-strict-prototypes -Wno-write-strings -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libresolv.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a -# Some hosts need '__stack_chk_guard', so pull in the definition from -# ld.so if required. -ifeq (yes,$(have-ssp)) -LDLIBS-resolv.so += $(as-needed) $(elfobjdir)/ld.so $(no-as-needed) -endif - # The DNS NSS modules needs the resolver. -$(objpfx)libnss_dns.so: $(objpfx)libresolv.so $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a +$(objpfx)libnss_dns.so: $(objpfx)libresolv.so # The asynchronous name lookup code needs the thread library. -$(objpfx)libanl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(shared-thread-library) +$(objpfx)libanl.so: $(shared-thread-library) $(objpfx)ga_test: $(objpfx)libanl.so $(shared-thread-library) diff --git a/rt/Makefile b/rt/Makefile index ef356d0..b1392f2 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -64,12 +64,7 @@ CFLAGS-librt-cancellation.c = -fasynchronous-unwind-tables LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)librt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(shared-thread-library) \ - $(elfobjdir)/ld.so +$(objpfx)librt.so: $(shared-thread-library) ifeq (yes,$(build-shared)) $(addprefix $(objpfx),$(tests)): $(objpfx)librt.so $(shared-thread-library) diff --git a/stdlib/Makefile b/stdlib/Makefile index 27765d1..17d80e0 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -144,7 +144,7 @@ $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so LDFLAGS-tst-putenv = $(no-as-needed) -$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os +$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps) $(build-module) CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1 diff --git a/sysdeps/i386/fpu/Makefile b/sysdeps/i386/fpu/Makefile deleted file mode 100644 index 1309b64..0000000 --- a/sysdeps/i386/fpu/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(subdir),math) -$(objpfx)libm.so: $(elfobjdir)/ld.so -endif diff --git a/sysdeps/powerpc/fpu/Makefile b/sysdeps/powerpc/fpu/Makefile index fda59f9..53470a9 100644 --- a/sysdeps/powerpc/fpu/Makefile +++ b/sysdeps/powerpc/fpu/Makefile @@ -1,8 +1,5 @@ ifeq ($(subdir),math) libm-support += fenv_const fe_nomask fe_mask t_sqrt - -# libm needs ld.so to access dl_hwcap -$(objpfx)libm.so: $(elfobjdir)/ld.so endif ifeq ($(subdir),stdlib) -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-14 0:32 ` Joseph S. Myers @ 2013-05-14 1:12 ` Roland McGrath 2013-05-17 20:24 ` Roland McGrath 1 sibling, 0 replies; 11+ messages in thread From: Roland McGrath @ 2013-05-14 1:12 UTC (permalink / raw) To: Joseph S. Myers; +Cc: libc-alpha, libc-ports I agree with the intent. I still haven't reviewed the details, and won't have time to do it until the end of this week at the earliest. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-14 0:32 ` Joseph S. Myers 2013-05-14 1:12 ` Roland McGrath @ 2013-05-17 20:24 ` Roland McGrath 2013-05-17 21:36 ` Joseph S. Myers 2013-05-17 23:19 ` Joseph S. Myers 1 sibling, 2 replies; 11+ messages in thread From: Roland McGrath @ 2013-05-17 20:24 UTC (permalink / raw) To: Joseph S. Myers; +Cc: libc-alpha, libc-ports > * In Makerules I link with ld.so in the form > $(common-objpfx)elf/ld.so. Other versions used in removed code > include $(elf-objpfx)$(rtld-installed-name) and $(elfobjdir)/ld.so. > Which is the best form to use in glibc makefiles? elfobjdir and elf-objpfx are redundant. We should consolidate on just one or the other. I don't think it matters which. For linking, using ld.so makes sense. There is no need to use $(rtld-installed-name). > * Some libraries need to link with the internal linkobj/libc.so, > rather than the normal libc.so, because of use of obsolete RPC > interfaces. To support this, the rule in Makerules allows > $($(@F)-libc) to be used instead of the default > $(common-objpfx)libc.so. What bad things would happen if we just always used linkobj/libc.so for linking? > But a previous arrangement where > dependencies were generated for every library listed in $(services) > in nis/Makefile and nss/Makefile has been replaced by one where a > variable for each library is set separately (libnss_nis.so-libc, > libnss_nisplus.so-libc etc.) - is there a good way, without unduly > increasing complexity, to set such variables for everything in > $(services) without the repetition of the list of elements of > $(services)? I can't come up with a decent way to do that. But there are different things you could do instead. Instead of $(@F)-libc you could use a constant-named variable, let's say libc-for-link. Then you could get this to expand differently for those targets in one of two ways: Makerules: libc-for-link = $(common-objpfx)libc.so a) nis/Makefile: include ../Rules ... standard-libc-for-link := $(libc-for-link) libc-for-link = $(if $(filter $(services),$(@F)),$(libnss-libc),$(standard-libc-for-link)) b) nis/Makefile: # Target-specific variable setting: $(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) The latter seems nicer. We used to do more hacks like the former, but nowadays we require a version of make that supports target-specific variables anyway (and I think they may be used elsewhere in libc now). > diff --git a/Makerules b/Makerules > index d88bb62..c7a4720 100644 > --- a/Makerules > +++ b/Makerules > @@ -432,13 +432,29 @@ map-file = $(firstword $($(@F:.so=-map)) \ > load-map-file = $(map-file:%=-Wl,--version-script=%) > endif > > +# Compiler arguments to use to link a shared object with libc and > +# ld.so. This is intended to be as similar as possible to a default > +# link with an installed libc. > +link-libc-args = -Wl,--start-group \ > + $(if $($(@F)-libc),$($(@F)-libc),$(common-objpfx)libc.so) \ > + $(common-objpfx)libc_nonshared.a \ > + $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) \ > + -Wl,--end-group Given the stated intent, perhaps an approach more likely to ensure it's followed would be to generate a linker script with a rule sharing most of its logic with the $(inst_libdir)/libc.so rule. If that uses file names without leading slash and -L$(common-objdir) before it, then I think it will pick up the right builddir files. > build-module-helper-objlist = \ > $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\ > - $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^)) > + $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \ > + $(if $($(@F)-no-libc-filter),,\ > + $(link-libc-deps)),$^)) Probably better done with: $(common-objpfx)libc.so: link-libc-deps = # empty, with comment why You said just, "Tested." Does that mean you tested that all the object came out completely unchanged from before the patch? Thanks, Roland ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-17 20:24 ` Roland McGrath @ 2013-05-17 21:36 ` Joseph S. Myers 2013-05-17 21:42 ` Roland McGrath 2013-05-17 23:19 ` Joseph S. Myers 1 sibling, 1 reply; 11+ messages in thread From: Joseph S. Myers @ 2013-05-17 21:36 UTC (permalink / raw) To: Roland McGrath; +Cc: libc-alpha, libc-ports On Fri, 17 May 2013, Roland McGrath wrote: > elfobjdir and elf-objpfx are redundant. We should consolidate on just one > or the other. I don't think it matters which. For linking, using ld.so > makes sense. There is no need to use $(rtld-installed-name). I've added this consolidation to the wiki todo list. > > * Some libraries need to link with the internal linkobj/libc.so, > > rather than the normal libc.so, because of use of obsolete RPC > > interfaces. To support this, the rule in Makerules allows > > $($(@F)-libc) to be used instead of the default > > $(common-objpfx)libc.so. > > What bad things would happen if we just always used linkobj/libc.so for > linking? The elf/ directory builds sotruss-lib.so using $(build-module-asneeded), which uses $(link-libc-args) (which is desirable, on the principle of consistency of linking), but is (or may be) built before linkobj/libc.so is built. When I tried changing the dependencies of sotruss-lib.so to include $(link-libc-deps), I got a build failure because of this (since link-libc-deps always includes linkobj/libc.so, and elf/Makefile doesn't know how to build that file). Now, maybe sotruss-lib.so could be built in a different way that happens after linkobj/libc.so is built. But the principle of consistency with building with an installed compiler and libc suggests that linkobj/libc.so should only be used when necessary. > > +# Compiler arguments to use to link a shared object with libc and > > +# ld.so. This is intended to be as similar as possible to a default > > +# link with an installed libc. > > +link-libc-args = -Wl,--start-group \ > > + $(if $($(@F)-libc),$($(@F)-libc),$(common-objpfx)libc.so) \ > > + $(common-objpfx)libc_nonshared.a \ > > + $(as-needed) $(common-objpfx)elf/ld.so $(no-as-needed) \ > > + -Wl,--end-group > > Given the stated intent, perhaps an approach more likely to ensure it's > followed would be to generate a linker script with a rule sharing most of > its logic with the $(inst_libdir)/libc.so rule. If that uses file names > without leading slash and -L$(common-objdir) before it, then I think it > will pick up the right builddir files. I'd think such a linker script might as well include absolute paths; a helper script that generates the linker script, given arguments that are the directory names that should go in the linker script, might be a sensible way of sharing the logic. (Either the links libc.so$(libc.so-version) and $(rtld-installed-name) are then being used at build time to link against, or else the names within the directory also need to vary between the linker scripts.) > You said just, "Tested." Does that mean you tested that all the object > came out completely unchanged from before the patch? No, tested with normal testsuite runs. I don't expect everything to be unchanged, given that various objects were previously linked unconditionally with ld.so and after the patch have a --as-needed link with ld.so (so some may not end up with a dependency on ld.so after all). -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-17 21:36 ` Joseph S. Myers @ 2013-05-17 21:42 ` Roland McGrath 2013-05-17 22:56 ` Joseph S. Myers 0 siblings, 1 reply; 11+ messages in thread From: Roland McGrath @ 2013-05-17 21:42 UTC (permalink / raw) To: Joseph S. Myers; +Cc: libc-alpha, libc-ports > > elfobjdir and elf-objpfx are redundant. We should consolidate on just one > > or the other. I don't think it matters which. For linking, using ld.so > > makes sense. There is no need to use $(rtld-installed-name). > > I've added this consolidation to the wiki todo list. Good enough. > Now, maybe sotruss-lib.so could be built in a different way that happens > after linkobj/libc.so is built. But the principle of consistency with > building with an installed compiler and libc suggests that linkobj/libc.so > should only be used when necessary. Fair enough. > I'd think such a linker script might as well include absolute paths; a We take some pains in other places to avoid those. It means you can move your build directory around without breaking everything. > No, tested with normal testsuite runs. I don't expect everything to be > unchanged, given that various objects were previously linked > unconditionally with ld.so and after the patch have a --as-needed link > with ld.so (so some may not end up with a dependency on ld.so after all). I'd like to see at least verification that no actual code changed, and diffs of readelf -d output where it changed. Thanks, Roland ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-17 21:42 ` Roland McGrath @ 2013-05-17 22:56 ` Joseph S. Myers 2013-05-17 23:12 ` Roland McGrath 0 siblings, 1 reply; 11+ messages in thread From: Joseph S. Myers @ 2013-05-17 22:56 UTC (permalink / raw) To: Roland McGrath; +Cc: libc-alpha, libc-ports [-- Attachment #1: Type: text/plain, Size: 1217 bytes --] On Fri, 17 May 2013, Roland McGrath wrote: > > No, tested with normal testsuite runs. I don't expect everything to be > > unchanged, given that various objects were previously linked > > unconditionally with ld.so and after the patch have a --as-needed link > > with ld.so (so some may not end up with a dependency on ld.so after all). > > I'd like to see at least verification that no actual code changed, and > diffs of readelf -d output where it changed. With the revised patch I'm currently testing, for an x86_64 build, the .so files that change are libSegFault, libanl, libmemusage, libnss_db, libpcprofile and librt. For libanl, libmemusage and libnss_db, there are no code changes and the only changes in readelf -d output are a reordering of DT_NEEDED entries. For the others, an ld.so dependency disappears. This reduces the size of the dynamic section. Lots of offsets change in code, probably as a result of this, making comparisons hard. See attached diffs of readelf -d and objdump -d output. For an i386 build, in addition to the changes described above the DT_NEEDED entries for libm are also reordered (with, again, no code changes). -- Joseph S. Myers joseph@codesourcery.com [-- Attachment #2: Type: text/plain, Size: 8425 bytes --] lib64/libSegFault.so: --- /dev/fd/63 2013-05-17 22:47:46.418962180 +0000 +++ /dev/fd/62 2013-05-17 22:47:46.418962180 +0000 @@ -1,27 +1,26 @@ -Dynamic section at offset 0x3e00 contains 24 entries: +Dynamic section at offset 0x3e10 contains 23 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] - 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] 0x000000000000000e (SONAME) Library soname: [libSegFault.so] - 0x000000000000000c (INIT) 0xb58 - 0x000000000000000d (FINI) 0x31a8 - 0x0000000000000004 (HASH) 0x3550 + 0x000000000000000c (INIT) 0xb40 + 0x000000000000000d (FINI) 0x3198 + 0x0000000000000004 (HASH) 0x3540 0x000000006ffffef5 (GNU_HASH) 0x258 0x0000000000000005 (STRTAB) 0x5f8 0x0000000000000006 (SYMTAB) 0x2b0 - 0x000000000000000a (STRSZ) 478 (bytes) + 0x000000000000000a (STRSZ) 457 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0x204000 0x0000000000000002 (PLTRELSZ) 504 (bytes) 0x0000000000000014 (PLTREL) RELA - 0x0000000000000017 (JMPREL) 0x960 - 0x0000000000000007 (RELA) 0x870 + 0x0000000000000017 (JMPREL) 0x948 + 0x0000000000000007 (RELA) 0x858 0x0000000000000008 (RELASZ) 240 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000000000001e (FLAGS) STATIC_TLS - 0x000000006ffffffe (VERNEED) 0x820 + 0x000000006ffffffe (VERNEED) 0x808 0x000000006fffffff (VERNEEDNUM) 1 - 0x000000006ffffff0 (VERSYM) 0x7d6 + 0x000000006ffffff0 (VERSYM) 0x7c2 0x000000006ffffff9 (RELACOUNT) 2 0x0000000000000000 (NULL) 0x0 lib64/libanl-2.17.90.so: --- /dev/fd/63 2013-05-17 22:47:46.418962180 +0000 +++ /dev/fd/62 2013-05-17 22:47:46.418962180 +0000 @@ -1,8 +1,8 @@ Dynamic section at offset 0x2de0 contains 26 entries: Tag Type Name/Value - 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x000000000000000e (SONAME) Library soname: [libanl.so.1] 0x000000000000000c (INIT) 0xc88 0x000000000000000d (FINI) 0x1f80 lib64/libmemusage.so: --- /dev/fd/63 2013-05-17 22:47:46.418962180 +0000 +++ /dev/fd/62 2013-05-17 22:47:46.418962180 +0000 @@ -2,8 +2,8 @@ Dynamic section at offset 0x3de0 contains 25 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libdl.so.2] - 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] + 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] 0x000000000000000e (SONAME) Library soname: [libmemusage.so] 0x000000000000000c (INIT) 0xd70 0x000000000000000d (FINI) 0x2688 lib64/libnss_db-2.17.90.so: --- /dev/fd/63 2013-05-17 22:47:46.422961993 +0000 +++ /dev/fd/62 2013-05-17 22:47:46.422961993 +0000 @@ -1,8 +1,8 @@ Dynamic section at offset 0x6de0 contains 26 entries: Tag Type Name/Value - 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000001 (NEEDED) Shared library: [libnss_files.so.2] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x000000000000000e (SONAME) Library soname: [libnss_db.so.2] 0x000000000000000c (INIT) 0x1698 0x000000000000000d (FINI) 0x5058 lib64/libpcprofile.so: --- /dev/fd/63 2013-05-17 22:47:46.422961993 +0000 +++ /dev/fd/62 2013-05-17 22:47:46.422961993 +0000 @@ -1,27 +1,26 @@ -Dynamic section at offset 0xe10 contains 24 entries: +Dynamic section at offset 0xe20 contains 23 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] - 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] 0x000000000000000e (SONAME) Library soname: [libpcprofile.so] - 0x000000000000000c (INIT) 0x798 - 0x000000000000000d (FINI) 0xa98 - 0x0000000000000004 (HASH) 0xba0 + 0x000000000000000c (INIT) 0x788 + 0x000000000000000d (FINI) 0xa88 + 0x0000000000000004 (HASH) 0xb90 0x000000006ffffef5 (GNU_HASH) 0x258 0x0000000000000005 (STRTAB) 0x498 0x0000000000000006 (SYMTAB) 0x2b8 - 0x000000000000000a (STRSZ) 319 (bytes) + 0x000000000000000a (STRSZ) 298 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0x201000 0x0000000000000002 (PLTRELSZ) 144 (bytes) 0x0000000000000014 (PLTREL) RELA - 0x0000000000000017 (JMPREL) 0x708 - 0x0000000000000007 (RELA) 0x630 + 0x0000000000000017 (JMPREL) 0x6f8 + 0x0000000000000007 (RELA) 0x620 0x0000000000000008 (RELASZ) 216 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000000000001e (FLAGS) STATIC_TLS - 0x000000006ffffffe (VERNEED) 0x600 + 0x000000006ffffffe (VERNEED) 0x5f0 0x000000006fffffff (VERNEEDNUM) 1 - 0x000000006ffffff0 (VERSYM) 0x5d8 + 0x000000006ffffff0 (VERSYM) 0x5c2 0x000000006ffffff9 (RELACOUNT) 3 0x0000000000000000 (NULL) 0x0 lib64/librt-2.17.90.so: --- /dev/fd/63 2013-05-17 22:47:46.422961993 +0000 +++ /dev/fd/62 2013-05-17 22:47:46.422961993 +0000 @@ -1,31 +1,30 @@ -Dynamic section at offset 0x6d98 contains 28 entries: +Dynamic section at offset 0x6da8 contains 27 entries: Tag Type Name/Value - 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] - 0x0000000000000001 (NEEDED) Shared library: [ld-linux-x86-64.so.2] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] 0x000000000000000e (SONAME) Library soname: [librt.so.1] - 0x000000000000000c (INIT) 0x1f40 - 0x000000000000000d (FINI) 0x52e4 - 0x0000000000000004 (HASH) 0x6208 + 0x000000000000000c (INIT) 0x1f38 + 0x000000000000000d (FINI) 0x52d4 + 0x0000000000000004 (HASH) 0x61f8 0x000000006ffffef5 (GNU_HASH) 0x258 0x0000000000000005 (STRTAB) 0x1058 0x0000000000000006 (SYMTAB) 0x500 - 0x000000000000000a (STRSZ) 1442 (bytes) + 0x000000000000000a (STRSZ) 1421 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0x207000 0x0000000000000002 (PLTRELSZ) 1392 (bytes) 0x0000000000000014 (PLTREL) RELA - 0x0000000000000017 (JMPREL) 0x19d0 - 0x0000000000000007 (RELA) 0x1838 + 0x0000000000000017 (JMPREL) 0x19c8 + 0x0000000000000007 (RELA) 0x1830 0x0000000000000008 (RELASZ) 408 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) - 0x000000006ffffffc (VERDEF) 0x16f0 + 0x000000006ffffffc (VERDEF) 0x16d8 0x000000006ffffffd (VERDEFNUM) 6 0x000000000000001e (FLAGS) STATIC_TLS 0x000000006ffffffb (FLAGS_1) Flags: NODELETE - 0x000000006ffffffe (VERNEED) 0x17b8 + 0x000000006ffffffe (VERNEED) 0x17a0 0x000000006fffffff (VERNEEDNUM) 2 - 0x000000006ffffff0 (VERSYM) 0x15fa + 0x000000006ffffff0 (VERSYM) 0x15e6 0x000000006ffffff9 (RELACOUNT) 5 0x0000000000000000 (NULL) 0x0 [-- Attachment #3: Type: application/octet-stream, Size: 100512 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-17 22:56 ` Joseph S. Myers @ 2013-05-17 23:12 ` Roland McGrath 0 siblings, 0 replies; 11+ messages in thread From: Roland McGrath @ 2013-05-17 23:12 UTC (permalink / raw) To: Joseph S. Myers; +Cc: libc-alpha, libc-ports Thanks. Those differences are fine. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-17 20:24 ` Roland McGrath 2013-05-17 21:36 ` Joseph S. Myers @ 2013-05-17 23:19 ` Joseph S. Myers 2013-05-28 23:58 ` Roland McGrath 1 sibling, 1 reply; 11+ messages in thread From: Joseph S. Myers @ 2013-05-17 23:19 UTC (permalink / raw) To: Roland McGrath; +Cc: libc-alpha, libc-ports This revised patch uses $(elfobjdir)/ld.so (instead of $(common-objpfx)elf/ld.so) but does not consolidate existing references to various versions of the elf/ directory. It uses target-specific libc-for-link variables to link with linkobj/libc.so, and target-specific link-libc-deps set to empty (for both the main libc.so and linkobj/libc.so) to avoid filtering out ld.so from the libc.so links. It also has changes to iconvdata/extra-module.mk, similar to those to other makefiles, which I'd previously missed. It does not change link-libc-args to use a linker script; the variation of libc-for-link (sometimes using linkobj/libc.so) means that there would probably need to be two such linker scripts, rather than just one, for such an approach to work. Tested with the glibc testsuite for x86_64 and x86, and .so comparisons as previously described in <http://sourceware.org/ml/libc-alpha/2013-05/msg00703.html>. 2013-05-17 Joseph Myers <joseph@codesourcery.com> * Makefile ($(common-objpfx)linkobj/libc.so): Define link-libc-deps to empty as target-specific variable. * Makerules (link-libc-args): New variable. (libc-for-link): Likewise. (link-libc-deps): Likewise. (lib%.so): Depend in $(link-libc-deps). Link with $(link-libc-args). (build-module): Link with $(link-libc-args). (build-module-asneeded): Likewise. (build-module-helper-objlist): Filter out $(link-libc-deps) from list of objects. ($(common-objpfx)libc.so): Define link-libc-deps to empty as target-specific variable. ($(extra-modules-build:%=$(objpfx)%.so)): Depend on $(link-libc-deps) instead of libc.so and libc_nonshared.a. * crypt/Makefile ($(objpfx)libcrypt.so): Remove dependencies on libc. * debug/Makefile ($(objpfx)libSegFault.so): Remove dependencies on libc and ld.so. ($(objpfx)libpcprofile.so): Likewise. * dlfcn/Makefile (LDLIBS-bug-atexit3-lib.so): Remove ld.so and libc_nonshared.a. ($(objpfx)libdl.so): Remove dependencies on libc and ld.so. * hesiod/Makefile ($(objpfx)libnss_hesiod.so): Likewise. * iconvdata/extra-module.mk ($(objpfx)$(mod).so): Depend on $(link-libc-deps). ($(objpfx)$(mod).so): Remove dependencies on libc and ld.so. * locale/Makefile ($(objpfx)libBrokenLocale.so): Likewise. * login/Makefile ($(objpfx)libutil.so): Likewise. * malloc/Makefile ($(objpfx)libmemusage.so): Likewise. * math/Makefile ($(objpfx)libm.so): Likewise. * nis/Makefile ($(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so): Define libc-for-link as target-specific variable instead of depending directly on libc. * nss/Makefile ($(services:%=$(objpfx)libnss_%.so)): Likewise. ($(objpfx)/libnss_test1.so): Change dependencies on libc to $(link-libc-deps). * resolv/Makefile ($(objpfx)libresolv.so): Remove dependencies on libc. [$(have-ssp) = yes] (LDLIBS-resolv.so): Remove variable. ($(objpfx)libnss_dns.so): Remove dependencies on libc. ($(objpfx)libanl.so): Likewise. * rt/Makefile ($(objpfx)librt.so): Remove dependencies on libc and ld.so. * stdlib/Makefile ($(objpfx)tst-putenvmod.so): Depend on $(link-libc-deps). * sysdeps/i386/fpu/Makefile: Remove file. * sysdeps/powerpc/fpu/Makefile [$(subdir) = math] ($(objpfx)libm.so): Remove dependency on ld.so. libidn/ChangeLog: 2013-05-17 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libcidn.so): Remove dependencies on libc. nptl/ChangeLog: 2013-05-17 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libpthread.so): Remove dependencies on libc and ld.so. nptl_db/ChangeLog: 2013-05-17 Joseph Myers <joseph@codesourcery.com> * Makefile ($(objpfx)libthread_db.so): Remove dependencies on libc. ports/ChangeLog.arm: 2013-05-17 Joseph Myers <joseph@codesourcery.com> * sysdeps/arm/Makefile [$(subdir) = malloc] ($(objpfx)libmemusage.so): Remove dependency on libc_nonshared. [$(subdir) = math] ($(objpfx)libm.so): Remove dependency on ld.so. ports/ChangeLog.microblaze 2013-05-17 Joseph Myers <joseph@codesourcery.com> * sysdeps/microblaze/Makefile ($(objpfx)libm.so): Remove dependency on ld.so. ($(objpfx)libcrypt.so): Likewise. ($(objpfx)libresolv.so): Likewise. ($(objpfx)libnss_dns.so): Likewise. ($(objpfx)libnss_files.so): Likewise. ($(objpfx)libnss_db.so): Likewise. ($(objpfx)libnss_nis.so): Likewise. ($(objpfx)libnss_nisplus.so): Likewise. ($(objpfx)libnss_hesiod.so): Likewise. ($(objpfx)libnss_compat.so): Likewise. ($(objpfx)libanl.so): Likewise. ($(objpfx)libnsl.so): Likewise. ($(objpfx)libcidn.so): Likewise. ($(objpfx)libutil.so): Likewise. diff --git a/Makefile b/Makefile index c12e332..7d8eccf 100644 --- a/Makefile +++ b/Makefile @@ -127,6 +127,9 @@ lib: $(common-objpfx)libc.so lib: $(common-objpfx)linkobj/libc.so +# Do not filter ld.so out of libc.so link. +$(common-objpfx)linkobj/libc.so: link-libc-deps = # empty + $(common-objpfx)linkobj/libc.so: $(elfobjdir)/soinit.os \ $(common-objpfx)linkobj/libc_pic.a \ $(elfobjdir)/sofini.os \ diff --git a/Makerules b/Makerules index d88bb62..2c25233 100644 --- a/Makerules +++ b/Makerules @@ -432,13 +432,33 @@ map-file = $(firstword $($(@F:.so=-map)) \ load-map-file = $(map-file:%=-Wl,--version-script=%) endif +# Compiler arguments to use to link a shared object with libc and +# ld.so. This is intended to be as similar as possible to a default +# link with an installed libc. +link-libc-args = -Wl,--start-group \ + $(libc-for-link) \ + $(common-objpfx)libc_nonshared.a \ + $(as-needed) $(elfobjdir)/ld.so $(no-as-needed) \ + -Wl,--end-group + +# The corresponding shared libc to use. This may be modified for a +# particular target. +libc-for-link = $(common-objpfx)libc.so + +# The corresponding dependencies. As these are used in dependencies, +# not just commands, they cannot use target-specific variables so need +# to name both possible libc.so objects. +link-libc-deps = $(common-objpfx)libc.so $(common-objpfx)linkobj/libc.so \ + $(common-objpfx)libc_nonshared.a $(elfobjdir)/ld.so + # Pattern rule to build a shared object from an archive of PIC objects. # This must come after the installation rules so Make doesn't try to # build shared libraries in place from the installed *_pic.a files. # $(LDLIBS-%.so) may contain -l switches to generate run-time dependencies -# on other shared objects. -lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) - $(build-shlib) +# on other shared objects. The linking with libc and ld.so is intended +# to be as similar as possible to a default link with an installed libc. +lib%.so: lib%_pic.a $(+preinit) $(+postinit) $(+interp) $(link-libc-deps) + $(build-shlib) $(link-libc-args) define build-shlib-helper $(LINK.o) -shared $(static-libgcc) -Wl,-O1 $(sysdep-LDFLAGS) \ @@ -513,17 +533,19 @@ endef # not for shared objects define build-module $(build-module-helper) -o $@ $(shlib-lds-flags) \ - $(csu-objpfx)abi-note.o $(build-module-objlist) + $(csu-objpfx)abi-note.o $(build-module-objlist) $(link-libc-args) endef define build-module-asneeded $(build-module-helper) -o $@ $(shlib-lds-flags) \ $(csu-objpfx)abi-note.o \ - -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed + -Wl,--as-needed $(build-module-objlist) -Wl,--no-as-needed \ + $(link-libc-args) endef build-module-helper-objlist = \ $(patsubst %_pic.a,$(whole-archive) %_pic.a $(no-whole-archive),\ - $(filter-out %.lds $(map-file) $(+preinit) $(+postinit),$^)) + $(filter-out %.lds $(map-file) $(+preinit) $(+postinit) \ + $(link-libc-deps),$^)) build-module-objlist = $(build-module-helper-objlist) $(LDLIBS-$(@F:%.so=%).so) build-shlib-objlist = $(build-module-helper-objlist) \ @@ -566,6 +588,9 @@ generated += libc_pic.opts libc_pic.os.clean libc_pic_clean := .clean endif +# Do not filter ld.so out of libc.so link. +$(common-objpfx)libc.so: link-libc-deps = # empty + # Use our own special initializer and finalizer files for libc.so. $(common-objpfx)libc.so: $(elfobjdir)/soinit.os \ $(common-objpfx)libc_pic.os$(libc_pic_clean) \ @@ -621,8 +646,7 @@ include $(patsubst %,$(..)extra-modules.mk,$(modules-names)) extra-modules-build := $(filter-out $(modules-names-nobuild),$(modules-names)) $(extra-modules-build:%=$(objpfx)%.so): $(objpfx)%.so: \ - $(objpfx)%.os $(shlib-lds) \ - $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a + $(objpfx)%.os $(shlib-lds) $(link-libs-deps) $(build-module) endif \f diff --git a/crypt/Makefile b/crypt/Makefile index 0f5f099..238e527 100644 --- a/crypt/Makefile +++ b/crypt/Makefile @@ -69,8 +69,3 @@ $(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.so else $(addprefix $(objpfx),$(tests)): $(objpfx)libcrypt.a endif - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libcrypt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/debug/Makefile b/debug/Makefile index 9b5afb4..779741f 100644 --- a/debug/Makefile +++ b/debug/Makefile @@ -186,13 +186,3 @@ $(objpfx)xtrace: xtrace.sh -e 's|@PKGVERSION@|$(PKGVERSION)|' \ -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \ && rm -f $@ && mv $@.new $@ && chmod +x $@ - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libSegFault.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elf-objpfx)$(rtld-installed-name) -$(objpfx)libpcprofile.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elf-objpfx)$(rtld-installed-name) diff --git a/dlfcn/Makefile b/dlfcn/Makefile index cf4428c..c2ebdca 100644 --- a/dlfcn/Makefile +++ b/dlfcn/Makefile @@ -117,14 +117,6 @@ $(objpfx)bug-atexit1.out: $(objpfx)bug-atexit1-lib.so $(objpfx)bug-atexit2: $(libdl) $(objpfx)bug-atexit2.out: $(objpfx)bug-atexit2-lib.so -LDLIBS-bug-atexit3-lib.so = -lstdc++ -lgcc_eh $(elfobjdir)/ld.so \ - $(common-objpfx)libc_nonshared.a +LDLIBS-bug-atexit3-lib.so = -lstdc++ -lgcc_eh $(objpfx)bug-atexit3: $(libdl) $(objpfx)bug-atexit3.out: $(objpfx)bug-atexit3-lib.so - - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libdl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(elfobjdir)/ld.so diff --git a/hesiod/Makefile b/hesiod/Makefile index 95ec252..b7a13c2 100644 --- a/hesiod/Makefile +++ b/hesiod/Makefile @@ -33,12 +33,7 @@ libnss_hesiod-inhibit-o = $(filter-out .os,$(object-suffixes)) include ../Rules -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -# The Hesiod NSS modules also needs the resolver and some help from +# The Hesiod NSS module also needs the resolver and some help from # the file service. $(objpfx)libnss_hesiod.so: $(common-objpfx)resolv/libresolv.so \ - $(common-objpfx)nss/libnss_files.so \ - $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a + $(common-objpfx)nss/libnss_files.so diff --git a/iconvdata/extra-module.mk b/iconvdata/extra-module.mk index 43f4e12..ecaf507 100644 --- a/iconvdata/extra-module.mk +++ b/iconvdata/extra-module.mk @@ -4,16 +4,9 @@ extra-modules-left := $(strip $(filter-out $(mod),$(extra-modules-left))) extra-objs := $(extra-objs) $(patsubst %,%.os,$($(mod)-routines)) $(objpfx)$(mod).so: $(addprefix $(objpfx),$(addsuffix .os,$($(mod)-routines)))\ - $(shlib-lds) + $(shlib-lds) $(link-libc-deps) $(build-module-asneeded) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)$(mod).so: $(common-objpfx)libc.so \ - $(common-objpfx)/elf/ld.so \ - $(common-objpfx)libc_nonshared.a - ifneq (,$(extra-modules-left)) include extra-module.mk endif diff --git a/libidn/Makefile b/libidn/Makefile index 1c578c1..de26051 100644 --- a/libidn/Makefile +++ b/libidn/Makefile @@ -33,5 +33,3 @@ include $(..)Makeconfig libcidn-inhibit-o = $(filter-out .os,$(object-suffixes)) include $(..)Rules - -$(objpfx)libcidn.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/locale/Makefile b/locale/Makefile index 8bab9a0..8ccc603 100644 --- a/locale/Makefile +++ b/locale/Makefile @@ -98,9 +98,3 @@ cpp-srcs-left := $(addsuffix .c,$(localedef-modules) $(localedef-aux) \ $(locale-modules) $(lib-modules)) lib := locale-programs include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libBrokenLocale.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a diff --git a/login/Makefile b/login/Makefile index 61c9d7e..0bfe643 100644 --- a/login/Makefile +++ b/login/Makefile @@ -68,8 +68,3 @@ endif $(inst_libexecdir)/pt_chown: $(objpfx)pt_chown $(+force) $(make-target-directory) -$(INSTALL_PROGRAM) -m 4755 -o root $< $@ - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libutil.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/malloc/Makefile b/malloc/Makefile index 05f9b15..0fe31a4 100644 --- a/malloc/Makefile +++ b/malloc/Makefile @@ -141,7 +141,7 @@ $(objpfx)memusage: memusage.sh # The implementation uses `dlsym' -$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so $(elfobjdir)/ld.so +$(objpfx)libmemusage.so: $(common-objpfx)dlfcn/libdl.so # Extra dependencies $(foreach o,$(all-object-suffixes),$(objpfx)malloc$(o)): arena.c hooks.c diff --git a/math/Makefile b/math/Makefile index 5bbf9d3..3ed78fc 100644 --- a/math/Makefile +++ b/math/Makefile @@ -229,8 +229,3 @@ gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\ $(objpfx)atest-exp: $(gmp-objs) $(objpfx)atest-sincos: $(gmp-objs) $(objpfx)atest-exp2: $(gmp-objs) - -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libm.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a diff --git a/nis/Makefile b/nis/Makefile index 0b3b6a2..b9b434c 100644 --- a/nis/Makefile +++ b/nis/Makefile @@ -76,12 +76,10 @@ $(objpfx)libnss_nis.so: $(objpfx)libnsl.so$(libnsl.so-version) \ $(common-objpfx)nss/libnss_files.so $(objpfx)libnss_nisplus.so: $(objpfx)libnsl.so$(libnsl.so-version) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. libnsl-libc = $(common-objpfx)linkobj/libc.so -$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: $(libnsl-libc) \ - $(common-objpfx)libc_nonshared.a +# Target-specific variable setting: +$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: \ + libc-for-link = $(libnsl-libc) ifeq ($(build-shared),yes) diff --git a/nptl/Makefile b/nptl/Makefile index 6af4b37..7fa991b 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -507,14 +507,6 @@ $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs)) $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs)) $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs)) -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -# Depend on ld.so too to get proper versions of ld.so symbols. -$(objpfx)libpthread.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a \ - $(elfobjdir)/ld.so - # Make sure we link with the thread library. ifeq ($(build-shared),yes) $(addprefix $(objpfx), \ diff --git a/nptl_db/Makefile b/nptl_db/Makefile index 533fbae..77ea46e 100644 --- a/nptl_db/Makefile +++ b/nptl_db/Makefile @@ -51,12 +51,6 @@ libthread_db.so-no-z-defs = yes include ../Rules -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libthread_db.so: $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a - tests: $(objpfx)db-symbols.out $(objpfx)db-symbols.out: $(objpfx)db-symbols.v.i \ $(common-objpfx)nptl/libpthread.so diff --git a/nss/Makefile b/nss/Makefile index 449a258..305b63f 100644 --- a/nss/Makefile +++ b/nss/Makefile @@ -84,12 +84,9 @@ ifeq (yes,$(have-selinux)) LDLIBS-makedb := -lselinux endif -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. libnss-libc = $(common-objpfx)linkobj/libc.so -$(services:%=$(objpfx)libnss_%.so): $(libnss-libc) \ - $(common-objpfx)libc_nonshared.a +# Target-specific variable setting: +$(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) $(objpfx)libnss_db.so: $(objpfx)libnss_files.so @@ -107,8 +104,7 @@ $(inst_vardbdir)/Makefile: db-Makefile $(+force) $(do-install) CFLAGS-nss_test1.c = -DNOT_IN_libc=1 -$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a +$(objpfx)/libnss_test1.so: $(objpfx)nss_test1.os $(link-libc-deps) $(build-module) ifdef libnss_test1.so-version $(objpfx)/libnss_test1.so$(libnss_test1.so-version): $(objpfx)/libnss_test1.so diff --git a/ports/sysdeps/arm/Makefile b/ports/sysdeps/arm/Makefile index 3bdb6b3..b218e76 100644 --- a/ports/sysdeps/arm/Makefile +++ b/ports/sysdeps/arm/Makefile @@ -25,11 +25,6 @@ sysdep_routines += $(aeabi_constants) $(aeabi_routines) static-only-routines += $(aeabi_constants) endif -# to pull in __aeabi_read_tp, needed for tls -ifeq ($(subdir),malloc) -$(objpfx)libmemusage.so: $(common-objpfx)libc_nonshared.a -endif - ifeq ($(subdir),gmon) sysdep_routines += arm-mcount endif @@ -37,7 +32,3 @@ endif ifeq ($(subdir),debug) CFLAGS-backtrace.c += -funwind-tables endif - -ifeq ($(subdir),math) -$(objpfx)libm.so: $(elfobjdir)/ld.so -endif diff --git a/ports/sysdeps/microblaze/Makefile b/ports/sysdeps/microblaze/Makefile index cc82a74..f7c95ae 100644 --- a/ports/sysdeps/microblaze/Makefile +++ b/ports/sysdeps/microblaze/Makefile @@ -9,18 +9,3 @@ endif ifeq ($(subdir),resource) sysdep_routines += backtrace_linux endif - -$(objpfx)libm.so: $(elfobjdir)/ld.so -$(objpfx)libcrypt.so: $(elfobjdir)/ld.so -$(objpfx)libresolv.so: $(elfobjdir)/ld.so -$(objpfx)libnss_dns.so: $(elfobjdir)/ld.so -$(objpfx)libnss_files.so: $(elfobjdir)/ld.so -$(objpfx)libnss_db.so: $(elfobjdir)/ld.so -$(objpfx)libnss_nis.so: $(elfobjdir)/ld.so -$(objpfx)libnss_nisplus.so: $(elfobjdir)/ld.so -$(objpfx)libnss_hesiod.so: $(elfobjdir)/ld.so -$(objpfx)libnss_compat.so: $(elfobjdir)/ld.so -$(objpfx)libanl.so: $(elfobjdir)/ld.so -$(objpfx)libnsl.so: $(elfobjdir)/ld.so -$(objpfx)libcidn.so: $(elfobjdir)/ld.so -$(objpfx)libutil.so: $(elfobjdir)/ld.so diff --git a/resolv/Makefile b/resolv/Makefile index d3635bc..51dcf21 100644 --- a/resolv/Makefile +++ b/resolv/Makefile @@ -83,23 +83,11 @@ CFLAGS-res_hconf.c = -fexceptions # The BIND code elicits some harmless warnings. +cflags += -Wno-strict-prototypes -Wno-write-strings -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)libresolv.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a -# Some hosts need '__stack_chk_guard', so pull in the definition from -# ld.so if required. -ifeq (yes,$(have-ssp)) -LDLIBS-resolv.so += $(as-needed) $(elfobjdir)/ld.so $(no-as-needed) -endif - # The DNS NSS modules needs the resolver. -$(objpfx)libnss_dns.so: $(objpfx)libresolv.so $(common-objpfx)libc.so \ - $(common-objpfx)libc_nonshared.a +$(objpfx)libnss_dns.so: $(objpfx)libresolv.so # The asynchronous name lookup code needs the thread library. -$(objpfx)libanl.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(shared-thread-library) +$(objpfx)libanl.so: $(shared-thread-library) $(objpfx)ga_test: $(objpfx)libanl.so $(shared-thread-library) diff --git a/rt/Makefile b/rt/Makefile index ef356d0..b1392f2 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -64,12 +64,7 @@ CFLAGS-librt-cancellation.c = -fasynchronous-unwind-tables LDFLAGS-rt.so = -Wl,--enable-new-dtags,-z,nodelete -# Depend on libc.so so a DT_NEEDED is generated in the shared objects. -# This ensures they will load libc.so for needed symbols if loaded by -# a statically-linked program that hasn't already loaded it. -$(objpfx)librt.so: $(common-objpfx)libc.so $(common-objpfx)libc_nonshared.a \ - $(shared-thread-library) \ - $(elfobjdir)/ld.so +$(objpfx)librt.so: $(shared-thread-library) ifeq (yes,$(build-shared)) $(addprefix $(objpfx),$(tests)): $(objpfx)librt.so $(shared-thread-library) diff --git a/stdlib/Makefile b/stdlib/Makefile index 27765d1..17d80e0 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -144,7 +144,7 @@ $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so LDFLAGS-tst-putenv = $(no-as-needed) -$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os +$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os $(link-libc-deps) $(build-module) CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1 diff --git a/sysdeps/i386/fpu/Makefile b/sysdeps/i386/fpu/Makefile deleted file mode 100644 index 1309b64..0000000 --- a/sysdeps/i386/fpu/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ifeq ($(subdir),math) -$(objpfx)libm.so: $(elfobjdir)/ld.so -endif diff --git a/sysdeps/powerpc/fpu/Makefile b/sysdeps/powerpc/fpu/Makefile index fda59f9..53470a9 100644 --- a/sysdeps/powerpc/fpu/Makefile +++ b/sysdeps/powerpc/fpu/Makefile @@ -1,8 +1,5 @@ ifeq ($(subdir),math) libm-support += fenv_const fe_nomask fe_mask t_sqrt - -# libm needs ld.so to access dl_hwcap -$(objpfx)libm.so: $(elfobjdir)/ld.so endif ifeq ($(subdir),stdlib) -- Joseph S. Myers joseph@codesourcery.com ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Link extra-libs consistently with libc and ld.so 2013-05-17 23:19 ` Joseph S. Myers @ 2013-05-28 23:58 ` Roland McGrath 0 siblings, 0 replies; 11+ messages in thread From: Roland McGrath @ 2013-05-28 23:58 UTC (permalink / raw) To: Joseph S. Myers; +Cc: libc-alpha, libc-ports > 2013-05-17 Joseph Myers <joseph@codesourcery.com> > > * Makefile ($(common-objpfx)linkobj/libc.so): Define > link-libc-deps to empty as target-specific variable. > * Makerules (link-libc-args): New variable. > (libc-for-link): Likewise. > (link-libc-deps): Likewise. > (lib%.so): Depend in $(link-libc-deps). Link with > $(link-libc-args). s/in/on/ > +# Target-specific variable setting: > +$(services:%=$(objpfx)libnss_%.so) $(objpfx)libnsl.so: \ > + libc-for-link = $(libnsl-libc) Use two-space indentation for this case. Otherwise it looks too similar to a target with commands. The comment should say why it's there, not just what it is. (The commentary was inadequate before, but this is a good time to improve it.) > +# Target-specific variable setting: > +$(services:%=$(objpfx)libnss_%.so): libc-for-link = $(libnss-libc) Likewise with this comment. Aside from those tiny cosmetic issues, this looks fine to me. Thanks, Roland ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-05-28 23:58 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-05-09 0:22 Link extra-libs consistently with libc and ld.so Joseph S. Myers 2013-05-10 0:01 ` David Holsgrove 2013-05-14 0:32 ` Joseph S. Myers 2013-05-14 1:12 ` Roland McGrath 2013-05-17 20:24 ` Roland McGrath 2013-05-17 21:36 ` Joseph S. Myers 2013-05-17 21:42 ` Roland McGrath 2013-05-17 22:56 ` Joseph S. Myers 2013-05-17 23:12 ` Roland McGrath 2013-05-17 23:19 ` Joseph S. Myers 2013-05-28 23:58 ` Roland McGrath
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).