Skip to content

Commit

Permalink
Generate libraries with correct DT_NEEDED entries
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ryao authored and behlendorf committed Oct 10, 2013
1 parent 1db7b9b commit 31fc193
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
3 changes: 1 addition & 2 deletions cmd/mount_zfs/Makefile.am
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion cmd/zdb/Makefile.am
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion cmd/zfs/Makefile.am
Expand Up @@ -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
2 changes: 1 addition & 1 deletion cmd/zhack/Makefile.am
Expand Up @@ -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)
2 changes: 0 additions & 2 deletions cmd/zinject/Makefile.am
Expand Up @@ -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)
2 changes: 0 additions & 2 deletions cmd/zpool/Makefile.am
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion cmd/zstreamdump/Makefile.am
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion cmd/ztest/Makefile.am
Expand Up @@ -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
2 changes: 2 additions & 0 deletions lib/libefi/Makefile.am
Expand Up @@ -10,3 +10,5 @@ noinst_LTLIBRARIES = libefi.la

libefi_la_SOURCES = \
$(top_srcdir)/lib/libefi/rdwr_efi.c

libefi_la_LIBADD = $(LIBUUID) $(ZLIB)
2 changes: 1 addition & 1 deletion lib/libspl/Makefile.am
Expand Up @@ -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
3 changes: 2 additions & 1 deletion lib/libzfs/Makefile.am
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/libzfs_core/Makefile.am
Expand Up @@ -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
3 changes: 2 additions & 1 deletion lib/libzpool/Makefile.am
Expand Up @@ -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 \
Expand Down

0 comments on commit 31fc193

Please sign in to comment.