Whamcloud - gitweb
Link shared libraries with local libraries instead of system ones
authorOlivier Blin <olivier.blin@softathome.com>
Sun, 29 Jul 2012 16:44:53 +0000 (12:44 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 29 Jul 2012 16:45:47 +0000 (12:45 -0400)
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 <blino@users.sourceforge.net>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/Makefile.elf-lib
lib/Makefile.solaris-lib

index c24636c..c66281c 100644 (file)
@@ -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) \
index 92bdbe2..66f2b4c 100644 (file)
@@ -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) \