gcc option -Os can/will give applications crashing with SIGSEGV

Roger Larsson roger.larsson at norran.net
Mon Jan 19 21:19:44 CET 2004


Since KDE 3.2 has been released...

Many users that compile KDE, or other applications, themselves will
compiles with optimizations.
(Most developers don't since they want fast compilation, good debugability)

So what will many people do after source release:
Add
	-Os (one of the better optimization options)
	-march=pentium3 (or whatever processor they have)
to their compilation options.

This is nothing strange, hundreds will do that.
If they happen to have gcc 3.3.1 (Like SuSE 9.0)
a gcc bug will generate code that crashes.
	http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13685
And will be rejected as WORKSFORME...

I have verified that kicker klock applet in analog mode (seconds might be
needed)
	http://bugs.kde.org/show_bug.cgi?id=70655
and kivio when drawing arrows
	http://bugs.kde.org/show_bug.cgi?id=72672

The interesting part is that once you have compiled most with -Os
you have a situation where changing compilation options on the specific
application might not help (no optimization -O0 will work...)

Work arounds (not verified with gcc folks):
* Do not use -Os use -O2 instead (recompile everything...)
or 
* When recompiling crashing code add
	-mno-sse
This will turn off ALL sse instructions, but you can still compile for your 
specific architecture.

Thanks to Thiago Macieira (KDE) and  Andrew Pinski (gcc) for helping me
in the right direction.
	
/RogerL

PS
  Try to compile and run the code on bugzilla and report results for
  different compilers and architectures...
DS

-- 
Roger Larsson
Skellefteå
Sweden



More information about the Kde-optimize mailing list