Opened 18 years ago
Closed 16 years ago
Last modified 16 years ago
#2402 closed defect (fixed)
qmake build system has bad dependencies which causes --as-needed and future binutils to fail to link
Reported by: | Owned by: | Nigel | |
---|---|---|---|
Priority: | minor | Milestone: | unknown |
Component: | mythtv | Version: | 0.20 |
Severity: | medium | Keywords: | |
Cc: | Ticket locked: | no |
Description
The build system has dependencies on libraries incorrect and poorly laid out. This causes anyone compiling with --as-needed to have missing symbols and libraries aren't built in the correct order for resolving dependencies since apparently qmake respects order rather then dependencies.
The following patch is for release-0_20-fixes, it cleans this whole mess up.
Attachments (2)
Change History (17)
Changed 18 years ago by
Attachment: | mythtv-0.20-as-needed.patch added |
---|
Changed 18 years ago by
Attachment: | mythtv-0.20-as-needed.2.patch added |
---|
comment:1 Changed 18 years ago by
comment:2 Changed 18 years ago by
nigel:
I'm well aware that there are circular dependencies. I've been saying that as far back as 0.18 or 0.17. There's A LOT of code that needs to get cleaned up. I've posted this here for Linux users with new binutils that use --as-needed since this will work on there systems. There is no guarentee it will work on other systems. I highlighted the Isaac the circular depends the other night.
comment:3 Changed 16 years ago by
Is there any news on this ticket? I believe multiple distros now use --as-needed, so I assume this could be becoming a bigger issue, and the cause of more distro provided patches.
comment:5 Changed 16 years ago by
Owner: | changed from Isaac Richards to Nigel |
---|---|
Status: | new → assigned |
comment:6 Changed 16 years ago by
Hmm. I just hacked a build machine's Qt to use ld with --as-needed, deleted all libs and did a build of both 0-20-fixes and current SVN head. No linker errors:
% make ... cd libmyth && make -f Makefile make[2]: Entering directory `/home/nigel/mythtv/libs/libmyth' rm -f libmyth-0.20.so.0.20.0 libmyth-0.20.so libmyth-0.20.so.0 libmyth-0.20.so.0.20 g++ -shared -v -Wl,--as-needed,--verbose -Wl,-soname,libmyth-0.20.so.0 -o libmyth-0.20.so.0.20.0 ... GNU ld version 2.17 Debian GNU/Linux ... attempt to open /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crtn.o succeeded /usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crtn.o ln -s libmyth-0.20.so.0.20.0 libmyth-0.20.so ln -s libmyth-0.20.so.0.20.0 libmyth-0.20.so.0 ln -s libmyth-0.20.so.0.20.0 libmyth-0.20.so.0.20 make[2]: Leaving directory `/home/nigel/mythtv/libs/libmyth'
I have looked at the binutils README, but there don't seem to be any real changes with --as-needed in 2.18 (except for a helper script). Am I going mad? Or does --as-needed do nothing different?
comment:7 Changed 16 years ago by
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
I tested again, on a 64bit machine which has binutils 2.18. Again, no problems in SVN head or 0-20-fixes.
comment:8 Changed 16 years ago by
Resolution: | worksforme |
---|---|
Status: | closed → new |
I have this line in my /usr/qt/3/mkspecs/linux-g++/qmake.conf file: QMAKE_LFLAGS_RELEASE=-Wl,--hash-style=both,-z,relro,--enable-new-dtags,-O1,-z,now,--as-needed
My machine is an AMD64 running GCC 4.2.2, binutils 2.18, and qt 3.3.8.
When I build mythtv 15429, this is the error I get: g++ -c -pipe -fomit-frame-pointer -O3 -Wall -Wno-switch -Wpointer-arith -Wredundant-decls -Wno-non-virtual-dtor -DSTDC_CONSTANT_MACROS -D_REENTRANT -DMMX -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DPREFIX=\"/usr\" -DLIBDIR=\"/usr/lib64\" -DUSING_X11 -DUSING_XV -DUSING_IVTV -DUSING_XVMC -DUSING_XVMC_VLD -DUSING_XRANDR -DUSING_OPENGL_VSYNC -DUSING_ALSA -DUSING_OSS -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/qt/3/mkspecs/linux-g++ -I. -I/usr/include -I/usr/include -I../.. -I../../libs -I../../libs/libmyth -I../../libs/libmythtv -I../../libs/libavutil -I../../libs/libavformat -I../../libs/libavcodec -I../../libs/libmythupnp -I../../libs/libmythui -I../../libs/libmythlivemedia -I/usr/qt/3/include -I/usr/X11R6/include -I/usr/X11R6/include -o manualschedule.o manualschedule.cpp g++ -c -pipe -fomit-frame-pointer -O3 -Wall -Wno-switch -Wpointer-arith -Wredundant-decls -Wno-non-virtual-dtor -DSTDC_CONSTANT_MACROS -D_REENTRANT -DMMX -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DPREFIX=\"/usr\" -DLIBDIR=\"/usr/lib64\" -DUSING_X11 -DUSING_XV -DUSING_IVTV -DUSING_XVMC -DUSING_XVMC_VLD -DUSING_XRANDR -DUSING_OPENGL_VSYNC -DUSING_ALSA -DUSING_OSS -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/qt/3/mkspecs/linux-g++ -I. -I/usr/include -I/usr/include -I../.. -I../../libs -I../../libs/libmyth -I../../libs/libmythtv -I../../libs/libavutil -I../../libs/libavformat -I../../libs/libavcodec -I../../libs/libmythupnp -I../../libs/libmythui -I../../libs/libmythlivemedia -I/usr/qt/3/include -I/usr/X11R6/include -I/usr/X11R6/include -o programrecpriority.o programrecpriority.cpp ../../libs/libmyth/libmyth-0.20.so: undefined reference to `XmlConfiguration::XmlConfiguration?(QString const&)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `MythXMLClient::~MythXMLClient()' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::UPnp()' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `SSDPCache::Find(QString const&)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `SSDPCache::Find(QString const&, QString const&)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `MythXMLClient::MythXMLClient(QUrl const&, bool)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::SetConfiguration?(Configuration*)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::Initialize(int, HttpServer?*)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnpDeviceDesc::Retrieve(QString&, bool)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::g_SSDPCache' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `SSDP::PerformSearch?(QString const&)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `HttpServer::HttpServer?(int)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::g_UPnpDeviceDesc' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `MythXMLClient::GetConnectionInfo?(QString const&, DatabaseParams?*, QString&)' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::g_pConfig' ../../libs/libmyth/libmyth-0.20.so: undefined reference to `UPnp::g_pSSDP' collect2: ld returned 1 exit status make[2]: * [mythtv] Error 1 make[2]: Leaving directory `/var/tmp/portage/media-tv/mythtv-0.21_pre15429/work/mythtv-0.21/programs/mythtv' make[1]: * [sub-mythtv] Error 2 make[1]: * Waiting for unfinished jobs....
If I remove the "--as-needed" from the QMAKE_LDFLAGS_RELEASE line in qmake.conf, mythtv builds and runs fine.
comment:9 Changed 16 years ago by
Hooray. Someone actually showed me the real errors they are getting!
From the patches, I had assumed the problems were in the library linking (closure), not the program linking.
I'm not sure this will be fixable, because --as-needed just seems to be broken on the link line. Check out this output after I pruned LIBS down to -lGL -lmyth -lmythui:
/usr/bin/ld --eh-frame-hdr -m elf_i386 --hash-style=both -dynamic-linker /lib/ld-linux.so.2 -o mythtv /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.1.3/crtbegin.o -L/usr/share/qt3/lib -L../../libs/libmyth -L../../libs/libmythui -L/usr/lib/gcc/i486-linux-gnu/4.1.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3 -L/usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib --as-needed -v main.o -lmyth-0.20.2 -lGL -lmythui-0.20.2 -lqt-mt -lXext -lX11 -lpthread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i486-linux-gnu/4.1.3/crtend.o /usr/lib/gcc/i486-linux-gnu/4.1.3/../../../../lib/crtn.o GNU ld (GNU Binutils for Debian) 2.18 main.o: In function `main': main.cpp:(.text+0x3c86): undefined reference to `TV::InitKeys()' main.cpp:(.text+0x3c9c): undefined reference to `TV::TV()' main.cpp:(.text+0x3cad): undefined reference to `TV::Init(bool)' main.cpp:(.text+0x431e): undefined reference to `ProgramInfo::ProgramInfo()' main.cpp:(.text+0x43e1): undefined reference to `TV::Playback(ProgramInfo*)' main.cpp:(.text+0x43ff): undefined reference to `TV::GetState() const' main.cpp:(.text+0x449b): undefined reference to `TV::LiveTV(bool, bool)' ../../libs/libmythui/libmythui-0.20.2.so: undefined reference to `glClearDepth' ../../libs/libmythui/libmythui-0.20.2.so: undefined reference to `glMatrixMode' ../../libs/libmythui/libmythui-0.20.2.so: undefined reference to `glHint'... % objdump -T /usr/lib/libGL.so | grep glClearDepth 0004ace0 g DF .text 00000000 Base glClearDepth
libGL is parsed first, it contains the symbols, but 'ld --as-needed' doesn't find it. I'm at a loss (again).
comment:10 Changed 16 years ago by
Status: | new → assigned |
---|
comment:11 Changed 16 years ago by
OK. I have worked it out. Linux ld --as-needed uses the dependencies that are compiled into the libraries that it is parsing (like Solaris's ld -R, except that they are used at runtime). Several checkins on the way!
comment:12 Changed 16 years ago by
comment:13 Changed 16 years ago by
comment:14 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:15 Changed 16 years ago by
this cannot be marked as fixed, problem still there in last svn revisions
Hi Doug. I have never used '--as-needed' (it is not an option in my ld), but yes, the dependencies need fixing. Sadly, your re-ordering of SUBDIRS causes link failure on Mac OS X:
because there are actually circular dependencies. I am not a C++ expert, so I have been thinking about this for several months (since libmythui started being used) and can only think of three fixes:
Only the first option is a proper fix