e853ba3519
I noticed during code review of zfsonlinux/zfs#4385 that the author of a commit had peppered the various Makefile.am files with `$(TIRPC_LIBS)` when putting it into `lib/libspl/Makefile.am` should have sufficed. Upon further examination, it seems that he had copied what we do with `$(ZLIB)`. We also have a bit of that with `-ldl` too. Unfortunately, what we do is wrong, so lets fix it to set a good example for future contributors. In addition, we have multiple `-lz` and `-luuid` passed to the compiler because each `AC_CHECK_LIB` adds it to `$LIBS`. That is somewhat annoying to see, so we switch to `AC_SEARCH_LIBS` to avoid it. This is consistent with the recommendation to use `AC_SEARCH_LIBS` over `AC_CHECK_LIB` by autotools upstream: https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Libraries.html In an ideal world, this would translate into improvements in ELF's `DT_NEEDED` entries, but that is not the case because of a couple of bugs in libtool. The first bug causes libtool to overlink by using static link dependencies for dynamic linking: https://wiki.mageia.org/en/Overlinking_issues_in_packaging#libtool_issues The workaround for this should be to pass `-Wl,--as-needed` in `LDFLAGS`. That leads us to the second bug, where libtool passes `LDFLAGS` after the libraries are specified and `ld` will only honor `--as-needed` on libraries specified before it: https://sigquit.wordpress.com/2011/02/16/why-asneeded-doesnt-work-as-expected-for-your-libraries-on-your-autotools-project/ There are a few possible workarounds for the second bug. One is to either patch the compiler spec file to specify `-Wl,--as-needed` or pass `-Wl,--as-needed` via `CC` like `CC='gcc -Wl,--as-needed'` so that it is specified early. Another is to patch ltmain.sh like Gentoo does: https://gitweb.gentoo.org/repo/gentoo.git/tree/eclass/ELT-patches/as-needed Without one of those workarounds, this cleanup provides no benefit in terms of `DT_NEEDED` entry generation. It should still be an improvement because it nicely simplifies the code while encouraging good habits when patching autotools scripts. Signed-off-by: Richard Yao <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #4426 |
||
---|---|---|
.. | ||
.gitignore | ||
always-no-bool-compare.m4 | ||
always-no-unused-but-set-variable.m4 | ||
config.awk | ||
deb.am | ||
kernel-acl.m4 | ||
kernel-automount.m4 | ||
kernel-bdev-block-device-operations.m4 | ||
kernel-bdev-logical-size.m4 | ||
kernel-bdev-physical-size.m4 | ||
kernel-bdi-setup-and-register.m4 | ||
kernel-bio-bvec-iter.m4 | ||
kernel-bio-end-io-t-args.m4 | ||
kernel-bio-failfast.m4 | ||
kernel-bio-rw-barrier.m4 | ||
kernel-bio-rw-discard.m4 | ||
kernel-blk-queue-flush.m4 | ||
kernel-blk-queue-max-hw-sectors.m4 | ||
kernel-blk-queue-max-segments.m4 | ||
kernel-blkdev-get-by-path.m4 | ||
kernel-blkdev-get.m4 | ||
kernel-block-device-operations-release-void.m4 | ||
kernel-clear-inode.m4 | ||
kernel-commit-metadata.m4 | ||
kernel-create-nameidata.m4 | ||
kernel-current_bio_tail.m4 | ||
kernel-d-make-root.m4 | ||
kernel-d-obtain-alias.m4 | ||
kernel-d-prune-aliases.m4 | ||
kernel-declare-event-class.m4 | ||
kernel-dentry-operations.m4 | ||
kernel-dirty-inode.m4 | ||
kernel-discard-granularity.m4 | ||
kernel-elevator-change.m4 | ||
kernel-encode-fh-inode.m4 | ||
kernel-evict-inode.m4 | ||
kernel-fallocate.m4 | ||
kernel-file-inode.m4 | ||
kernel-fmode-t.m4 | ||
kernel-follow-down-one.m4 | ||
kernel-fsync.m4 | ||
kernel-generic_io_acct.m4 | ||
kernel-get-disk-ro.m4 | ||
kernel-get-gendisk.m4 | ||
kernel-get-link.m4 | ||
kernel-insert-inode-locked.m4 | ||
kernel-invalidate-bdev-args.m4 | ||
kernel-is_owner_or_cap.m4 | ||
kernel-kmap-atomic-args.m4 | ||
kernel-kobj-name-len.m4 | ||
kernel-lookup-bdev.m4 | ||
kernel-lookup-nameidata.m4 | ||
kernel-lseek-execute.m4 | ||
kernel-mk-request-fn.m4 | ||
kernel-mkdir-umode-t.m4 | ||
kernel-mount-nodev.m4 | ||
kernel-open-bdev-exclusive.m4 | ||
kernel-put-link.m4 | ||
kernel-security-inode-init.m4 | ||
kernel-set-nlink.m4 | ||
kernel-sget-args.m4 | ||
kernel-show-options.m4 | ||
kernel-shrink.m4 | ||
kernel-truncate-range.m4 | ||
kernel-truncate-setsize.m4 | ||
kernel-vfs-iterate.m4 | ||
kernel-vfs-rw-iterate.m4 | ||
kernel-xattr-handler.m4 | ||
kernel.m4 | ||
mount-helper.m4 | ||
rpm.am | ||
Rules.am | ||
suppressed-warnings.txt | ||
tgz.am | ||
user-arch.m4 | ||
user-commands.m4 | ||
user-dracut.m4 | ||
user-frame-larger-than.m4 | ||
user-libattr.m4 | ||
user-libblkid.m4 | ||
user-libuuid.m4 | ||
user-runstatedir.m4 | ||
user-systemd.m4 | ||
user-sysvinit.m4 | ||
user-udev.m4 | ||
user-zlib.m4 | ||
user.m4 | ||
zfs-build.m4 | ||
zfs-meta.m4 |