Created attachment 327234 [details, diff] Use pkg-config for libselinux in the lvm2 configure script When linking, the lvm2 build system make direct reference to '-lselinux', bypassing pkg-config and thus not linking with '-lprce': x86_64-pc-linux-gnu-gcc -march=native -O2 -pipe -march=native -O2 -pipe -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissi ng-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 -march=native -O2 -pipe -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-exte rns -Winline -Wmissing-noreturn -Wformat-security -Wredundant-decls -Wpointer-arith -O2 -Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--as-needed -Wl,--export-dynamic -L./libdm -L./lib -L./daemons/dmeventd -Wl,-O1 -Wl ,--as-needed -Wl,--export-dynamic -L../libdm -L../lib -L../daemons/dmeventd -Wl,--no-export-dynamic -static -L../libdm/ioctl \ -o dmsetup.static dmsetup.o -ldevmapper -lselinux -lsepol -ludev -lrt -ludev -lrt /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(seusers.o): In function `getseuserbyname': (.text+0x602): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(seusers.o): In function `getseuserbyname': (.text+0x3a2): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(seusers.o): In function `getseuserbyname': (.text+0xa5): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(label_file.o): In function `closef': (.text+0x180): undefined reference to `pcre_free' /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(label_file.o): In function `closef': (.text+0x18b): undefined reference to `pcre_free_study' /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(label_file.o): In function `compile_regex.clone.5': (.text+0x2bf): undefined reference to `pcre_compile' /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(label_file.o): In function `compile_regex.clone.5': (.text+0x2de): undefined reference to `pcre_study' /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(label_file.o): In function `lookup': (.text+0x49d): undefined reference to `pcre_exec' /usr/lib/gcc/x86_64-pc-linux-gnu/4.5.4/../../../../lib64/libselinux.a(label_file.o): In function `lookup': (.text+0x530): undefined reference to `pcre_exec' collect2: ld returned 1 exit status make[1]: *** [dmsetup.static] Error 1 make[1]: Leaving directory `/var/tmp/portage/sys-fs/lvm2-2.02.88/work/LVM2.2.02.88/tools' make: *** [tools.device-mapper] Error 2 emake failed I attached some idea of patch (it works with sys-libs/libselinux-2.1.12-r1 from the overlay and libpcre[static] but I'm not sure it should be written like that, as I have close to no experience with pkg-config, autoreconf & co)
*** This bug has been marked as a duplicate of bug 438998 ***
Same problem here. Yet, unstable version sys-fs/lvm2-2.02.93-r1 compiles just fine. Later versions are blocked by openrc.
sys-fs/lvm2-2.02.93-r1 also compile fine here (Didn't tried to run it through). There are some modifications in the Configure.in (e.g +STATIC_LDFLAGS="-Wl,--no-export-dynamic") that probably explains the 'fix'. I just noticed that there is no mention of libselinux in the ebuild. Shouldn't there be a dev-libs/libselinux[static-libs?] in the RDEPEND ?
Created attachment 345148 [details] Build log (undefined reference to `pcre_free') I just checked sys-fs/lvm2-2.02.97-r1[selinux,static]: in fact it still doesn't work (I'm using non-static lvm2, thus I normally doesn't check it). I've attached a build.log. Steps to reproduce: - Install a selinux enabled - Install libselinux[static-libs] (I think a dependency to this should be added in the ebuild, e.g: 'selinux? ( static? ( libselinux[static-libs] ) )' ) - Try to install sys-fs/lvm2-2.02.97-r1[static]
Created attachment 345150 [details] Build log after patch: compiles with warnings The patch I proposed before is still 'working': it fixes the pcre linking problem and allows the compilation to end with no errors. I've added a full build.log to the bug report. However, there are some strange warnings during the compilation: x86_64-pc-linux-gnu-gcc -march=native -O2 -pipe -march=native -O2 -pipe -fPIC -O2 -march=native -O2 -pipe -fPIC -O2 -Wl,-O1 -Wl,--as-needed -Wl,-O1 -Wl,--as-needed -O2 -L./libdm -L./lib -L./libdaemon/clien t -L./daemons/dmeventd -Wl,-O1 -Wl,--as-needed -O2 -L../libdm -L../lib -L../libdaemon/client -L../daemons/dmeventd -Wl,--no-export-dynamic -static -L../libdm/ioctl \ -o dmsetup.static dmsetup.o -ldevmapper -lselinux -lsepol -lpcre -ludev -lrt -ludev -lrt /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libselinux.a(seusers.o): In function `getseuserbyname': (.text+0x5f9): warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libudev.a(util.o): In function `gid_to_name': (.text.gid_to_name+0x2b): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libudev.a(util.o): In function `get_group_creds': (.text.get_group_creds+0xce): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libselinux.a(seusers.o): In function `getseuserbyname': (.text+0x360): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libudev.a(util.o): In function `get_user_creds': (.text.get_user_creds+0x15d): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libudev.a(util.o): In function `get_user_creds': (.text.get_user_creds+0xcf): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libselinux.a(seusers.o): In function `getseuserbyname': (.text+0xa2): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../lib64/libudev.a(util.o): In function `lookup_uid': (.text.lookup_uid+0x85): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking Is the static compilation of lvm2 completely broken ?
Created attachment 345152 [details] Trying to build without libselinux[static-libs] Tried to build lvm2[static] without libselinux[static-libs], as expected it failed (I just wanted to have some proof for the modification of the ebuild, the need of dependency upon libselinux[static-libs] (libselinux is installed only as -static-libs here)): /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/bin/ld: cannot find -lselinux
For the libselinux stuff that uses glibc calls (like the "warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking" warning), is there anything that I can patch inside libselinux for this (except using uclibc)? Or is it "allowed" that statically linked applications do use glibc-related dynamic linking?
Created attachment 354860 [details, diff] a re-write of the patch base don the one for udev[static-libs] The following patch applies to 2.02.97 and above, and allowed me to build lvm2[selinux,static] without issue. Please not that in combination with applying this patch, dependencies on libselinux should also be adjusted: --- lvm2-2.02.98.ebuild 2013-08-01 15:42:03.000000000 -0400 +++ lvm2-2.02.98.ebuild.new 2013-08-01 17:47:49.000000000 -0400 @@ -39,7 +39,10 @@ DEPEND="${DEPEND_COMMON} virtual/pkgconfig >=sys-devel/binutils-2.20.1-r1 - static? ( udev? ( virtual/udev[static-libs] ) )" + static? ( + udev? ( virtual/udev[static-libs] ) + selinux? ( sys-libs/libselinux[static-libs] ) + )" S="${WORKDIR}/${PN/lvm/LVM}.${PV}"
Created attachment 355078 [details, diff] lvm2-2.02.99 patch update Here is a clean simple patch just add to end of ebuild and go :) All credit to AXS for his work on this.
Thanks Jory for the updated patch for .99 Vapier gave me the OK to commit after testing passed with a forced-install of libselinux et. al.; anyone using a full selinux system and still has issues, please reopen. + 06 Aug 2013; Ian Stakenvicius <axs@gentoo.org> + +files/lvm2-2.02.97-selinux-static.patch, + +files/lvm2-2.02.99-selinux-static.patch, lvm2-2.02.97-r1.ebuild, + lvm2-2.02.98.ebuild, lvm2-2.02.99-r1.ebuild, lvm2-2.02.99.ebuild: + fixed compile error when building with USE='static selinux', bug 439414 +