PDA

View Full Version : ARM Platform: Segfaults with "-release" Qt but works great with "-debug" Qt?!



thajan
11th August 2009, 13:57
Hi there,

I am working to get Qt Embedded 4.5.2 working on an ARM (Samsung s3c2440) dev-kit.

Qt compiled fine with my current toolchain (the "spring" 2009 sourcery) and everything is going spiffy. EXCEPT when I try to run a GUI program (ANY GUI program, even the dead simple "Hello World" button "program") doesn't work...

To be exact: It gives a segmentation fault while loading a GUI program.

(NOTE: I did try an console program by using qDebug() to print "Hello world" and this DOES work with "-release" Qt)

The strange thing is, when I configure Qt with the -debug option, it DOES work! Doesn't give a segmentation fault and everything works perfectly, even ts-lib!

Does anyone know the reason why the "-release" qt doesnt't work but it DOES work in debug mode?

My configuration (NOTE: I replace "-release" with "-debug" when compiling for debug mode):



./configure -v \
-embedded arm -xplatform qws/linux-arm-g++ -prefix /usr/qt \
-nomake examples -nomake demos -opensource \
-no-accessibility -no-sql-sqlite -no-phonon -no-phonon-backend -no-qt3support \
-no-scripttools -no-mmx -no-3dnow -no-sse -no-sse2 -no-cups -no-dbus -no-glib \
-qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -qt-gfx-linuxfb -qt-mouse-tslib -qt-gfx-qvfb \
-shared -release


Is there anything I'm doing wrong? If there is more information needed, I am happy to supply :)

Thanks a lot! :D

thajan
11th August 2009, 14:06
Note:
I used the same hello world program from: http://doc.trolltech.com/4.1/tutorial-t1.html

I found out (by inserting qDebug()'s) that the program doesn't get any further than the QApplication Line:



...
qDebug() << "Making QApplication";
QApplication app(argc, argv);
...


Program output:


$./helloworld
Making QApplication
Segmentation Fault


I hope this helps some more.

nrabara
29th August 2009, 12:51
hi thajan,

I have found the similar problem..
Did you find the solution??

If yes, please let me know??

thajan
29th August 2009, 22:24
hi thajan,

I have found the similar problem..
Did you find the solution??

If yes, please let me know??

Hi there,

I contacted the people at Qt and it is a common error caused by compiler optimizations present in G++ 4.2.x and higher. This also explains why it DOES work in debug mode, because it excludes several optimization options.

They had several solutions to get rid of the optimization issue:

(i) Use a 4.1 compiler
(ii) Drop the "-O2" value of the QMAKE_CFLAGS_RELEASE in "mkspecs/common/g++.conf" to "-O1".
(iii) Edit "mkspecs/qws/linux-arm-g++/qmake.conf" and turn off some compiler optimizations that seem to give some problems like so:

QMAKE_CFLAGS_RELEASE += -fomit-frame-pointer -finline-functions -funroll-loops -falign-functions=2 -falign-loops=2 -falign-jumps=2

NOTE: Fill in the right values for "-falign-functions -falign-loops -falign-jumps" that fit with your CPU.

Don't forget to run "make confclean" after you edit the file.

All options (changing compiler was not an option), however, did not work properly for me. I had to drop the compilerflag to "-O0", which had an, to me, unacceptable slow performance.
In staid I had to change the following line in "src/gui/embedded/qscreenlinuxfb.cpp":

From:

canaccel = useOffscreen();
To:

canaccel = false;

I found this out by filling the file with qDebug()'s and see where it went wrong.

NOTE: This is a HACK, and not a pretty one either. It makes sure that it hardcoded doesn't use off-chip graphic memory. I don't use off-chip graphic memory, but if you do, this hack is useless.