Bug 256231 - cmake INSTALL(EXPORT) files installed into /usr/share/apps instead of /usr/lib*/, breaks multilib
Summary: cmake INSTALL(EXPORT) files installed into /usr/share/apps instead of /usr/li...
Status: RESOLVED WAITINGFORINFO
Alias: None
Product: buildsystem
Classification: Developer tools
Component: KDE4 (cmake) (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Alexander Neundorf
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-06 15:26 UTC by Nathan Phillip Brink (binki)
Modified: 2018-11-28 21:32 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Phillip Brink (binki) 2010-11-06 15:26:40 UTC
Version:           4.5 (using KDE 4.5.2) 
OS:                Linux

When attempting to compile a 32-bit version of something such as libkdegames, the file INSTALL(EXPORT) files give CMake full paths to 64-bit verions of the kdelib's core libraries. For example, /usr/share/apps/cmake/modules/KDELibs4LibraryTargets.cmake references /usr/share/apps/cmake/modules/KDELibs4LibraryTargets-gentoo.cmake which contains something like:
``
# Import target "KDE4__kio" for configuration "Gentoo"
SET_PROPERTY(TARGET KDE4__kio APPEND PROPERTY IMPORTED_CONFIGURATIONS GENTOO)
SET_TARGET_PROPERTIES(KDE4__kio PROPERTIES
  IMPORTED_LINK_DEPENDENT_LIBRARIES_GENTOO "KDE4__solid"
  IMPORTED_LINK_INTERFACE_LIBRARIES_GENTOO "KDE4__kdeui;KDE4__kdecore;Qt4::QtNetwork;Qt4::QtXml;Qt4::QtGui"
  IMPORTED_LOCATION_GENTOO "/usr/lib64/libkio.so.5.5.0"
  IMPORTED_SONAME_GENTOO "libkio.so.5"
  )
''

This causes compilation failure for a 32-bit compilation of libkdegames:
``
Linking CXX shared library ../lib/libkdegames.so
cd /var/tmp/portage/kde-base/libkdegames-4.5.2/work/libkdegames-4.5.2_build/libkdegames && /usr/bin/cmake -E cmake_link_script CMakeFiles/kdegames.dir/link.txt --verbose=1
/usr/bin/x86_64-pc-linux-gnu-g++  -fPIC -O2 -pipe -march=athlon64 -g -ggdb -combine -ftree-vectorize -falign-functions=16 -falign-labels=16 -falign-jumps=16 -m32  -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -DQT_NO_EXCEPTIONS -fno-check-new -fno-common -Woverloaded-virtual -fno-threadsafe-statics -fvisibility=hidden -fvisibility-inlines-hidden -Wl,--enable-new-dtags -Wl,--fatal-warnings -Wl,--no-undefined -lc -Wl,--as-needed -Wl,-O1 -Wl,-t -Wl,--enable-new-dtags -Wl,--hash-style=gnu -shared -Wl,-soname,libkdegames.so.5 -o ../lib/libkdegames.so.5.0.0 CMakeFiles/kdegames.dir/kdegames_automoc.o CMakeFiles/kdegames.dir/digits/kgamesvgdigits.o CMakeFiles/kdegames.dir/highscore/kexthighscore_item.o CMakeFiles/kdegames.dir/highscore/kexthighscore_internal.o CMakeFiles/kdegames.dir/highscore/kexthighscore_tab.o CMakeFiles/kdegames.dir/highscore/kexthighscore_gui.o CMakeFiles/kdegames.dir/highscore/kexthighscore.o CMakeFiles/kdegames.dir/highscore/khighscore.o CMakeFiles/kdegames.dir/highscore/kscoredialog.o CMakeFiles/kdegames.dir/kgame/kgame.o CMakeFiles/kdegames.dir/kgame/kgamechat.o CMakeFiles/kdegames.dir/kgame/kgameerror.o CMakeFiles/kdegames.dir/kgame/kgameio.o CMakeFiles/kdegames.dir/kgame/kgamemessage.o CMakeFiles/kdegames.dir/kgame/kgamenetwork.o CMakeFiles/kdegames.dir/kgame/kgameprocess.o CMakeFiles/kdegames.dir/kgame/kgameproperty.o CMakeFiles/kdegames.dir/kgame/kgamepropertyhandler.o CMakeFiles/kdegames.dir/kgame/kgamesequence.o CMakeFiles/kdegames.dir/kgame/kmessageclient.o CMakeFiles/kdegames.dir/kgame/kmessageio.o CMakeFiles/kdegames.dir/kgame/kmessageserver.o CMakeFiles/kdegames.dir/kgame/kplayer.o CMakeFiles/kdegames.dir/kgame/dialogs/kgameconnectdialog.o CMakeFiles/kdegames.dir/kgame/dialogs/kgamedebugdialog.o CMakeFiles/kdegames.dir/kgame/dialogs/kgamedialog.o CMakeFiles/kdegames.dir/kgame/dialogs/kgamedialogconfig.o CMakeFiles/kdegames.dir/kgame/dialogs/kgameerrordialog.o CMakeFiles/kdegames.dir/carddeckinfo.o CMakeFiles/kdegames.dir/kcarddialog.o CMakeFiles/kdegames.dir/kchat.o CMakeFiles/kdegames.dir/kchatbase.o CMakeFiles/kdegames.dir/kchatbaseitemdelegate.o CMakeFiles/kdegames.dir/kchatbasemodel.o CMakeFiles/kdegames.dir/kchatdialog.o CMakeFiles/kdegames.dir/kgamecanvas.o CMakeFiles/kdegames.dir/kgameclock.o CMakeFiles/kdegames.dir/kgamelcd.o CMakeFiles/kdegames.dir/kgamemisc.o CMakeFiles/kdegames.dir/kgameprogress.o CMakeFiles/kdegames.dir/kgamepopupitem.o CMakeFiles/kdegames.dir/kgamesvgdocument.o CMakeFiles/kdegames.dir/kgametheme.o CMakeFiles/kdegames.dir/kgamethemeselector.o CMakeFiles/kdegames.dir/kstandardgameaction.o CMakeFiles/kdegames.dir/kgamedifficulty.o CMakeFiles/kdegames.dir/cardcache.o -L/usr/lib32/qt4 /usr/lib64/libkio.so.5.5.0 /usr/lib64/libkdeui.so.5.5.0 /usr/lib64/libkdnssd.so.4.5.0 /usr/lib64/libknewstuff3.so.4.5.0 /usr/lib32/qt4/libQtXml.so /usr/lib32/qt4/libQtNetwork.so /usr/lib64/libkio.so.5.5.0 /usr/lib32/qt4/libQtXml.so /usr/lib32/qt4/libQtNetwork.so /usr/lib64/libkdeui.so.5.5.0 /usr/lib32/qt4/libQtSvg.so /usr/lib64/libkdecore.so.5.5.0 /usr/lib32/qt4/libQtCore.so -lpthread /usr/lib32/qt4/libQtDBus.so /usr/lib32/qt4/libQtGui.so -Wl,-rpath,/usr/lib32/qt4:
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/../../../../x86_64-pc-linux-gnu/bin/ld: mode elf_i386
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/../../../../lib32/crti.o
/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.3/32/crtbeginS.o
CMakeFiles/kdegames.dir/kdegames_automoc.o
CMakeFiles/kdegames.dir/digits/kgamesvgdigits.o
CMakeFiles/kdegames.dir/highscore/kexthighscore_item.o
CMakeFiles/kdegames.dir/highscore/kexthighscore_internal.o
CMakeFiles/kdegames.dir/highscore/kexthighscore_tab.o
''
...
``
CMakeFiles/kdegames.dir/kstandardgameaction.o
CMakeFiles/kdegames.dir/kgamedifficulty.o
CMakeFiles/kdegames.dir/cardcache.o
/usr/lib64/libkio.so.5.5.0
/usr/lib64/libkio.so.5.5.0: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [lib/libkdegames.so.5.0.0] Error 1
make[2]: Leaving directory `/var/tmp/portage/kde-base/libkdegames-4.5.2/work/libkdegames-4.5.2_build'
make[1]: *** [libkdegames/CMakeFiles/kdegames.dir/all] Error 2
make[1]: Leaving directory `/var/tmp/portage/kde-base/libkdegames-4.5.2/work/libkdegames-4.5.2_build'
make: *** [all] Error 2
''

If kdelibs installed the EXPORT files into $(libdir) as almost suggested by the example at http://cmake.org/cmake/help/cmake-2-8-docs.html#command:install , then I expect I would be able to compile a 32-bit version of libkdegames with no problem. Another example of using $(libdir) for storing compile-time metadata is pkg-config.


Reproducible: Always

Steps to Reproduce:
1. Set up your system to use a multilib-nosymlink style libdir structure. In this format /lib is _not_ a symlink to /lib64 nor to /lib32; /lib32, /lib, and /lib64 are distinct directories. The same paradigm applies to /usr/lib*.

Why must /lib not be a symlink to /lib64? Because this can hide problems where an application's ./configure script should be pulling data from /lib32 but it instead pulls the data from /lib (which is a symlink to /lib64). This makes debugging a multilib-related compilation failure harder; the multilib-nosymlink setup is much more straight-forward to debug.

2. Install both the 32-bit and 64-bit versions of =kde-base/kdelibs-4.5.2 using portage-multilib (https://github.com/sjnewbury/multilib-overlay/blob/portage-multilib/doc/portage-multilib-instructions). portage-multilib will compile every package twice, once with normal CFLAGS and again after inserting -m32 into CFLAGS and CXXFLAGS to produce 32-bit binaries. It will also correctly set --with-libdir to /usr/lib64 or /usr/lib32 based on which bitiness is being used. See also http://public.kitware.com/Bug/view.php?id=11260 for a patch which fixes cmake's ability to find automoc's .cmake files (which are properly installed into $(libdir)).

3. Attempt to install both 32-bit and 64-bit versions of =libkdegames-4.5.2 .

(even though I am using the standard ./configure-style terminology to describe how a 32-bit compilation is achieved, I recognize that kde uses CMake which has more complicated and harder-to-remember methods/conventions for doing the same thing. Unfortunately, CMake's authors disagree with some of these conventions: http://public.kitware.com/Bug/view.php?id=10287 )

Actual Results:  
The installation of =libkdegames-4.5.2 fails with the error shown in description.

Expected Results:  
Instead of specifying a full path to /usr/lib64/libkio.so.5.5.0, the Makefile should just use -lkio so that the linker can find /usr/lib32/libkio.so (which is in its searchpath).
Comment 1 Christoph Feck 2010-11-06 15:42:04 UTC
Not sure I understand the issue, did you define CMAKE_INSTALL_PREFIX?
Comment 2 Nathan Phillip Brink (binki) 2010-11-06 15:45:36 UTC
Gentoo's portage properly sets CMAKE_INSTALL_PREFIX:
ohnopublishing portage # grep -e CMAKE_INSTALL_PREFIX /var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2_build/CMakeCache.txt /var/tmp/portage/kde-base/libkdegam
es-4.5.2/work/libkdegames-4.5.2_build/CMakeCache.txt 
/var/tmp/portage/kde-base/kdelibs-4.5.2/work/kdelibs-4.5.2_build/CMakeCache.txt:CMAKE_INSTALL_PREFIX:PATH=/usr
/var/tmp/portage/kde-base/libkdegames-4.5.2/work/libkdegames-4.5.2_build/CMakeCache.txt:CMAKE_INSTALL_PREFIX:PATH=/usr
Comment 3 Nathan Phillip Brink (binki) 2010-11-06 15:55:36 UTC
If I understand kdelibs's CMakeLists.txt file, I think I'm essentially asking for the second of the two lines to be uncommented (although I think the line may have to be modified -- I'm not sure why ${CMAKE_CURRENT_BINARY_DIR} is being referenced or if that half of the line is supposed to work):

# the following will be the correct locations once cmake has the improved FIND_PACKAGE()
# install( FILES ${CMAKE_CURRENT_BINARY_DIR}/KDELibsDependencies.cmake DESTINATION ${PLUGIN_INSTALL_DIR}/cmake RENAME KDE4Config.cmake)
Comment 4 Konstantin 2011-02-08 04:18:55 UTC
This also happens for me with polkit-kde-agent-0.99.0. The second 32bit pass results in a failure:


-- <<< Gentoo configuration >>>
Build type      Gentoo
Install path    /usr
Compiler flags:
C               -march=nocona -O2 -pipe -m32  -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common
C++             -march=nocona -O2 -pipe -m32  -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -DQT_NO_EXCEPTIONS -fno-check-new -fno-common -Woverloaded-virtual -fno-threadsafe-statics -fvisibility=hidden -fvisibility-inlines-hidden
Linker flags:
Executable      -Wl,--enable-new-dtags -Wl,-O1 -Wl,--as-needed -m32
Module          -Wl,--enable-new-dtags -Wl,--fatal-warnings -Wl,--no-undefined -lc -Wl,-O1 -Wl,--as-needed -m32
Shared          -Wl,--enable-new-dtags -Wl,--fatal-warnings -Wl,--no-undefined -lc -Wl,-O1 -Wl,--as-needed -m32

[...]

Linking CXX executable polkit-kde-authentication-agent-1
/usr/lib64/libkdeui.so.5.5.0: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make[2]: *** [polkit-kde-authentication-agent-1] Error 1
make[1]: *** [CMakeFiles/polkit-kde-authentication-agent-1.dir/all] Error 2
make: *** [all] Error 2



Note that the linker tries to link against an so in /usr/lib64/ which of course is doomed.
I'd happily run tests, apply patches or provide more information if needed.
Comment 5 salamanderrake 2013-05-21 13:06:28 UTC
This bug is still present on gentoo systems with multilb portage.
Comment 6 Andrew Crouthamel 2018-11-10 03:14:27 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 7 Andrew Crouthamel 2018-11-20 04:03:01 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 8 Konstantin 2018-11-28 21:32:51 UTC
I think this bug can be closed. I didn't re-test it, as the default way of doing multilib in Gentoo changed since this bug was reported and multilib-portage (that was never default) is not necessary anymore for most use-cases.

The multilib-portage project is still alive though, as it seems: https://github.com/gentoo-mirror/multilib-portage