Use abs_top_builddir when referencing libraries

libtool stores absolute paths in the dependency_libs component of the
.la files. If the Makefile for a dependent library refers to the
libraries by relative path, some libraries end up duplicated on the link
command line.

As an example, libzfs specifies libzfs_core, libnvpair and libuutil as
dependencies to be linked in. The .la file for libzfs_core also
specifies libnvpair, but using an absolute path, with the result that
libnvpair is present twice in the linker command line for producing
libzfs.

While the only thing this causes is to slightly slow down the linking,
we can avoid it by using absolute paths everywhere, including for
convenience libraries just for consistency.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Closes #10538
This commit is contained in:
Arvind Sankar 2020-07-06 16:01:29 -04:00 committed by Brian Behlendorf
parent af65916226
commit 3e597dee11
24 changed files with 64 additions and 64 deletions

View File

@ -13,8 +13,8 @@ mount_zfs_SOURCES = \
mount_zfs.c
mount_zfs_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la
mount_zfs_LDADD += $(LTLIBINTL)

View File

@ -14,7 +14,7 @@ raidz_test_SOURCES = \
raidz_bench.c
raidz_test_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la
$(abs_top_builddir)/lib/libzpool/libzpool.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la
raidz_test_LDADD += -lm

View File

@ -11,6 +11,6 @@ zdb_SOURCES = \
zdb.h
zdb_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzpool/libzpool.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la

View File

@ -38,10 +38,10 @@ FMA_SRC = \
zed_SOURCES = $(ZED_SRC) $(FMA_SRC)
zed_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la
zed_LDADD += -lrt $(LIBUDEV_LIBS) $(LIBUUID_LIBS)
zed_LDFLAGS = -pthread

View File

@ -11,10 +11,10 @@ zfs_SOURCES = \
zfs_projectutil.h
zfs_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la
zfs_LDADD += $(LTLIBINTL)

View File

@ -6,4 +6,4 @@ zfs_ids_to_path_SOURCES = \
zfs_ids_to_path.c
zfs_ids_to_path_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la
$(abs_top_builddir)/lib/libzfs/libzfs.la

View File

@ -6,6 +6,6 @@ zhack_SOURCES = \
zhack.c
zhack_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzpool/libzpool.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la

View File

@ -8,6 +8,6 @@ zinject_SOURCES = \
zinject.h
zinject_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la

View File

@ -22,10 +22,10 @@ zpool_SOURCES += os/linux/zpool_vdev_os.c
endif
zpool_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la
zpool_LDADD += $(LTLIBINTL)

View File

@ -9,6 +9,6 @@ zstream_SOURCES = \
zstream_redup.c
zstream_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la

View File

@ -15,9 +15,9 @@ ztest_SOURCES = \
ztest.c
ztest_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzpool/libzpool.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la
ztest_LDADD += -lm
ztest_LDFLAGS = -pthread

View File

@ -7,10 +7,10 @@ pammodule_LTLIBRARIES=pam_zfs_key.la
pam_zfs_key_la_SOURCES = pam_zfs_key.c
pam_zfs_key_la_LIBADD = \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la \
$(top_builddir)/lib/libzfs/libzfs.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la \
$(abs_top_builddir)/lib/libzfs/libzfs.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la
pam_zfs_key_la_LDFLAGS = -version-info 1:0:0 -avoid-version -module -shared

View File

@ -27,7 +27,7 @@ nodist_libnvpair_la_SOURCES = \
$(KERNEL_C)
libnvpair_la_LIBADD = \
$(top_builddir)/lib/libspl/libspl_assert.la
$(abs_top_builddir)/lib/libspl/libspl_assert.la
libnvpair_la_LIBADD += $(LIBTIRPC_LIBS) $(LTLIBINTL)

View File

@ -16,8 +16,8 @@ USER_C = \
libuutil_la_SOURCES = $(USER_C)
libuutil_la_LIBADD = \
$(top_builddir)/lib/libavl/libavl.la \
$(top_builddir)/lib/libspl/libspl.la
$(abs_top_builddir)/lib/libavl/libavl.la \
$(abs_top_builddir)/lib/libspl/libspl.la
libuutil_la_LIBADD += $(LTLIBINTL)

View File

@ -73,13 +73,13 @@ libzfs_la_LIBADD =
if BUILD_LINUX
libzfs_la_LIBADD += \
$(top_builddir)/lib/libshare/libshare.la
$(abs_top_builddir)/lib/libshare/libshare.la
endif
libzfs_la_LIBADD += \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la \
$(top_builddir)/lib/libuutil/libuutil.la
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la \
$(abs_top_builddir)/lib/libuutil/libuutil.la
libzfs_la_LIBADD += -lm $(LIBCRYPTO_LIBS) $(ZLIB_LIBS) $(LTLIBINTL)

View File

@ -10,8 +10,8 @@ USER_C = \
libzfs_core_la_SOURCES = $(USER_C)
libzfs_core_la_LIBADD = \
$(top_builddir)/lib/libzutil/libzutil.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzutil/libzutil.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la
libzfs_core_la_LIBADD += $(LTLIBINTL)

View File

@ -200,10 +200,10 @@ nodist_libzpool_la_SOURCES = \
$(LUA_C)
libzpool_la_LIBADD = \
$(top_builddir)/lib/libicp/libicp.la \
$(top_builddir)/lib/libunicode/libunicode.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libunicode/libunicode.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la
libzpool_la_LIBADD += $(LIBCLOCK_GETTIME) $(ZLIB_LIBS) -ldl

View File

@ -32,13 +32,13 @@ endif
libzutil_la_SOURCES = $(USER_C)
libzutil_la_LIBADD = \
$(top_builddir)/lib/libavl/libavl.la \
$(top_builddir)/lib/libtpool/libtpool.la \
$(top_builddir)/lib/libspl/libspl.la
$(abs_top_builddir)/lib/libavl/libavl.la \
$(abs_top_builddir)/lib/libtpool/libtpool.la \
$(abs_top_builddir)/lib/libspl/libspl.la
if BUILD_LINUX
libzutil_la_LIBADD += \
$(top_builddir)/lib/libefi/libefi.la
$(abs_top_builddir)/lib/libefi/libefi.la
endif
libzutil_la_LIBADD += -lm $(LIBBLKID_LIBS) $(LIBUDEV_LIBS)

View File

@ -28,5 +28,5 @@ pkgexec_PROGRAMS = btree_test
btree_test_SOURCES = btree_test.c
btree_test_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la \
$(top_builddir)/lib/libzfs_core/libzfs_core.la
$(abs_top_builddir)/lib/libzpool/libzpool.la \
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la

View File

@ -6,5 +6,5 @@ pkgexec_PROGRAMS = libzfs_input_check
libzfs_input_check_SOURCES = libzfs_input_check.c
libzfs_input_check_LDADD = \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la

View File

@ -6,5 +6,5 @@ pkgexec_PROGRAMS = nvlist_to_lua
nvlist_to_lua_SOURCES = nvlist_to_lua.c
nvlist_to_lua_LDADD = \
$(top_builddir)/lib/libzfs_core/libzfs_core.la \
$(top_builddir)/lib/libnvpair/libnvpair.la
$(abs_top_builddir)/lib/libzfs_core/libzfs_core.la \
$(abs_top_builddir)/lib/libnvpair/libnvpair.la

View File

@ -1,8 +1,8 @@
include $(top_srcdir)/config/Rules.am
LDADD = \
$(top_builddir)/lib/libicp/libicp.la \
$(top_builddir)/lib/libspl/libspl_assert.la
$(abs_top_builddir)/lib/libicp/libicp.la \
$(abs_top_builddir)/lib/libspl/libspl_assert.la
pkgdatadir = $(datadir)/@PACKAGE@/zfs-tests/tests/functional/checksum

View File

@ -14,4 +14,4 @@ pkgexec_PROGRAMS = \
hkdf_test_SOURCES = hkdf_test.c
hkdf_test_LDADD = \
$(top_builddir)/lib/libzpool/libzpool.la
$(abs_top_builddir)/lib/libzpool/libzpool.la

View File

@ -10,7 +10,7 @@ dist_pkgdata_SCRIPTS = \
libzfs_input.ksh
many_fds_LDADD = \
$(top_builddir)/lib/libzfs/libzfs.la
$(abs_top_builddir)/lib/libzfs/libzfs.la
pkgexec_PROGRAMS = many_fds
many_fds_SOURCES = many_fds.c