From a7c17431b9fbf767235d614cfe2e4f22ee0d6771 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Sun, 29 Jul 2012 12:44:53 -0400 Subject: [PATCH] Link shared libraries with local libraries instead of system ones ELF_OTHER_LIBS usually contains local search dirs (-L ../..), but it was added in link command after system search dirs from LDFLAGS. Libraries and executables were linked with the system libraries if present, and possibly using static archives instead of shared libraries. It could also make final executable link to fail when shared libraries are enabled: if libext2fs.so is linked with a static libcom_err.a from system, build system would attempt to link without -lpthread. This fixes the issue by moving ELF_OTHER_LIBS before LDFLAGS in the link command. Addresses-Sourceforge-Bug: #3542572 Reported-by: Olivier Blin Signed-off-by: Theodore Ts'o --- lib/Makefile.elf-lib | 4 ++-- lib/Makefile.solaris-lib | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Makefile.elf-lib b/lib/Makefile.elf-lib index c24636c..c66281c 100644 --- a/lib/Makefile.elf-lib +++ b/lib/Makefile.elf-lib @@ -24,8 +24,8 @@ image: $(ELF_LIB) $(ELF_LIB): $(OBJS) $(E) " GEN_ELF_SOLIB $(ELF_LIB)" - $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \ - -Wl,-soname,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) + $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(ELF_OTHER_LIBS) \ + $(LDFLAGS) -Wl,-soname,$(ELF_SONAME) $(OBJS)) $(Q) $(MV) elfshared/$(ELF_LIB) . $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \ diff --git a/lib/Makefile.solaris-lib b/lib/Makefile.solaris-lib index 92bdbe2..66f2b4c 100644 --- a/lib/Makefile.solaris-lib +++ b/lib/Makefile.solaris-lib @@ -24,8 +24,8 @@ image: $(ELF_LIB) $(ELF_LIB): $(OBJS) $(E) " GEN_ELF_SOLIB $(ELF_LIB)" - $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(LDFLAGS) \ - -Wl,-h,$(ELF_SONAME) $(OBJS) $(ELF_OTHER_LIBS)) + $(Q) (cd elfshared; $(CC) --shared -o $(ELF_LIB) $(ELF_OTHER_LIBS) \ + $(LDFLAGS) -Wl,-h,$(ELF_SONAME) $(OBJS)) $(Q) $(MV) elfshared/$(ELF_LIB) . $(Q) $(RM) -f ../$(ELF_LIB) ../$(ELF_IMAGE).so ../$(ELF_SONAME) $(Q) (cd ..; $(LN) $(LINK_BUILD_FLAGS) \ -- 1.8.3.1