Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 502544

Summary: sys-libs/libselinux: libselinux.pc libdir doesn't respect multilib (was: sys-apps/util-linux: build fails due to missing dependency -L/usr/lib for libmount)
Product: Gentoo Linux Reporter: Olaf Leidinger <oleid>
Component: [OLD] Core systemAssignee: Sven Vermeulen (RETIRED) <swift>
Status: VERIFIED FIXED    
Severity: normal CC: base-system, dennis.freise, selinux
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: http://bugs.gentoo.org/show_bug.cgi?id=502954
http://bugs.gentoo.org/show_bug.cgi?id=481782
Whiteboard: selinux-utils
Package list:
Runtime testing required: ---
Attachments: patch to fix the build dependencies
patch to current ebuild (2.24.1-r2)

Description Olaf Leidinger 2014-02-26 17:13:20 UTC
On Gentoo-hardened with selinux enabled, build fails as make doesn't know how to create -L/usr/lib. The relevant parts of the Makefile are the following:

libmount.la: $(libmount_la_OBJECTS) $(libmount_la_DEPENDENCIES) $(EXTRA_libmount_la_DEPENDENCIES)
        $(AM_V_CCLD)$(libmount_la_LINK) $(am_libmount_la_rpath) $(libmount_la_OBJECTS) $(libmount_la_LIBADD) $(LIBS)


libmount_la_DEPENDENCIES = \
        $(libmount_la_LIBADD) \
        libmount/src/libmount.sym \
        libmount/src/libmount.h.in

libmount_la_LIBADD = libcommon.la libblkid.la $(SELINUX_LIBS)

SELINUX_LIBS is set to the output of pkg-config --libs libselinux, which is
-L/usr/lib -lselinux

Thus, -L/usr/lib is listed as a build-time dependency and clearly, make doesn't know how to create it.

Reproducible: Always
Comment 1 Olaf Leidinger 2014-02-26 17:19:14 UTC
Created attachment 371348 [details, diff]
patch to fix the build dependencies
Comment 2 Olaf Leidinger 2014-02-26 17:33:42 UTC
Created attachment 371350 [details, diff]
patch to current ebuild (2.24.1-r2)

As the fixed build dependencies change Makefile.am, a regeneration of Makefile.in is needed. The patch to the ebuild reflects that.
Comment 3 Olaf Leidinger 2014-02-26 17:50:42 UTC
Upstream bug:
https://github.com/karelzak/util-linux/issues/49
Comment 4 Samuli Suominen gentoo-dev 2014-02-26 19:09:19 UTC
See bug 481782, Comment #5 and up to #7

Output of libselinux shouldn't mention -L/usr/lib at all, it should omit native library directory

What version of libselinux and/or libsepol is this? Does upgrading to very latest change anything?
Comment 5 Samuli Suominen gentoo-dev 2014-02-26 19:12:17 UTC
pastebin the /usr/lib/pkgconfig/selinux.pc and 'emerge -pv libselinux'
it should NOT list -L/usr/lib
and what pkg-config are you using? output of 'emerge -pv --nodeps dev-util/pkgconfig dev-util/pkgconf`?
Comment 6 Olaf Leidinger 2014-02-26 22:51:16 UTC
Here is the output pastebin-ed:
http://pastebin.com/hwjCqJRf

The libsepol-bug is related, I think, as the pkgbuild file, which was generated for libselinux sets libdir to /usr/lib instead of /usr/lib64 for my 64bit system. If this was fixed, util-linux would build properly.

However, the dependency in the Makefile is wrong, anyway. If one installs libselinux to a non-standard path, things will break. This won't happen on Gentoo when installing everything via portage, so a fix for libselinux's pkgconfig-file generation would be sufficient in our case.
Comment 7 SpanKY gentoo-dev 2014-02-26 23:58:13 UTC
paste the output here.  external links die & are useless.

ignoring the -L thing, we don't want -lfoo showing up in make deps either.  so upstream might be setting vars wrong ...
Comment 8 Olaf Leidinger 2014-02-27 06:47:10 UTC
The content of the external link:

 $ emerge -pv libselinux sys-libs/libsepol
[...]
 
[ebuild   R    ] sys-libs/libselinux-2.2.2-r1  USE="(python) static-libs" ABI_X86="(64) -32 (-x32)" PYTHON_TARGETS="python2_7 python3_2 -python3_3" 168 kB
[ebuild   R    ] sys-libs/libsepol-2.2  ABI_X86="(64) -32 (-x32)" 205 kB
 
[...]
 
################################################################################
 $ pkg-config --libs libsepol
-lsepol
 
################################################################################
 
 $ cat /usr/lib/pkgconfig/libselinux.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=/usr/include
 
Name: libselinux
Description: SELinux utility library
Version: 2.2.2
URL: http://userspace.selinuxproject.org/
Requires.private: libsepol libpcre
Libs: -L${libdir} -lselinux
Cflags: -I${includedir}

################################################################################

$ emerge -pv --nodeps dev-util/pkgconfig dev-util/pkgconf
 
These are the packages that would be merged, in order:
 
[ebuild   R    ] dev-util/pkgconfig-0.28  USE="hardened -internal-glib" 1,886 kB
[ebuild  N     ] dev-util/pkgconf-0.9.3  USE="pkg-config -strict" 81 kB
 
Total: 2 packages (1 new, 1 reinstall), Size of downloads: 1,967 kB

################################################################################

$ emerge --info
Portage 2.2.8-r1 (hardened/linux/amd64/selinux, gcc-4.8.2, glibc-2.18-r1, 3.12.2-hardened x86_64)
=================================================================
System uname: Linux-3.12.2-hardened-x86_64-AMD_E-350_Processor-with-gentoo-2.2
KiB Mem:     7759448 total,   1490928 free
KiB Swap:    8388604 total,   8128088 free
Timestamp of tree: Tue, 25 Feb 2014 22:00:01 +0000
ld GNU ld (GNU Binutils) 2.24
app-shells/bash:          4.2_p45-r1
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.6, 3.2.5-r3, 3.3.4
dev-util/cmake:           2.8.12.2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4::pentoo
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.14.1
sys-devel/binutils:       2.24-r2
sys-devel/gcc:            4.8.2-r1::hardened-dev
sys-devel/gcc-config:     1.8
sys-devel/libtool:        2.4.2
sys-devel/make:           4.0-r1
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.18-r1
Repositories: gentoo local laurentb gentoo-haskell chtekk-apps jamesbroadhead hardened-dev emery systemd-love pentoo dragon chain
ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=native  -fomit-frame-pointer  -floop-interchange -floop-strip-mine -floop-block"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /home/www /usr/share/gnupg/qualified.txt /var/www/localhost/htdocs"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-O2 -pipe -march=native  -fomit-frame-pointer  -floop-interchange -floop-strip-mine -floop-block"
DISTDIR="/var/cache/distfiles"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sesandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="de_DE.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -O2 -pipe -march=native  -fomit-frame-pointer  -floop-interchange -floop-strip-mine -floop-block"
MAKEOPTS="-j1"
PKGDIR="/var/cache/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /var/lib/layman/laurentb /var/lib/layman/haskell /var/lib/layman/chtekk-apps /var/lib/layman/jamesbroadhead /var/lib/layman/hardened-development /var/lib/layman/emery /var/lib/layman/systemd-love /var/lib/layman/pentoo /var/lib/layman/dragon /var/lib/layman/spectrum2"
USE="3dnow 3dnowext aac aacplus amd64 audiofile avahi avx berkdb bzip2 c++0x cdio cli cracklib crypt cue cups cxx dirac dri egl faac flac fluidsynth gdbm gif hardened iconv inotify ipv6 jpeg jpeg2k justify lame lastfmradio libsamplerate lzma mad midi mmx mmxext modules mp3 mpg123 multilib musepack mysql ncurses nls nptl ogg open_perms opengl openmp pam pax_kernel pcre png policykit pulseaudio readline selinux session sndfile sqlite sse sse2 sse4a ssl ssse3 systemd tcpd theora threads tiff truetype twolame unicode urandom usb vdpau vorbis x264 xtpax xz zeroconf zip zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="de en" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby19 ruby18" USERLAND="GNU" VIDEO_CARDS="radeon" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7 3.2"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, SYNC
Comment 9 Olaf Leidinger 2014-02-27 06:54:19 UTC
I had a look at how libselinux.pc was generated. This is the relevant part from the Makefile:


LIBDIR ?= $(PREFIX)/lib
LIBBASE ?= $(shell basename $(LIBDIR))
LIBPC=libselinux.pc

[...]

$(LIBPC): $(LIBPC).in ../VERSION
        sed -e 's/@VERSION@/$(VERSION)/; s:@prefix@:$(PREFIX):; s:@libdir@:$(LIBBASE):; s:@includedir@:$(INCLUDEDIR):' < $< > $@

####### libselinux.pc.in ##
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/@libdir@
includedir=@includedir@

Name: libselinux
Description: SELinux utility library
Version: @VERSION@
URL: http://userspace.selinuxproject.org/
Requires.private: libsepol libpcre
Libs: -L${libdir} -lselinux
Cflags: -I${includedir}
###########################

If I call make manually with:

LIBDIR=/usr/lib64 make

The generated libselinux.pc is fine. So I assume, that the variable is set wrongly in the ebuild.
Comment 10 Samuli Suominen gentoo-dev 2014-02-27 08:53:16 UTC
# grep libdir /usr/lib64/pkgconfig/libselinux.pc
libdir=${exec_prefix}/lib
Libs: -L${libdir} -lselinux
# qfile -v /usr/lib64/pkgconfig/libselinux.pc
sys-libs/libselinux-2.2.2-r1 (/usr/lib64/pkgconfig/libselinux.pc)
# pkg-config --libs libselinux
-L/usr/lib -lselinux

^ broken, identical bug to 481782
Comment 11 Samuli Suominen gentoo-dev 2014-02-27 08:55:49 UTC
what makes this even worse is that libselinux has ABI_X86="32" support and the /usr/lib32/pkgconfig/libselinux.pc also returns -L/usr/lib

so while util-linux could propably be adjusted to ignore this bug, the actual bug is really in libselinux, there is no way around that
Comment 12 Olaf Leidinger 2014-02-27 09:03:56 UTC
I agree, libselinux should be fixed (which would make the current release of utils-linux work for us as it is) and the dependency issue should be fixed upstream. I reported it there already, (c.f. the link above) so nothing to do for util-linux downstream.
Comment 13 Sven Vermeulen (RETIRED) gentoo-dev 2014-03-04 19:18:02 UTC
libselinux-2.2.2-r2 has the src_compile() now also running with LIBDIR and SHLIBDIR set (it was previously only set for the install phase).

~$ pkg-config --libs libselinux
-lselinux

~$ $ cat /usr/lib64/pkgconfig/libselinux.pc 
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir=/usr/include

Name: libselinux
Description: SELinux utility library
Version: 2.2.2
URL: http://userspace.selinuxproject.org/
Requires.private: libsepol libpcre
Libs: -L${libdir} -lselinux
Cflags: -I${includedir}

I'll look into bug 502954 as soon as I can too.
Comment 14 Olaf Leidinger 2014-03-05 11:02:58 UTC
$ cat /usr/lib64/pkgconfig/libselinux.pc 
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib64
includedir=/usr/include

Name: libselinux
Description: SELinux utility library
Version: 2.2.2
URL: http://userspace.selinuxproject.org/
Requires.private: libsepol libpcre
Libs: -L${libdir} -lselinux
Cflags: -I${includedir}

$ pkg-config --libs libselinux
-lselinux 


Works for me, thanks!

By the way, my patch made it upstream, so the next util-linux version won't have this dependency problem anymore. Thank's for fixing!
Comment 15 Sven Vermeulen (RETIRED) gentoo-dev 2014-04-21 18:39:39 UTC
libselinux-2.2.2-r4 is now stable