mixing optimized and unoptimized code?
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sun Mar 5 15:42:00 GMT 2000
> In my application I have several source files for which latest gcc is
> unable to produce optimized code (runs out of memory on a 256M Ultra10
> with -O1). So, I was wondering what would be the implications of
> compiling those few sources unoptimized and linking with the rest of the
> application which is optimized? Are there any optimizations I should
> avoid? (I am thinking of those that change function call conventions)?
You can mix code of all optimization levels as you please; it should
work in all possible combinations. I'm not aware of optimizations that
change function call conventions.
> A related question: which optimizations are not especially memory
> hungry? I was thinking I could selectively turn on *some* of them
> on those problematic sources.
If you are talking about memory consumption in the generated code,
using '-Os' should give you what you want. If you are talking about
memory consumption in the compiler - many optimizations do. In
particular, inlining requires a lot of compile time and compile
memory; you can restrict this with -fno-inline or -finline-limit-N. I
don't think there is a way to turn on only the cheap optimizations
(except, perhaps, -O1) - you'll have to turn off the expensive ones.
See (gcc)Optimize Options for details.
Martin
More information about the Gcc
mailing list