Re: Controlling optimization level per function
Re: Controlling optimization level per function
- Subject: Re: Controlling optimization level per function
- From: Ivan Cavero Belaunde <email@hidden>
- Date: Fri, 9 Jul 2010 12:46:21 -0700
- Acceptlanguage: en-US
- Thread-topic: Controlling optimization level per function
#pragma GCC optimization_level x (as opposed to #pragma GCC optimize, which is GNU's blessed approach on 4.4+) works fine on Xcode's GCC, with the caveat that some of the optimizations controlled by -Ox are whole-file optimizations and can't be changed mid-compile (e.g. inlining).
If the missing optimizations are really important to you, pull the functions you want optimized to a separate file and use the per-file build options to change that. However, be forewarned that those options will apply even on Debug builds, which can make debugging pretty unpleasant (gdb has a hell of a time following the flow of code generated by -O3). Optimally, you'd add a user-defined build setting which varies between Debug/Release (e.g. "PER_FILE_OPTIMIZATION_LEVEL" set to "3" or "0"), and set up your per-file build setting based on that (e.g. "-O$(PER_FILE_OPTIMIZATION_LEVEL)").
HTH,
Iván
---
Iván Cavero Belaunde (email@hidden)
Advanced Technology Labs
Adobe Systems Inc.
On Jul 9, 2010, at 12:04 PM, lbland wrote:
> hi-
>
> On Jul 9, 2010, at 2:30 PM, Eric Gorr wrote:
>
>> #pragma GCC optimization_level 0
>
> last week I read that such a pragma is only supported on gcc 4.4 and above ( ... or some such thing ... I don't have the exact reference off hand).
>
> I wanted to insert compiler flags just like you want, but now I don't know if it is possible with gcc 4.2
>
> ... I could be wrong though.
>
> thanks!-
>
> -lance
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden