From 1619127c11a5ab5d499d4b8a9b76af74f3132400 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Mon, 25 Jan 2016 19:57:38 -0500 Subject: use same object files for libc.a and libc.so if compiler produces PIC now that .lo and .o files differ only by whether -fPIC is passed (and no longer at the source level based on the SHARED macro), it's possible to use the same object files for both static and shared libc when the compiler would produce PIC for the static files anyway. this happens if the user has included -fPIC in their CFLAGS or if the compiler has been configured to produce PIE by default. we use the .lo files for both, and still append -fPIC to the CFLAGS, rather than using the .o files so that libc.so does not break catastrophically if the user later removes -fPIC from CFLAGS in config.mak or on the make command line. this also ensures that we get full -fPIC in case -fpic, -fPIE, or some other lesser-PIC option was passed in CFLAGS. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 7c2cd77b..82ea024e 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ REPLACED_OBJS = $(sort $(subst /$(ARCH)/,/,$(ARCH_OBJS))) LDSO_SRCS = $(sort $(wildcard $(srcdir)/ldso/*.c)) LDSO_OBJS = $(patsubst $(srcdir)/%,obj/%.lo,$(basename $(LDSO_SRCS))) OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS)))) +AOBJS = $(OBJS) LOBJS = $(OBJS:.o=.lo) GENH = obj/include/bits/alltypes.h GENH_INT = obj/src/internal/version.h @@ -158,9 +159,9 @@ lib/libc.so: $(LOBJS) $(LDSO_OBJS) -Wl,-e,_dlstart -Wl,-Bsymbolic-functions \ -o $@ $(LOBJS) $(LDSO_OBJS) $(LIBCC) -lib/libc.a: $(OBJS) +lib/libc.a: $(AOBJS) rm -f $@ - $(AR) rc $@ $(OBJS) + $(AR) rc $@ $(AOBJS) $(RANLIB) $@ $(EMPTY_LIBS): -- cgit 1.4.1