Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 753581 - Profile 17.0 -> 17.1 upgrade: cmake and cmake-based ebuilds: wrong library search path
Summary: Profile 17.0 -> 17.1 upgrade: cmake and cmake-based ebuilds: wrong library se...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo KDE team
URL:
Whiteboard:
Keywords:
: 753689 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-11-08 17:10 UTC by Vasily Pupkin
Modified: 2023-03-07 06:54 UTC (History)
4 users (show)

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


Attachments
portage/dev-util/cmake-3.18.4/temp/environment (environment,103.18 KB, text/plain)
2020-11-08 17:12 UTC, Vasily Pupkin
Details
emerge --info (emerge--info,7.19 KB, text/plain)
2020-11-08 17:13 UTC, Vasily Pupkin
Details
CMakeCache.txt (CMakeCache.txt,36.66 KB, text/plain)
2020-11-08 17:17 UTC, Vasily Pupkin
Details
cmake called manually find --debug-find (log-cmake-debug-find-system-cmake.txt,93.69 KB, text/plain)
2020-11-09 09:19 UTC, Vasily Pupkin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vasily Pupkin 2020-11-08 17:10:01 UTC
After following instructions from 2019-06-05-amd64-17-1-profiles-are-now-stable I stuck at step 11. 

Initial the problem was with dev-util/cmocka :

[2/3] : && /usr/bin/x86_64-pc-linux-gnu-gcc -fPIC -O2 -march=native -pipe -ftree-vectorize -flto -fuse-linker-plugin -mfpmath=sse  -Wl,-O1 -Wl,--sort-common -flto -fuse-linker-plugin -shared -Wl,-soname,libcmocka.so.0 -o src/libcmocka.so.0.7.0 src/CMakeFiles/cmocka.dir/cmocka.c.o  /usr/lib/librt.so && :
FAILED: src/libcmocka.so.0.7.0 
: && /usr/bin/x86_64-pc-linux-gnu-gcc -fPIC -O2 -march=native -pipe -ftree-vectorize -flto -fuse-linker-plugin -mfpmath=sse  -Wl,-O1 -Wl,--sort-common -flto -fuse-linker-plugin -shared -Wl,-soname,libcmocka.so.0 -o src/libcmocka.so.0.7.0 src/CMakeFiles/cmocka.dir/cmocka.c.o  /usr/lib/librt.so && :
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/librt.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

It's clear this happens because used librt is 32bits instead of /usr/lib64/librt.so

tachi / # file -L /usr/lib64/librt.so
/usr/lib64/librt.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, for GNU/Linux 3.2.0, stripped
tachi / # file -L /usr/lib/librt.so
/usr/lib/librt.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, for GNU/Linux 3.2.0, stripped
tachi / # 


Just to be sure I rebuilt bintuils and glibc once again, then tried to rebuild cmake (just in case). And with cmake I got very similar story:

[ 83%] Linking CXX executable ../bin/cmake
cd /tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4_build/Source && /usr/bin/cmake -E cmake_link_script CMakeFiles/cmake.dir/link.txt --verbose=1
/usr/bin/x86_64-pc-linux-gnu-g++ -O2 -march=native -pipe -ftree-vectorize -flto -fuse-linker-plugin -mfpmath=sse -Wl,-O1 -Wl,--sort-common -flto -fuse-linker-plugin CMakeFiles/cmake.dir/cmakemain.cxx.o CMakeFiles/cmake.dir/cmcmd.cxx.o -o ../bin/cmake  libCMakeLib.a libCMakeServerLib.a libCMakeLib.a kwsys/libcmsys.a -ldl ../Utilities/std/libcmstd.a /usr/lib/libexpat.so /usr/lib/libz.so /usr/lib/libarchive.so /usr/lib64/libcurl.so /usr/lib64/libjsoncpp.so /usr/lib64/libuv.so /usr/lib64/librhash.so -lpthread 
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libexpat.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status


It's interesting, that some deps are correct and some are not:

# grep /usr/lib CMakeCache.txt 
CURL_LIBRARY_RELEASE:FILEPATH=/usr/lib64/libcurl.so
CURSES_CURSES_LIBRARY:FILEPATH=/usr/lib/libcurses.so
CURSES_EXTRA_LIBRARY:FILEPATH=/usr/lib/libtinfo.so
CURSES_FORM_LIBRARY:FILEPATH=/usr/lib/libform.so
CURSES_NCURSES_LIBRARY:FILEPATH=/usr/lib/libncurses.so
EXPAT_LIBRARY:FILEPATH=/usr/lib/libexpat.so
JsonCpp_LIBRARY:FILEPATH=/usr/lib64/libjsoncpp.so
LibArchive_LIBRARY:FILEPATH=/usr/lib/libarchive.so
LibRHash_LIBRARY:FILEPATH=/usr/lib64/librhash.so
LibUV_LIBRARY:FILEPATH=/usr/lib64/libuv.so
ZLIB_LIBRARY_RELEASE:FILEPATH=/usr/lib/libz.so
pkgcfg_lib_NCURSES_ncurses:FILEPATH=/usr/lib/libncurses.so
pkgcfg_lib_NCURSES_tinfo:FILEPATH=/usr/lib/libtinfo.so
pkgcfg_lib_PC_CURL_curl:FILEPATH=/usr/lib64/libcurl.so
pkgcfg_lib_PC_EXPAT_expat:FILEPATH=/usr/lib/libexpat.so
//Have library /usr/lib/libcurses.so
//Have library /usr/lib/libncurses.so
//Have library /usr/lib/libncurses.so
FIND_PACKAGE_MESSAGE_DETAILS_CURL:INTERNAL=[/usr/lib64/libcurl.so][/usr/include][c ][v7.73.0()]
FIND_PACKAGE_MESSAGE_DETAILS_Curses:INTERNAL=[/usr/lib/libncurses.so][/usr/include][v()]
FIND_PACKAGE_MESSAGE_DETAILS_EXPAT:INTERNAL=[/usr/lib/libexpat.so][/usr/include][v2.2.10()]
FIND_PACKAGE_MESSAGE_DETAILS_JsonCpp:INTERNAL=[/usr/lib64/libjsoncpp.so][/usr/include/jsoncpp][v1.9.4(1.4.1)]
FIND_PACKAGE_MESSAGE_DETAILS_LibArchive:INTERNAL=[/usr/lib/libarchive.so][/usr/include][v3.4.3(3.3.3)]
FIND_PACKAGE_MESSAGE_DETAILS_LibRHash:INTERNAL=[/usr/lib64/librhash.so][/usr/include][v()]
FIND_PACKAGE_MESSAGE_DETAILS_LibUV:INTERNAL=[/usr/lib64/libuv.so][/usr/include][v1.40.0(1.10.0)]
FIND_PACKAGE_MESSAGE_DETAILS_ZLIB:INTERNAL=[/usr/lib/libz.so][/usr/include][v1.2.11()]
NCURSES_LIBDIR:INTERNAL=/usr/lib64
PC_CURL_LIBDIR:INTERNAL=/usr/lib64
PC_EXPAT_LIBDIR:INTERNAL=/usr/lib64

After rebuilding libz, libarchive and expat nothing changed. First idea was that there is some crap in pkgconfig,
but looks like it's not that:

# grep -e "/lib$" -e "/lib " /usr/lib64/pkgconfig/*
/usr/lib64/pkgconfig/check.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/gdal.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/libbcc.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/libcork.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/libmosquitto.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/libmosquittopp.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/librtlsdr.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/libtommath.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/miniupnpc.pc:libdir=${exec_prefix}/lib
/usr/lib64/pkgconfig/monodoc.pc:libdir=/usr/lib

So, there is something wrong in the way cmake searches deps. Maybe I overlooked something reading the instruction?

Reproducible: Always
Comment 1 Vasily Pupkin 2020-11-08 17:12:23 UTC
Created attachment 670478 [details]
portage/dev-util/cmake-3.18.4/temp/environment
Comment 2 Vasily Pupkin 2020-11-08 17:13:17 UTC
Created attachment 670481 [details]
emerge --info
Comment 3 Vasily Pupkin 2020-11-08 17:17:21 UTC
Created attachment 670484 [details]
CMakeCache.txt
Comment 4 Vasily Pupkin 2020-11-09 08:48:23 UTC
Cmake can be built manually at this system (using ./bootstrap && gmake). So very likely something wrong with portage
Comment 5 Vasily Pupkin 2020-11-09 09:19:00 UTC
Created attachment 670562 [details]
cmake called manually find --debug-find

Something wrong with search folders. Cmake was called with

cmake --debug-find -C /tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4_build/gentoo_common_config.cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_USE_SYSTEM_LIBRARIES=ON -DCMAKE_DOC_DIR=/share/doc/cmake-3.18.4 -DCMAKE_MAN_DIR=/share/man -DCMAKE_DATA_DIR=/share/cmake -DSPHINX_MAN=no -DSPHINX_HTML=no -DBUILD_CursesDialog=yes -DBUILD_TESTING=no -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_TOOLCHAIN_FILE=/tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4_build/gentoo_toolchain.cmake  /tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4-C /tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4_build/gentoo_common_config.cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_USE_SYSTEM_LIBRARIES=ON -DCMAKE_DOC_DIR=/share/doc/cmake-3.18.4 -DCMAKE_MAN_DIR=/share/man -DCMAKE_DATA_DIR=/share/cmake -DSPHINX_MAN=no -DSPHINX_HTML=no -DBUILD_CursesDialog=yes -DBUILD_TESTING=no -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_TOOLCHAIN_FILE=/tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4_build/gentoo_toolchain.cmake  /tmp/portage/dev-util/cmake-3.18.4/work/cmake-3.18.4  2>&1 | tee log.txt
Comment 6 Vasily Pupkin 2020-11-09 11:00:54 UTC
For this case I placed PATH=/usr/lib64:/lib64:$PATH for cmake into eclass..

PATH=/lib${libdir/lib}:/usr/lib${libdir/lib}:$PATH "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"

This is obviously horrible, but still better than having completely broken cmake.
Comment 7 Vasily Pupkin 2020-11-09 11:13:56 UTC
It turns out, that 

LIB_SUFFIX -> CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX

in gentoo_common_config.cmake

fixes situation as well.
Comment 8 Duncan 2020-11-09 12:12:58 UTC
Title/summary: Please clarify that this is a /profile-/upgrade 17.0 -> 17.1 bug, not a some-package-17.x version upgrade bug.  Maybe:

Profile 17.1 upgrade: "error adding symbols: file in wrong format" for some dependencies

Or "Profile 17.0 -> 17.1 upgrade:" if you want to keep the profile you upgraded from in there as well, but IMO the "profile" bit is more critical info than the 17.0 upgraded-from, and after that it's a question of title conciseness vs upgrade-from info, your call.

(YMMV but it would have been useful here.  Given the lack of domain specifier in the title and as a reasonably proactive ~arch user that switched to 17.1 profiles long ago, I'd guess three years ago in 2017 given the 17.x, I wasn't thinking about profiles, leaving me confused as to what package version 17.x you were referring to.)
Comment 9 Andreas Sturmlechner gentoo-dev 2020-11-10 15:47:35 UTC
*** Bug 753689 has been marked as a duplicate of this bug. ***
Comment 10 Andreas Sturmlechner gentoo-dev 2020-11-10 15:58:01 UTC
(In reply to Alexey Shevchuck from comment #0)
> After rebuilding libz, libarchive and expat nothing changed. First idea was
> that there is some crap in pkgconfig,
> but looks like it's not that:
> 
> # grep -e "/lib$" -e "/lib " /usr/lib64/pkgconfig/*
> /usr/lib64/pkgconfig/check.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/gdal.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/libbcc.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/libcork.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/libmosquitto.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/libmosquittopp.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/librtlsdr.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/libtommath.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/miniupnpc.pc:libdir=${exec_prefix}/lib
> /usr/lib64/pkgconfig/monodoc.pc:libdir=/usr/lib

But all those paths are wrong.
Comment 11 Vasily Pupkin 2020-11-10 16:10:44 UTC
Sure, but they are not related to this exact case
Comment 12 Andreas Sturmlechner gentoo-dev 2020-11-10 16:43:03 UTC
(In reply to Alexey Shevchuck from comment #0)
> It's interesting, that some deps are correct and some are not:
> 
> # grep /usr/lib CMakeCache.txt 
> ...
Here's the result on my 17.1 system:

CURL_LIBRARY_RELEASE:FILEPATH=/usr/lib64/libcurl.so
CURSES_CURSES_LIBRARY:FILEPATH=/usr/lib64/libcurses.so
CURSES_EXTRA_LIBRARY:FILEPATH=/usr/lib64/libtinfo.so
CURSES_FORM_LIBRARY:FILEPATH=/usr/lib64/libform.so
CURSES_NCURSES_LIBRARY:FILEPATH=/usr/lib64/libncurses.so
EXPAT_LIBRARY:FILEPATH=/usr/lib64/libexpat.so
JsonCpp_LIBRARY:FILEPATH=/usr/lib64/libjsoncpp.so
LibArchive_LIBRARY:FILEPATH=/usr/lib64/libarchive.so
LibRHash_LIBRARY:FILEPATH=/usr/lib64/librhash.so
LibUV_LIBRARY:FILEPATH=/usr/lib64/libuv.so
ZLIB_LIBRARY_RELEASE:FILEPATH=/usr/lib64/libz.so
pkgcfg_lib_NCURSES_ncurses:FILEPATH=/usr/lib64/libncurses.so
pkgcfg_lib_NCURSES_tinfo:FILEPATH=/usr/lib64/libtinfo.so
pkgcfg_lib_PC_CURL_curl:FILEPATH=/usr/lib64/libcurl.so
pkgcfg_lib_PC_EXPAT_expat:FILEPATH=/usr/lib64/libexpat.so
//Have library /usr/lib64/libcurses.so
//Have library /usr/lib64/libncurses.so
FIND_PACKAGE_MESSAGE_DETAILS_CURL:INTERNAL=[/usr/lib64/libcurl.so][/usr/include][c ][v7.73.0()]
FIND_PACKAGE_MESSAGE_DETAILS_Curses:INTERNAL=[/usr/lib64/libncurses.so][/usr/include][v()]
FIND_PACKAGE_MESSAGE_DETAILS_EXPAT:INTERNAL=[/usr/lib64/libexpat.so][/usr/include][v2.2.10()]
FIND_PACKAGE_MESSAGE_DETAILS_JsonCpp:INTERNAL=[/usr/lib64/libjsoncpp.so][/usr/include/jsoncpp][v1.9.3(1.4.1)]
FIND_PACKAGE_MESSAGE_DETAILS_LibArchive:INTERNAL=[/usr/lib64/libarchive.so][/usr/include][v3.4.3(3.3.3)]
FIND_PACKAGE_MESSAGE_DETAILS_LibRHash:INTERNAL=[/usr/lib64/librhash.so][/usr/include][v()]
FIND_PACKAGE_MESSAGE_DETAILS_LibUV:INTERNAL=[/usr/lib64/libuv.so][/usr/include][v1.40.0(1.10.0)]
FIND_PACKAGE_MESSAGE_DETAILS_ZLIB:INTERNAL=[/usr/lib64/libz.so][/usr/include][v1.2.11()]
NCURSES_LIBDIR:INTERNAL=/usr/lib64
PC_CURL_LIBDIR:INTERNAL=/usr/lib64
PC_EXPAT_LIBDIR:INTERNAL=/usr/lib64
prefix_result:INTERNAL=/usr/lib64

So all is well, and you simply need to rebuild packages with an incorrect path in /usr/lib.
Comment 13 Vasily Pupkin 2020-11-10 16:57:11 UTC
Well, as I wrote, I completed rebuild dependencies before writing this bug.

Also, CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX works for me.

What version of cmake do you have? I have 3.18.4. Do you have 32 bit versions of libexpat, zlib etc?
Comment 14 Andreas Sturmlechner gentoo-dev 2020-11-10 18:41:33 UTC
(In reply to Alexey Shevchuck from comment #13)
> What version of cmake do you have? I have 3.18.4. Do you have 32 bit
> versions of libexpat, zlib etc?

Yes to all of that.
Comment 15 Vasily Pupkin 2020-11-10 18:52:27 UTC
And you have LIB_SUFFIX (not CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX) in your gentoo_common_config.cmake which is generated by eclass? 

Then I don't get how this works. In cmake sources there is CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX.

Source/cmFindLibraryCommand.cxx:53:

// add custom lib<qual> paths instead of using fixed lib32, lib64 or
// libx32
if (const char* customLib = this->Makefile->GetDefinition(
       "CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX")) {
  this->AddArchitecturePaths(customLib);
}
Comment 16 Vasily Pupkin 2020-11-11 16:48:48 UTC
Okay. I found out the problem, thanks to strace. it's a bit ... weird.

Simply saying.. never ever create /etc/debian_version in gentoo.

x_x
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-11-11 16:50:19 UTC
(In reply to Alexey Shevchuck from comment #16)
> Okay. I found out the problem, thanks to strace. it's a bit ... weird.
> 
> Simply saying.. never ever create /etc/debian_version in gentoo.
> 
> x_x

Similar issues arise with /etc/redhat-release; build systems make assumptions based on it. Don't do that!
Comment 18 Andreas Sturmlechner gentoo-dev 2020-11-11 16:51:05 UTC
You can follow bug 733480 for that; I haven't had time to follow up upstream about it.