Ticket #36 (new Defect)

Opened 1 year ago

Last modified 4 months ago

Qt4 libs get dropped by --as-needed

Reported by: taj Assigned to: taj
Priority: Medium Milestone:
Component: apbuild Version: 1.2.3
Severity: Normal Keywords:
Cc:

Description

According to this comment, Qt4 libs get removed by --as-needed during dep-stripping. Fix it so that doesn't happen.

Attachments

qt-testcase.tar.gz (0.7 kB) - added by taj on 08/25/07 19:36:58.
small test-case
output.zip (1.4 kB) - added by UnFleshed One on 08/27/07 20:22:43.
test.tar.gz (0.5 kB) - added by UnFleshed One on 08/28/07 11:55:47.
Order dependent linking example

Change History

08/25/07 19:36:58 changed by taj

  • attachment qt-testcase.tar.gz added.

small test-case

08/25/07 19:37:47 changed by taj

Huh, for some reason I can't reproduce this. I'm using Qt-4.3.1 (open source) in release mode. What version of GCC is this? I'm using 4.1.2.

I've attached a small test-case that you could try and see if it happens for you. Also, what's the complete output of compiling with APBUILD_DEBUG=1 set?

Thanks, - Taj

08/27/07 20:22:43 changed by UnFleshed One

  • attachment output.zip added.

08/27/07 20:31:13 changed by UnFleshed One

Hm, with your example I can't reproduce it either.

Right now it seems to happen only with QtNetwork?.

In attached output, only thing I need to do to make it link is moving -lQtNetwork to be after -ldownloader (or remove --as-needed). In this case, one of my libraries depend on QtNetwork?, and main application doesn't, there are no references to it, even in headers, all calls to QtNetwork? are hidden within my wrapper library.

I'll try to reduce this to minimal example tomorrow, but this seems to be a problem not particular to Qt. If I guess correctly, any indirect dependency through a library will be dropped on --as-needed. (So there should be a way to force linkage order via apbuild).

08/28/07 11:55:47 changed by UnFleshed One

  • attachment test.tar.gz added.

Order dependent linking example

08/28/07 12:08:39 changed by UnFleshed One

Ok, so here is an example when order of linking matters. The problem isn't in Qt, but in the way I'm using it.

I wonder if the same thing happens in case of those other libraries that are being pushed at the end right now.

09/23/07 16:24:17 changed by taj

Is the problem apgcc reordering the compile land? I'm not sure test.tar.gz is a valid test case, because substituting apg++ with g++ gives the same error.

In the qt output example, what happens when you run the apg++ command with g++?

g++ -Wl,--rpath=$ORIGIN/../lib -Wl,--rpath=$ORIGIN/../../common/lib -Wl,-z,origin -o bins/SMARTProductUpdate Linux/release/main.o Linux/release/moc_mainwindow.o Linux/release/mainwindowimpl.o Linux/release/version.os Linux/release/recordkeeper.o Linux/release/workflow.o Linux/release/CommandLineParser.o Linux/release/ApplicationFactory.o Linux/release/galleryversion.os Linux/release/resources.os build_id.os Linux/release/moc_mainwindowimpl.o -Llibs -L/usr/local/Trolltech/Qt-4.2.2/lib -L/home/swbuild/externalHD/Builds/ScheduledBuildsClash/builds/clash/CurrentBuild/projects/spu/source/Shared Libraries/libs -L/home/swbuild/externalHD/Builds/ScheduledBuildsClash/builds/clash/CurrentBuild/projects/spu/source/SelfUpdate/libs -lQtCore -lQtGui -lQtNetwork -lselfupdate -ldownloader -lqtport -lauthentication -lsmartutil -lwinport -lsmartatl -lpreference -llocalization -lauthentication -lxml -lz

I assume that works? I'm not sure why though...if you could create a different testcase that would help. I'll try to research it more this week too (probably next weekend, though).

09/24/07 12:28:03 changed by UnFleshed One

I think last time I tried it, the breaking difference was --as-needed flag. I'll have to double-check it though.

09/28/07 22:45:49 changed by taj

The testcase fails for me when using g++ without --as-needed:

$ g++ -o test.bin test.cpp -I. -L. -lA -lB
./libB.a(libB.o): In function `LibBClass::LibBClass()':
libB.cpp:(.text+0xd): undefined reference to `LibAClass::LibAClass()'
./libB.a(libB.o): In function `LibBClass::LibBClass()':
libB.cpp:(.text+0x21): undefined reference to `LibAClass::LibAClass()'
collect2: ld returned 1 exit status

It sounds like the root cause of the Qt issue is from linking order being changed. Apbuild's not supposed to do that anymore, though.

05/31/08 15:04:37 changed by Jan-Nik