Red Hat Bugzilla – Bug 28385
g++ -O hangs while compiling file
Last modified: 2005-10-31 17:00:50 EST
As of this afternoon, g++ hangs while compiling nsStyleContext.cpp in the
Mozilla tree with -O2. I'll attach the preprocessed output to make for
easy testing. Given nsStyleContext.ii that I will attach, the command
c++ -c -o nsStyleContext.o -O2 nsStyleContext.ii
hangs, while the command
c++ -c -o nsStyleContext.o nsStyleContext.ii
I'm seeing this with gcc-2.96-70 and -O2. tor reports the same problem
with gcc-2.96-74 and -O (rather than -O2). mao reports it with
Created attachment 10440 [details]
nsStyleContext.ii - preprocessed source
Thanks. Actually, CVS head hangs on this as well.
The culprit is:
inline void CalcSidesFor(const nsIFrame* aFrame, const nsStyleSides& aSides,
const nscoord* aEnumTable, PRInt32 aNumEnums,
aResult.left = CalcSideFor(aFrame, aSides.GetLeft(coord), aSpacing, 3,
aResult.top = CalcSideFor(aFrame, aSides.GetTop(coord), aSpacing, 0,
aResult.right = CalcSideFor(aFrame, aSides.GetRight(coord), aSpacing, 1,
aResult.bottom = CalcSideFor(aFrame, aSides.GetBottom(coord), aSpacing, 2,
and the tree based inlining for some reason does not limit itself in doing
further and further inlines of itself in this case (because CalcSideFor indirectly
calls CalcSidesFor). I'll try to simplify it first.
With -O (not O3) and with gcc-2.96-54, it takes a long time, and finally gives
Cannot allocate 892625676 bytes after allocating 16260924 bytes
I've narrowed it down to a 3K testcase and it really does not hang, it just
does a lot of inlining and eats gobs of memory (if I remove one of the 4
routines for inlining, it actually succeeds on my 256MB box, otherwise I never
had the patience to let it finish). I hope I'll know more tomorrow.
Any movement on this? It's a real killer.
Yes, I think I've fixed this by:
Mark Mitchell approved it, if Jason Merrill does not have anything
against it until tomorrow, I'll commit it and will include it into
Are you committing the patch to both the gcc trunk and the gcc 3.0 branch? I
sure hope this is fixed in gcc 3.0 also.
Sure, I've commited it to both branch and head.
*** Bug 31937 has been marked as a duplicate of this bug. ***