compiling large functions

Martin Wiebusch martin.wiebusch@gmx.net
Fri Oct 3 21:57:00 GMT 2008


Thanks. -fno-unit-at-a-time works for the case where I have many 
functions in one big source file. I can even switch on optimization now.

I'm still surprised that gcc can't just dump everything it has and start 
over when it runs out of memory while compiling a big function. But then 
things inside a compiler are probably more complicated than I imagine.

Tom St Denis wrote:
> Martin Wiebusch wrote:
>> Hi,
>>
>> I'm having trouble compiling generated code, which results in very 
>> large function bodies. The structure of the function is quite simple; 
>> just a long list of variable = expression assignments, where each 
>> expression is at most 30 lines or so. The entire sourcefile can be up 
>> to 10MB. (Yes, it's a beast of a calculation.) Even without 
>> optimization, gcc uses all my 2Gig of memory and eventually quits with 
>> a "cc1plus: out of memory" message.
>>
>> I have had limited success with splitting up the code into several 
>> smaller functions. What puzzles me is that, if I put all functions 
>> into the same source file, gcc still uses much more memory than when I 
>> put them in separate files (and eventually dies for the 10MB source).
>>
>> Basically, I'm wondering whether there is a way to tell gcc to just 
>> compile (and maybe even optimize?) one assignment at a time and not 
>> try to keep the entire function in memory (assuming that that's what 
>> it does now).
> 
> Try -fno-unit-at-a-time ?
> 
> Alternatively, just put the different functions in different files (e.g. 
> func1.c, func2.c, func3.c, etc), and generate your makefile 
> automatically so you don't need to keep track of the names.
> 
> Tom
> 



More information about the Gcc-help mailing list