Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 753791 - media-libs/libsdl2: sdl2-config-version.cmake hardcodes /usr/lib/ (breaks Profile 17.0 -> 17.1 upgrade)
Summary: media-libs/libsdl2: sdl2-config-version.cmake hardcodes /usr/lib/ (breaks Pro...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-10 06:37 UTC by Vasily Pupkin
Modified: 2020-11-11 16:52 UTC (History)
0 users

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


Attachments
Patched sdl2-config-version.cmake which works for me (sdl2-config-version.cmake,278 bytes, text/plain)
2020-11-10 06:38 UTC, Vasily Pupkin
Details
faudio-20.09: build.log (build-abi_x86_64.amd64.log,20.77 KB, text/x-log)
2020-11-10 16:26 UTC, Vasily Pupkin
Details
faudio-20.09: CMackeCache.txt (CMakeCache.txt,28.08 KB, text/plain)
2020-11-10 16:27 UTC, Vasily Pupkin
Details
faudio-20.09: build.make (build.make,33.03 KB, text/plain)
2020-11-10 16:27 UTC, Vasily Pupkin
Details
cmake --debug-find output (log.txt.2,39.40 KB, text/plain)
2020-11-10 20:09 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-10 06:37:45 UTC
SDL2 installs own cmake configuration to /usr/lib/cmake/SDL2/sdl2-config.cmake

There is an instruction to specify libSDL2.so library directly by path, rather then by -lSDL2. 

  add_library(SDL2::SDL2 SHARED IMPORTED)
  set_target_properties(SDL2::SDL2 PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "/usr/lib/libSDL2.so"
    INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}")

Because of that, depended multilib builds will fail with
/usr/lib/libSDL2.so: error adding symbols: file in wrong format

For example faudio:
[100%] Linking C shared library libFAudio.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/FAudio.dir/link.txt --verbose=1
/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,libFAudio.so.0 -o libFAudio.so.0.20.09 CMakeFiles/FAudio.dir/src/F3DAudio.c.o CMakeFiles/FAudio.dir/src/FACT3D.c.o CMakeFiles/FAudio.dir/src/FACT.c.o CMakeFiles/FAudio.dir/src/FACT_internal.c.o CMakeFiles/FAudio.dir/src/FAPOBase.c.o CMakeFiles/FAudio.dir/src/FAPOFX.c.o CMakeFiles/FAudio.dir/src/FAPOFX_echo.c.o CMakeFiles/FAudio.dir/src/FAPOFX_eq.c.o CMakeFiles/FAudio.dir/src/FAPOFX_masteringlimiter.c.o CMakeFiles/FAudio.dir/src/FAPOFX_reverb.c.o CMakeFiles/FAudio.dir/src/FAudio.c.o CMakeFiles/FAudio.dir/src/FAudioFX_reverb.c.o CMakeFiles/FAudio.dir/src/FAudioFX_volumemeter.c.o CMakeFiles/FAudio.dir/src/FAudio_internal.c.o CMakeFiles/FAudio.dir/src/FAudio_internal_simd.c.o CMakeFiles/FAudio.dir/src/FAudio_operationset.c.o CMakeFiles/FAudio.dir/src/FAudio_platform_sdl2.c.o CMakeFiles/FAudio.dir/src/XNA_Song.c.o CMakeFiles/FAudio.dir/src/FAudio_gstreamer.c.o  /usr/lib/libSDL2.so -lgstaudio-1.0 -lgstapp-1.0 -lgstbase-1.0 -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 
/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libSDL2.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

To fix the situation it's enough to patch this file with ${CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX} like this:

  set_target_properties(SDL2::SDL2 PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
    IMPORTED_LINK_INTERFACE_LANGUAGES "C"
    IMPORTED_LOCATION "/usr/lib${CMAKE_FIND_LIBRARY_CUSTOM_LIB_SUFFIX}/libSDL2.so"
    INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}")


Reproducible: Always
Comment 1 Vasily Pupkin 2020-11-10 06:38:47 UTC
Created attachment 670661 [details]
Patched sdl2-config-version.cmake which works for me
Comment 2 Andreas Sturmlechner gentoo-dev 2020-11-10 15:29:01 UTC
Please convince me this is no duplicate of bug 644538.
Comment 3 Andreas Sturmlechner gentoo-dev 2020-11-10 15:45:46 UTC
/usr/lib/cmake
/usr/lib/cmake/SDL2
/usr/lib/cmake/SDL2/sdl2-config-version.cmake
/usr/lib/cmake/SDL2/sdl2-config.cmake
/usr/lib64/cmake
/usr/lib64/cmake/SDL2
/usr/lib64/cmake/SDL2/sdl2-config-version.cmake
/usr/lib64/cmake/SDL2/sdl2-config.cmake

If /usr/lib/ is hardcoded in /usr/lib/, and /usr/lib64/ is hardcoded in /usr/lib64/ that's fine, and only the (known) one-time breakage through the profile change exists and is fixed by rebuild of the package.
Comment 4 Vasily Pupkin 2020-11-10 16:21:24 UTC
Well, I had rebuild SDL2 before I created this bug. Or you mean some other package?

I really have these files:

qlist media-libs/libsdl2 | grep cmake        
/usr/share/doc/libsdl2-2.0.12-r2/README-cmake.md.bz2
/usr/lib/cmake/SDL2/sdl2-config.cmake
/usr/lib/cmake/SDL2/sdl2-config-version.cmake
/usr/lib64/cmake/SDL2/sdl2-config.cmake
/usr/lib64/cmake/SDL2/sdl2-config-version.cmake

Still, there was an issue at least with faudio.
Comment 5 Vasily Pupkin 2020-11-10 16:26:45 UTC
Created attachment 670733 [details]
faudio-20.09: build.log
Comment 6 Vasily Pupkin 2020-11-10 16:27:08 UTC
Created attachment 670736 [details]
faudio-20.09: CMackeCache.txt
Comment 7 Vasily Pupkin 2020-11-10 16:27:30 UTC
Created attachment 670739 [details]
faudio-20.09: build.make
Comment 8 Vasily Pupkin 2020-11-10 20:08:40 UTC
Well, according to --debug-find cmake tries defs from /usr/lib/cmake, not from /usr/lib64/cmake.
Comment 9 Vasily Pupkin 2020-11-10 20:09:35 UTC
Created attachment 670802 [details]
cmake --debug-find output

cmake --debug-find  -C /tmp/portage/app-emulation/faudio-20.09/work/FAudio-20.09-abi_x86_64.amd64/gentoo_common_config.cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_INSTALL_INCLUDEDIR=include/FAudio -DCMAKE_INSTALL_LIBDIR=lib64 -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DFORCE_ENABLE_DEBUGCONFIGURATION=OFF -DBUILD_TESTS=OFF -DBUILD_UTILS=OFF -DDUMP_VOICES=ON -DGSTREAMER=ON -DXNASONG=OFF -DCMAKE_BUILD_TYPE=Gentoo -DCMAKE_TOOLCHAIN_FILE=/tmp/portage/app-emulation/faudio-20.09/work/FAudio-20.09-abi_x86_64.amd64/gentoo_toolchain.cmake  /tmp/portage/app-emulation/faudio-20.09/work/FAudio-20.09 2>log.txt.2 1>log.txt.1
Comment 10 Andreas Sturmlechner gentoo-dev 2020-11-11 14:52:11 UTC
Please make sure your /usr/lib is no symlink to /usr/lib64.

(In reply to Alexey Shevchuck from comment #0)
> SDL2 installs own cmake configuration to
> /usr/lib/cmake/SDL2/sdl2-config.cmake
> 
> There is an instruction to specify libSDL2.so library directly by path,
> rather then by -lSDL2. 
> 
>   add_library(SDL2::SDL2 SHARED IMPORTED)
>   set_target_properties(SDL2::SDL2 PROPERTIES
>     INTERFACE_INCLUDE_DIRECTORIES "${prefix}/include/SDL2"
>     IMPORTED_LINK_INTERFACE_LANGUAGES "C"
>     IMPORTED_LOCATION "/usr/lib/libSDL2.so"
>     INTERFACE_LINK_LIBRARIES "${SDL2_EXTRA_LINK_FLAGS}")
Again, coming back to your initial description, this is completely fine and what you should have been looking at ever only was the cmake files below /usr/lib64. 

If you meddled with cmake and -configs as described here and in other bugs I can only assume you broke your system.
Comment 11 Vasily Pupkin 2020-11-11 14:55:44 UTC
Ok. What can be broken and how to check that?
Comment 12 Vasily Pupkin 2020-11-11 16:22:57 UTC
Well, this is certainly not an faudio issue. I unpacked fresh gentoo profile, and yes, it's fine there. The problem is my cmake for some strange reason starts to find packages (and everything) from /usr/lib, not /usr/lib64.