Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 762017 - sys-fs/lvm2 - static linkage against libudev fails due to underlinking
Summary: sys-fs/lvm2 - static linkage against libudev fails due to underlinking
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on: 801325
Blocks:
  Show dependency tree
 
Reported: 2020-12-27 23:00 UTC by Stefan Huber
Modified: 2021-08-30 02:35 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info.log,6.61 KB, text/x-log)
2020-12-27 23:00 UTC, Stefan Huber
Details
build log (build.log,110.52 KB, text/x-log)
2020-12-27 23:00 UTC, Stefan Huber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Huber 2020-12-27 23:00:19 UTC
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
Comment 1 Stefan Huber 2020-12-27 23:00:40 UTC
Created attachment 679910 [details]
emerge --info
Comment 2 Stefan Huber 2020-12-27 23:00:55 UTC
Created attachment 679913 [details]
build log
Comment 3 Stefan Huber 2021-04-13 00:04:10 UTC
There is some progress upstream:
https://github.com/lvmteam/lvm2/issues/45
Comment 4 Mike Gilbert gentoo-dev 2021-07-08 17:42:36 UTC
You probably just need to rebuild sys-apps/systemd.
Comment 5 Mike Gilbert gentoo-dev 2021-07-08 17:48:26 UTC
Actually, we probably need to link against indirect dependencies of libsystemd.a (namely libcap and librt).
Comment 6 Mike Gilbert gentoo-dev 2021-07-08 17:54:32 UTC
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.
Comment 7 Mike Gilbert gentoo-dev 2021-07-08 17:54:41 UTC
*** Bug 801070 has been marked as a duplicate of this bug. ***
Comment 8 Stefan Huber 2021-07-09 07:52:10 UTC
Rebuilding systemd does not fix it, neither for lvm2 nor for cryptsetup (bug #801070).
Comment 9 Mike Gilbert gentoo-dev 2021-07-11 23:16:23 UTC
It looks like the lvm2 build system needs to be fixed to use the static libs info (Libs.private) from libudev.pc.
Comment 10 Stefan Huber 2021-07-12 07:52:16 UTC
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")
Comment 11 Larry the Git Cow gentoo-dev 2021-07-12 14:00:59 UTC
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(+)
Comment 12 Larry the Git Cow gentoo-dev 2021-07-12 14:45:25 UTC
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(+)
Comment 13 Rolf Eike Beer archtester 2021-08-12 07:31:10 UTC
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
Comment 14 Mike Gilbert gentoo-dev 2021-08-30 02:35:17 UTC
(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.