Bug#615742: binutils gold fix for libdrumstick

Pedro Lopez-Cabanillas pedro.lopez.cabanillas at gmail.com
Tue Mar 1 06:06:18 UTC 2011


Hi, 

Just for the record: in Drumstick's source tree, directory "utils/vpiano", the file CMakeLists.txt has the following lines defining the list of libraries that need to be linked to that program:

TARGET_LINK_LIBRARIES(drumstick-vpiano
    ${QT_LIBRARIES} 
    ${ALSA_LIBS} 
    ${QT_X11_X11_LIBRARY}
    drumstick-common
    drumstick-alsa
)

On Tuesday 01 March 2011, Modestas Vainius wrote:
> Hello,
> 
> On antradienis 01 Kovas 2011 01:06:22 Pedro Lopez-Cabanillas wrote:
> > I've wrote Drumstick, and I know for sure that the target "vpiano" uses
> > QT_X11_X11_LIBRARY for linking. The bug report says that when linking this
> > target in Debian, it fails saying that -lX11 is required.
> > 
> > I suspect that there may be a problem in Debian around this matter. It
> > works fine in some other distros.
> 
> Nop, you misunderstood the bug a bit. It does link on Debian or 0.5.0-1 would 
> not be in Debian testing. gold linker enables --no-add-needed by default and 
> that's typically the reason for packages to fail linking with it. Now ubuntu 
> enabled --as-needed by default and gcc maintainer is pushing this to debian 
> proper too.

The same policy was introduced in Fedora some time ago, and probably in other distros as well. Anyway, I understood the problem the first time, and this is how I've tested the build system here (running openSUSE 11.3)

$ cmake --version
cmake version 2.8.1

$ cmake .. -DCMAKE_EXE_LINKER_FLAGS=-Wl,--no-add-needed

The build process works fine here using this flag. This is the relevant part of the log:

Linking CXX executable ../../bin/drumstick-vpiano
cd /home/pedro/Projects/drumstick/build/utils/vpiano && /usr/bin/cmake -E cmake_link_script CMakeFiles/drumstick-vpiano.dir/link.txt --verbose=1
/usr/bin/c++    -fexceptions -UQT_NO_EXCEPTIONS -fvisibility=hidden -fvisibility-inlines-hidden  -Wl,--no-add-needed -Wl,--as-needed CMakeFiles/drumstick-vpiano.dir/moc_pianoscene.cxx.o CMakeFiles/drumstick-vpiano.dir/moc_pianokeybd.cxx.o CMakeFiles/drumstick-vpiano.dir/moc_vpianoabout.cxx.o CMakeFiles/drumstick-vpiano.dir/moc_connections.cxx.o CMakeFiles/drumstick-vpiano.dir/moc_preferences.cxx.o CMakeFiles/drumstick-vpiano.dir/moc_vpiano.cxx.o CMakeFiles/drumstick-vpiano.dir/pianokey.cpp.o CMakeFiles/drumstick-vpiano.dir/pianoscene.cpp.o CMakeFiles/drumstick-vpiano.dir/pianokeybd.cpp.o CMakeFiles/drumstick-vpiano.dir/keylabel.cpp.o CMakeFiles/drumstick-vpiano.dir/rawkeybdapp.cpp.o CMakeFiles/drumstick-vpiano.dir/vpianoabout.cpp.o CMakeFiles/drumstick-vpiano.dir/connections.cpp.o CMakeFiles/drumstick-vpiano.dir/preferences.cpp.o CMakeFiles/drumstick-vpiano.dir/vpiano.cpp.o CMakeFiles/drumstick-vpiano.dir/vpianomain.cpp.o CMakeFiles/drumstick-vpiano.dir/qrc_pianokeybd.cxx.o  -o ../../bin/drumstick-vpiano -rdynamic -L/home/pedro/Projects/drumstick/build/lib -lQtSvg -lQtGui -lQtDBus -lQtXml -lQtCore -lQtSvg -lQtGui -lQtDBus -lQtXml -lQtCore -lasound -lX11 ../../lib/libdrumstick-common.a ../../lib/libdrumstick-alsa.so.0.5.1 -lQtSvg -lQtGui -lQtDBus -lQtXml -lQtCore -lQtSvg -lQtGui -lQtDBus -lQtXml -lQtCore -lasound -Wl,-rpath,/home/pedro/Projects/drumstick/build/lib 
make[3]: Leaving directory `/home/pedro/Projects/drumstick/build'
/usr/bin/cmake -E cmake_progress_report /home/pedro/Projects/drumstick/build/CMakeFiles  68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
[100%] Built target drumstick-vpiano

> So yes, the reason it's failing is that QT_X11_X11_LIBRARY is undefined and --
> no-add-needed no longer looks the library up recursively. The code which sets 
> this variable was removed in cmake 2.8.1 by [1]. QT_X11_X11_LIBRARY falls out 
> of FindQt4.cmake scope.

You are wrong assuming that the variable QT_X11_X11_LIBRARY is deprecated in CMake 2.8.1, or it is not available anymore. The CMake macros were reorganized, and now this variable is set in Qt4ConfigDependentSettings.cmake [2] (lines 259-271) which is included from FindQt4.cmake [3], line 1035, and it is also documented [4]. 

The attached CMakeLists.txt test file should work as expected. Here is the output in my development machine:
$ cmake .
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for Q_WS_X11
-- Looking for Q_WS_X11 - found
-- Looking for Q_WS_WIN
-- Looking for Q_WS_WIN - not found.
-- Looking for Q_WS_QWS
-- Looking for Q_WS_QWS - not found.
-- Looking for Q_WS_MAC
-- Looking for Q_WS_MAC - not found.
-- Found Qt-Version 4.6.3 (using /usr/bin/qmake)
-- Looking for _POSIX_TIMERS
-- Looking for _POSIX_TIMERS - found
-- QT_X11_X11_LIBRARY contains: /usr/lib/libX11.so
-- Configuring done
-- Generating done

> You're right that current debian patch (courtesy by ubuntu) is a pure hack and 
> you nailed its deficiencies well. But you have the bug on your hands 
> nevertheless, it's not debian-specific bug. In order to fix this properly, do 
> find_package(X11) and use a proper variable which expands to X11 library 
> (iirc, X11_X11_lib).

I don't agree with that. You are proposing to patch this package, but every build system depending on CMake and the variable QT_X11_X11_LIBRARY would need a similar patch. Won't be better a common solution that works for all of them? In my opinion it would be preferred to patch Debian's CMake package.

> 1.http://cmake.org/gitweb?p=cmake.git;a=commit;h=0f457937f4f5cbdaedaaec00849cb7a050bbc0f4

[2] http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Qt4ConfigDependentSettings.cmake
[3] http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/FindQt4.cmake
[4] http://cmake.org/cmake/help/cmake-2-8-docs.html#module:Qt4ConfigDependentSettings

Regards,
Pedro
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeLists.txt
Type: text/x-cmake
Size: 266 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-multimedia-maintainers/attachments/20110301/05a4a6dc/attachment-0001.bin>


More information about the pkg-multimedia-maintainers mailing list