The package sys-fs/lvm2-2.02.187-r2 fails to build with the use flag 'static' enabled due to a couple of undefined reference errors like these: /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: (.text.capability_quintet_enforce+ 0x4af): undefined reference to `cap_free' /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/9 .3.0/../../../../lib64/libsystemd.a(src_libsystemd_sd-daemon_sd-daemon.c.o): in function `sd_is_mq': (.text.sd_is_mq+0x3a): undefined reference to `mq_getattr' I am using gcc-9.3.0-r2. Reproducible: Always
Created attachment 679910 [details] emerge --info
Created attachment 679913 [details] build log
There is some progress upstream: https://github.com/lvmteam/lvm2/issues/45
You probably just need to rebuild sys-apps/systemd.
Actually, we probably need to link against indirect dependencies of libsystemd.a (namely libcap and librt).
So the root issue is that systemd upstream doesn't really support static libs, and the pkgconfig file is missing some key information for static linking.
*** Bug 801070 has been marked as a duplicate of this bug. ***
Rebuilding systemd does not fix it, neither for lvm2 nor for cryptsetup (bug #801070).
It looks like the lvm2 build system needs to be fixed to use the static libs info (Libs.private) from libudev.pc.
Trying to build sys-fs/lvm2-2.02.187-r2 against sys-apps/systemd-249-r3 now results in a missing -lsystemd: x86_64-pc-linux-gnu-gcc -O2 -pipe -march=native -fPIC -Wl,-O1 -Wl,--as-needed -L./libdm -L./lib -L./libdaemon/client -L./daemons/dmeventd -L../libdm -L../lib -L../libdaemon/client -L../daemons/dmeventd -Wl,--no-export-dynamic -static -L../libdm/ioctl -o lvm.static \ command.o dumpconfig.o formats.o lvchange.o lvconvert.o lvconvert_poll.o lvcreate.o lvdisplay.o lvextend.o lvmcmdline.o lvmdiskscan.o lvreduce.o lvremove.o lvrename.o lvresize.o lvscan.o polldaemon.o pvchange.o pvck.o pvcreate.o pvdisplay.o pvmove.o pvmove_poll.o pvremove.o pvresize.o pvscan.o reporter.o segtypes.o tags.o toollib.o vgcfgbackup.o vgcfgrestore.o vgchange.o vgck.o vgcreate.o vgconvert.o vgdisplay.o vgexport.o vgextend.o vgimport.o vgmerge.o vgmknodes.o lvpoll.o vgimportclone.o vgreduce.o vgremove.o vgrename.o vgscan.o vgsplit.o lvm-static.o -llvm-internal ../base/libbase.a -ldevmapper-event -ldaemonclient -lsystemd -ludev -ldl -lblkid -ldevmapper -laio -ludev -lrt -pthread -lblkid -lm -lpthread /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lsystemd /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../lib64/libudev.a(src_basic_util.c.o): in function `version': (.text.version+0x0): multiple definition of `version'; lvmcmdline.o:lvmcmdline.c:(.text+0x3d10): first defined here /usr/lib/gcc/x86_64-pc-linux-gnu/10.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: ../lib/liblvm-internal.a(sharedlib.o): in function `load_shared_library': sharedlib.c:(.text+0x153): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking collect2: error: ld returned 1 exit status Note that the shared library versions of libsystemd are installed despite the static-libs use flag: % qlist systemd | grep /lib | grep "libsystemd\." /usr/lib64/pkgconfig/libsystemd.pc /usr/lib64/libsystemd.so /usr/lib/libsystemd.so.0 /usr/lib/libsystemd.so.0.32.0 /usr/lib/pkgconfig/libsystemd.pc /usr/lib/libsystemd.so /lib64/libsystemd.so.0 /lib64/libsystemd.so.0.32.0 % qlist systemd | grep "\.a\>" /usr/lib64/libudev.a /usr/lib/libudev.a % eix -e systemd […] Installed versions: 249-r3(0/2)^t(09:19:59 12.07.2021)(acl apparmor cryptsetup gcrypt hwdb kmod lz4 pam pcre policykit resolvconf seccomp split-usr static-libs sysv-utils zstd -audit -build -cgroup-hybrid -curl -dns-over-tls -elfutils -gnuefi -homed -http -idn -importd -lzma -nat -pkcs11 -pwquality -qrcode -repart -selinux -test -tpm -vanilla -xkb ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="32 64 -x32" KERNEL="linux")
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e6b3fbbe8db1cca0c7f1bd5e64744765d030e7a9 commit e6b3fbbe8db1cca0c7f1bd5e64744765d030e7a9 Author: Mike Gilbert <floppym@gentoo.org> AuthorDate: 2021-07-12 13:59:09 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2021-07-12 13:59:09 +0000 sys-fs/lvm2: set REQUIRED_USE="static? ( !systemd )" libsystemd.a was dropped in 304993e0f527970b16ea4c4e0e07a06ee8b55e55. Bug: https://bugs.gentoo.org/762017 Signed-off-by: Mike Gilbert <floppym@gentoo.org> sys-fs/lvm2/lvm2-2.02.187-r2.ebuild | 1 + sys-fs/lvm2/lvm2-2.02.188.ebuild | 1 + sys-fs/lvm2/lvm2-2.03.12.ebuild | 1 + 3 files changed, 3 insertions(+)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=16f1bcaa8abae55ad46bfa3c4bb49882834977a5 commit 16f1bcaa8abae55ad46bfa3c4bb49882834977a5 Author: Mike Gilbert <floppym@gentoo.org> AuthorDate: 2021-07-12 14:44:39 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2021-07-12 14:45:22 +0000 sys-fs/lvm2: fix static link failure for dmsetup.static Bug: https://bugs.gentoo.org/762017 Signed-off-by: Mike Gilbert <floppym@gentoo.org> .../lvm2-2.03.12-static-pkgconfig-libs-2.patch | 38 ++++++++++++++++++++++ sys-fs/lvm2/lvm2-2.03.12.ebuild | 1 + 2 files changed, 39 insertions(+)
Static linking still fails in 2.02.188: * USE: elibc_glibc hppa kernel_linux readline static udev userland_GNU * FEATURES: network-sandbox preserve-libs sandbox userpriv usersandbox
(In reply to Rolf Eike Beer from comment #13) > Static linking still fails in 2.02.188: That's probably a different issue. File a new bug please.