Generate libraries with correct DT_NEEDED entries

Libraries that depend on other libraries should list them in ELF's
DT_NEEDED field so that programs linking to them do not need to specify
those libraries unless they depend on them as well. This is not the case
in the current code and the consequence is that anything that needs a
library must know its dependencies. This is fragile and caused GRUB2's
configure script to break when a dependency was added on libblkid in
libzfs.

This resolves that problem by using LIBADD/LDADD to specify libraries in
Makefile.am instead of LDFLAGS. This ensures that proper DT_NEEDED
entries are generated and prevents GRUB2's configure script from
breaking in the presence of a libblkid dependency. This also removes
unneeded dependencies from various files.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #1751
This commit is contained in:
Richard Yao 2013-09-26 13:42:41 -04:00 committed by Brian Behlendorf
parent 1db7b9be75
commit 31fc19399e
13 changed files with 15 additions and 15 deletions

View File

@ -20,5 +20,4 @@ mount_zfs_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
mount_zfs_LDFLAGS = \
-pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID) $(LIBSELINUX)
mount_zfs_LDADD += $(LIBSELINUX)

View File

@ -16,4 +16,4 @@ zdb_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
zdb_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)
zdb_LDADD += $(ZLIB)

View File

@ -19,4 +19,5 @@ zfs_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la
zfs_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)
zfs_LDADD += $(ZLIB)
zfs_LDFLAGS = -pthread

View File

@ -15,4 +15,4 @@ zhack_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
zhack_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)
zhack_LDADD += $(ZLIB)

View File

@ -16,5 +16,3 @@ zinject_LDADD = \
$(top_builddir)/lib/libuutil/libuutil.la \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
zinject_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)

View File

@ -18,5 +18,3 @@ zpool_LDADD = \
$(top_builddir)/lib/libuutil/libuutil.la \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
zpool_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)

View File

@ -15,4 +15,4 @@ zstreamdump_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
zstreamdump_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)
zstreamdump_LDADD += $(ZLIB)

View File

@ -17,4 +17,4 @@ ztest_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs/libzfs.la
ztest_LDFLAGS = -pthread -lm $(ZLIB) -lrt -ldl $(LIBUUID) $(LIBBLKID)
ztest_LDADD += -lm -ldl

View File

@ -10,3 +10,5 @@ noinst_LTLIBRARIES = libefi.la
libefi_la_SOURCES = \
$(top_srcdir)/lib/libefi/rdwr_efi.c
libefi_la_LIBADD = $(LIBUUID) $(ZLIB)

View File

@ -30,4 +30,4 @@ libspl_la_SOURCES = \
$(top_srcdir)/lib/libspl/include/sys/list.h \
$(top_srcdir)/lib/libspl/include/sys/list_impl.h
libspl_la_LDFLAGS = -lrt
libspl_la_LIBADD = -lrt

View File

@ -27,4 +27,5 @@ libzfs_la_LIBADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libzpool/libzpool.la
libzfs_la_LDFLAGS = -lm -ldl -version-info 1:1:0 $(LIBSELINUX)
libzfs_la_LIBADD += -lm -ldl $(LIBBLKID)
libzfs_la_LDFLAGS = -version-info 1:1:0

View File

@ -12,4 +12,4 @@ libzfs_core_la_SOURCES = \
libzfs_core_la_LIBADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la
libzfs_core_la_LDFLAGS = -pthread -version-info 1:1:0
libzfs_core_la_LDFLAGS = -version-info 1:1:0

View File

@ -99,7 +99,8 @@ libzpool_la_LIBADD = \
$(top_builddir)/lib/libuutil/libuutil.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
libzpool_la_LDFLAGS = -pthread -version-info 1:1:0
libzpool_la_LIBADD += $(ZLIB)
libzpool_la_LDFLAGS = -version-info 1:1:0
EXTRA_DIST = \
$(top_srcdir)/module/zfs/vdev_disk.c \