In 9fae47666 zfsd got a libspl dependency to avoid undefined references.
However that workaround did not help external consumers of libzfs_core.
Fix all missing dependencies lld 13 and the rtld complain about.
Differential D32521
cddl: fix missing ZFS library dependencies val_packett.cool on Oct 16 2021, 4:32 PM. Authored by Tags Referenced Files
Details
In 9fae47666 zfsd got a libspl dependency to avoid undefined references. Fix all missing dependencies lld 13 and the rtld complain about. e.g. a libzetta-rs based rust app doesn't fail to build anymore with = note: ld: error: /usr/lib/libzfs_core.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] ld: error: /usr/lib/libzfs_core.so: undefined reference to zfs_ioctl_fd [--no-allow-shlib-undefined] ld: error: /usr/lib/libnvpair.so: undefined reference to libspl_assertf [--no-allow-shlib-undefined] clang-13: error: linker command failed with exit code 1 (use -v to see invocation) and doesn't fail to launch with ld-elf.so.1: /lib/libzfs_core.so.2: Undefined symbol "libspl_assertf" or ld-elf.so.1: /lib/libzutil.so.2: Undefined symbol "powl" or ld-elf.so.1: /lib/libzutil.so.2: Undefined symbol "g_open"
Diff Detail
Event TimelineComment Actions This looks good, but I'm surprised that there aren't more transitive dependencies that can be removed. For example, zfsd doesn't use libzfs_core directly, only through libzfs. Can libzfs_core be removed from its LIBADD? Comment Actions Yep, that works. I haven't had the time to thoroughly investigate every zfs dependency in the tree, my goal was to unbreak external consumers of libzfs_core. Comment Actions A buildworld fails after applying this patch to main, seems to be while linking libavl: --- cddl/lib/libavl__L --- cc -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp -B/usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/usr/bin -fstack-protector-strong -shared -Wl,-x -Wl,--fatal-warnings -Wl,--warn-shared-textrel -o libavl.so.2.full -Wl,-soname,libavl.so.2 avl.pico -lspl ... --- cddl/lib/libavl__L --- ld: error: relocation R_X86_64_PC32 cannot be used against symbol __stderrp; recompile with -fPIC >>> defined in /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/lib/libc.so.7 >>> referenced by assert.c:38 (/usr/home/markj/src/freebsd/sys/contrib/openzfs/lib/libspl/assert.c:38) >>> assert.o:(libspl_assertf) in archive /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/usr/lib/libspl.a ld: error: relocation R_X86_64_PC32 cannot be used against symbol __stderrp; recompile with -fPIC >>> defined in /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/lib/libc.so.7 >>> referenced by assert.c:39 (/usr/home/markj/src/freebsd/sys/contrib/openzfs/lib/libspl/assert.c:39) >>> assert.o:(libspl_assertf) in archive /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/usr/lib/libspl.a ld: error: relocation R_X86_64_PC32 cannot be used against symbol __stderrp; recompile with -fPIC >>> defined in /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/lib/libc.so.7 >>> referenced by assert.c:40 (/usr/home/markj/src/freebsd/sys/contrib/openzfs/lib/libspl/assert.c:40) >>> assert.o:(libspl_assertf) in archive /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/usr/lib/libspl.a ld: error: can't create dynamic relocation R_X86_64_32 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output >>> defined in /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/usr/lib/libspl.a(assert.o) >>> referenced by assert.c:40 (/usr/home/markj/src/freebsd/sys/contrib/openzfs/lib/libspl/assert.c:40) >>> assert.o:(libspl_assertf) in archive /usr/obj/usr/home/markj/src/freebsd/amd64.amd64/tmp/usr/lib/libspl.a Comment Actions Also add to Makefile.inc1 and SUBDIR_DEPEND_*. Should always work now. git patch with metadata in case pulling that out from differential fails: P527 |