busybox emerge failed with the errors disclosed on the URL. Reproducible: Always Steps to Reproduce: 1.emerge =sys-libs/libselinux-2.1.13-r2 2.emerge =sys-apps/busybox-1.20.2 Actual Results: /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/libselinux.a(procattr.o): In function `init_procattr': (.text+0x1d8): undefined reference to `pthread_atfork' Expected Results: busybog emerged This got fixed with following patch: libselinux-2.1.13.orig/src/libselinux.pc.in libselinux-2.1.13/src/libselinux.pc.in --- libselinux-2.1.13.orig/src/libselinux.pc.in 2013-02-06 03:43:22.000000000 +0200 +++ libselinux-2.1.13/src/libselinux.pc.in 2013-06-18 17:59:31.018121175 +0300 @@ -8,5 +8,6 @@ Version: @VERSION@ URL: http://userspace.selinuxproject.org/ Requires.private: libsepol libpcre +Libs.private: -lpthread Libs: -L${libdir} -lselinux Cflags: -I${includedir}
Created attachment 351316 [details] Tested ebuild I used this ebuild to apply the patch probosed
Created attachment 351318 [details, diff] Patch for including required line This is the proposed patch as file
I would like to add that there is also similar problem with cryptsetup which (inspired by this bugreport) I fixed by adding -lpthread to Libs instead of Libs.private (it still failed with this one) emerge cryptsetup with unpatched libselinux: libtool: link: x86_64-pc-linux-gnu-gcc -Wall -O3 -march=native -pipe -static -Wl,-O1 -o veritysetup.static veritysetup_static-utils_crypt.o veritysetup_static-utils_loop.o veritysetup_static-utils_tools.o veritysetup_static-veritysetup.o -Wl,--as-needed ../lib/.libs/libcryptsetup.a -L/lib64 -lpopt /usr/lib64/libgcrypt.a -lgpg-error -ldevmapper -lselinux -lsepol -lpcre -ludev -lrt -luuid /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find -lselinux /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find -lpcre /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function _selabel_lookup: error: undefined reference to 'selabel_lookup' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function _selabel_lookup: error: undefined reference to 'selabel_open' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'is_selinux_enabled' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'setfscreatecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'setfscreatecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'is_selinux_enabled' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'lsetfilecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function selinux_release: error: undefined reference to 'selabel_close' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libudev.a(libudev_la-libudev-util.o):function util_lookup_user: 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.7.3/../../../../lib64/libudev.a(libudev_la-libudev-util.o):function util_lookup_group: 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.7.3/../../../../lib64/libudev.a(util.o):function lookup_uid: warning: Using 'getpwuid_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.7.3/../../../../lib64/libudev.a(util.o):function get_user_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function get_user_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function uid_to_name: 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.7.3/../../../../lib64/libudev.a(util.o):function gid_to_name: 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.7.3/../../../../lib64/libudev.a(util.o):function get_group_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function get_group_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function get_home_dir: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking collect2: error: ld returned 1 exit status make[2]: *** [cryptsetup.static] Error 1 make[2]: *** Waiting for unfinished jobs.... /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find -lselinux /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: error: cannot find -lpcre /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function _selabel_lookup: error: undefined reference to 'selabel_lookup' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function _selabel_lookup: error: undefined reference to 'selabel_open' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'is_selinux_enabled' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'setfscreatecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'setfscreatecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_prepare_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'is_selinux_enabled' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'lsetfilecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function dm_set_selinux_context: error: undefined reference to 'freecon' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libdevmapper.a(libdm-common.o):function selinux_release: error: undefined reference to 'selabel_close' /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libudev.a(libudev_la-libudev-util.o):function util_lookup_user: 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.7.3/../../../../lib64/libudev.a(libudev_la-libudev-util.o):function util_lookup_group: 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.7.3/../../../../lib64/libudev.a(util.o):function lookup_uid: warning: Using 'getpwuid_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.7.3/../../../../lib64/libudev.a(util.o):function get_user_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function get_user_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function uid_to_name: 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.7.3/../../../../lib64/libudev.a(util.o):function gid_to_name: 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.7.3/../../../../lib64/libudev.a(util.o):function get_group_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function get_group_creds: 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.7.3/../../../../lib64/libudev.a(util.o):function get_home_dir: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking collect2: error: ld returned 1 exit status make[2]: *** [veritysetup.static] Error 1 make[2]: Leaving directory `/var/tmp/portage/sys-fs/cryptsetup-1.6.1/work/cryptsetup-1.6.1/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/var/tmp/portage/sys-fs/cryptsetup-1.6.1/work/cryptsetup-1.6.1' make: *** [all] Error 2 * ERROR: sys-fs/cryptsetup-1.6.1 failed (compile phase): * emake failed * * If you need support, post the output of `emerge --info '=sys-fs/cryptsetup-1.6.1'`, * the complete build log and the output of `emerge -pqv '=sys-fs/cryptsetup-1.6.1'`. * The complete build log is located at '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/temp/environment'. * Working directory: '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/work/cryptsetup-1.6.1' * S: '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/work/cryptsetup-1.6.1' >>> Failed to emerge sys-fs/cryptsetup-1.6.1, Log file: >>> '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/temp/build.log' * Messages for package sys-fs/cryptsetup-1.6.1: * ERROR: sys-fs/cryptsetup-1.6.1 failed (compile phase): * emake failed * * If you need support, post the output of `emerge --info '=sys-fs/cryptsetup-1.6.1'`, * the complete build log and the output of `emerge -pqv '=sys-fs/cryptsetup-1.6.1'`. * The complete build log is located at '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/temp/build.log'. * The ebuild environment file is located at '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/temp/environment'. * Working directory: '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/work/cryptsetup-1.6.1' * S: '/var/tmp/portage/sys-fs/cryptsetup-1.6.1/work/cryptsetup-1.6.1'
(In reply to Amadeusz Sławiński from comment #3) > I would like to add that there is also similar problem with cryptsetup which > (inspired by this bugreport) I fixed by adding -lpthread to Libs instead of > Libs.private (it still failed with this one) [...] > ld: error: cannot find -lselinux > /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ > ld: error: cannot find -lpcre You're saying that adding -lpthread to the Libs allowed it to find the libselinux and libpcre libraries during linking phase?
Created attachment 351670 [details] busybox failure Ok so that it's clear, suggested approach definitely fixes busybox (attached mine failure), seems to fail in the same place.
Created attachment 351672 [details] cryptsetup failure Seems like I can't reproduce that log with cannot find -lpcre/-lselinux However cryptsetup fails in similar way ie: /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../lib64/libselinux.a(procattr.o):function init_procattr: error: undefined reference to 'pthread_atfork'
Created attachment 351676 [details] cryptsetup failure with -lpthread in Libs.private It also fails when -lpthread is defined in Libs.private busybox and cryptsetup build both fine for me when I add -lpthread in Libs line
Should be in libselinux-2.1.13-r3
Stable in tree
*** Bug 476866 has been marked as a duplicate of this bug. ***