Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 729642 - dev-libs/check's pkgconfig file contains wrong libdir
Summary: dev-libs/check's pkgconfig file contains wrong libdir
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Joonas Niilola
URL: https://github.com/libcheck/check/pul...
Whiteboard:
Keywords: TESTFAILURE
Depends on:
Blocks:
 
Reported: 2020-06-25 16:08 UTC by Alexey
Modified: 2022-04-12 02:00 UTC (History)
2 users (show)

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


Attachments
emerge --info (file_729642.txt,19.46 KB, text/plain)
2020-06-25 16:08 UTC, Alexey
Details
build.log (build.log,29.71 KB, text/plain)
2020-06-25 16:09 UTC, Alexey
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey 2020-06-25 16:08:45 UTC
Created attachment 646410 [details]
emerge --info

/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libcheck.so: error adding symbols: file in wrong format
Comment 1 Alexey 2020-06-25 16:09:10 UTC
Created attachment 646412 [details]
build.log
Comment 2 Matt Turner gentoo-dev 2021-03-09 22:28:54 UTC
I don't think this has anything to do with no-symlink-lib or even libevdev.

The problem is that check's pc file is wrong:

 # cat /usr/lib/pkgconfig/check.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Check
Description: A unit test framework for C
URL: https://libcheck.github.io/check/
Version: 0.15.2
Requires.private: 
Libs: -L/usr/lib64 -lcheck
Libs.private:  -pthread  -lm -lrt
Cflags: -I${includedir} -pthread

Notice the -L/usr/lib64.
Comment 3 Matt Turner gentoo-dev 2021-03-09 22:34:06 UTC
After src_unpack:

# grep Libs: /var/tmp/portage/dev-libs/check-0.15.2/work/check-0.15.2/check.pc.in

After src_prepare:

grep Libs: /var/tmp/portage/dev-libs/check-0.15.2/work/check-0.15.2/check.pc.in
Libs: -L/usr/lib64 -lcheck
Comment 4 Matt Turner gentoo-dev 2021-03-09 22:34:40 UTC
Oh yeah.

    # Fix wrong libdir, probably caused by multilib
    sed -i "s|\${libdir}|/usr/$(get_libdir)|g" check.pc.in || die "sed .pc failed."

How did we ever expect this to work?
Comment 5 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-03-09 22:36:28 UTC
(In reply to Matt Turner from comment #2)
> I don't think this has anything to do with no-symlink-lib or even libevdev.
> 

Yeah, I added it because such bugs cause problems for people still migrating - like most of the bugs for it.

(In reply to Matt Turner from comment #3)
> After src_unpack:
> 
> # grep Libs:
> /var/tmp/portage/dev-libs/check-0.15.2/work/check-0.15.2/check.pc.in
> 
> After src_prepare:
> 
> grep Libs:
> /var/tmp/portage/dev-libs/check-0.15.2/work/check-0.15.2/check.pc.in
> Libs: -L/usr/lib64 -lcheck

In src_prepare:
	# Fix wrong libdir, probably caused by multilib
	sed -i "s|\${libdir}|/usr/$(get_libdir)|g" check.pc.in || die "sed .pc failed."

But this is wrong if we're in the multilib case.
Comment 6 Matt Turner gentoo-dev 2021-03-09 22:37:22 UTC
Looks like the fix for bug 714058 was put into the wrong src_* function.
Comment 7 Joonas Niilola gentoo-dev 2021-03-10 06:17:12 UTC
As I don't use/do multilib or cross-compile I'd be guessing what the correct phase is.

multilib_src_configure() {
  if multilib_is_native_abi; then
    sed

?

Or some hackery in 
multilib_src_install() {
  if multilib_is_native_abi; then
    find -exec sed
?
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2021-03-10 06:29:46 UTC
(In reply to Joonas Niilola from comment #7)
> As I don't use/do multilib or cross-compile I'd be guessing what the correct
> phase is.
> 
> multilib_src_configure() {
>   if multilib_is_native_abi; then
>     sed
> 
> ?
> 
> Or some hackery in 
> multilib_src_install() {
>   if multilib_is_native_abi; then
>     find -exec sed
> ?

I would do the latter in m_s_i and unconditionally sed to the appropriate libdir (so we aren’t assuming anything about which is native etc, I believe riscv was nearly weird here).
Comment 9 Joonas Niilola gentoo-dev 2021-03-10 10:34:03 UTC
--- /var/db/repos/gentoo/dev-libs/check/check-0.15.2.ebuild	2021-01-07 15:59:59.780714739 -0000
+++ ./check-0.15.2-r1.ebuild	2021-03-10 10:21:30.327967818 -0000
@@ -27,13 +27,6 @@
 
 PATCHES=( "${FILESDIR}/check-0.14.0-r2-disable-automagic-dep.patch" )
 
-src_prepare() {
-	cmake_src_prepare
-
-	# Fix wrong libdir, probably caused by multilib
-	sed -i "s|\${libdir}|/usr/$(get_libdir)|g" check.pc.in || die "sed .pc failed."
-}
-
 multilib_src_configure() {
 	local mycmakeargs=(
 		-DBUILD_TESTING=$(usex test ON OFF)
@@ -52,6 +45,11 @@
 	fi
 }
 
+multilib_src_install() {
+	cmake_src_install
+	find "${ED}" -name 'check.pc' -exec sed -i "s|\${libdir}|/usr/$(get_libdir)|g" {} \; || die
+}
+
 multilib_src_install_all() {
 	use doc && local HTML_DOCS=( "${S}"/doc/html/. )
 	einstalldocs


But I honestly can't perceive any difference to how it's currently working. Same files get created with same content.
Comment 10 Matt Turner gentoo-dev 2021-03-10 21:45:45 UTC
The root of the problem is that libdir is wrong.

% grep libdir /usr/lib64/pkgconfig/check.pc
libdir=${exec_prefix}/lib

The sed hack just worked around that, but broke non-default ABIs in the process.
Comment 11 Matt Turner gentoo-dev 2021-03-10 21:46:50 UTC
And that's because it's hardcoded in CMakeLists.txt:

  set(libdir "\${exec_prefix}/lib")
Comment 12 Matt Turner gentoo-dev 2021-03-10 22:03:50 UTC
Upstream pull request opened.
Comment 13 Larry the Git Cow gentoo-dev 2021-03-21 00:52:11 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=85035e3ff63b4153763fc5f4b234a04f979e025a

commit 85035e3ff63b4153763fc5f4b234a04f979e025a
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2021-03-21 00:49:50 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2021-03-21 00:51:57 +0000

    dev-libs/check: Fix pkgconfig file's libdir
    
    Closes: https://bugs.gentoo.org/729642
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 ...{check-0.15.2.ebuild => check-0.15.2-r1.ebuild} | 16 ++++++------
 ...-0.15.2-Fix-pkgconfig-file-s-libdir-value.patch | 30 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 8 deletions(-)
Comment 14 Larry the Git Cow gentoo-dev 2022-04-12 02:00:03 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=0ac65ddf7cff60a64730ca7c123f492fb68217a4

commit 0ac65ddf7cff60a64730ca7c123f492fb68217a4
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2021-10-28 00:38:43 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-04-12 01:59:53 +0000

    install-qa-check.d/60pkgconfig: check for not respecting libdir in pc files
    
    It's not valid to reference lib64 when installing to /usr/lib where we
    want 32-bit libraries.
    
    We want to make sure that if we're installing a pkgconfig file for a 32-bit
    variant (multilib), we make sure that the file references the right library:
    it should have e.g. /usr/lib, not /usr/lib64, or consumers trying to use
    the 32-bit library will try to link against a 64-bit library.
    
    (We also cover the opposite case: /usr/lib64 pkgconfig files referencing
    /usr/lib).
    
    Bug: https://bugs.gentoo.org/729642
    Signed-off-by: Sam James <sam@gentoo.org>

 bin/install-qa-check.d/60pkgconfig | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)