We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 31

Summary: Up default optimizations to -O3...
Product: SDL Reporter: Ryan C. Gordon <icculus>
Component: buildAssignee: Eric wing <ewmailing>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: ewmailing, marchesin
Version: HG 2.0   
Hardware: All   
OS: All   

Description Ryan C. Gordon 2006-01-04 14:46:08 UTC
Newer GCC builds get a decent benefit from -O3, but we're still using -O2 in the Unix configure script.

Up this?

--ryan.
Comment 1 marchesin 2006-01-11 18:27:27 UTC
I've had some really bad experience with -O3 (unpredictable crashes) on x86 and some older gcc (3.X, don't remember exactly). So I would advise against it.

I think it'd be wiser to find the right -f* option(s) and only use these.
Comment 2 Ryan C. Gordon 2006-01-27 11:23:08 UTC
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL.

--ryan.

Comment 3 Eric wing 2006-01-31 16:01:13 UTC
For the OS X Xcode projects, should I up this to -O3? For PPC, we will be using gcc 3.3 and x86 we will be using gcc 4.0.1. I think the default is -Os. 



Comment 4 marchesin 2006-01-31 16:12:26 UTC
I can't say about PPC, but on x86 I suspect the issues are due to the non PIC-cleanness of the hermes blitters. Since OS X doesn't enable these blitters yet, it *should* be ok.
Comment 5 Sam Lantinga 2006-04-13 10:40:19 UTC
(In reply to comment #0)
> Newer GCC builds get a decent benefit from -O3, but we're still using -O2 in
> the Unix configure script.
> 
> Up this?

Maybe.  Do the blitters benefit from this?  I don't think any of the other SDL code would benefit much from -O3.
Is there an easy way to detect if -O3 is supported by the compiler?

Comment 6 Ryan C. Gordon 2006-04-13 11:22:54 UTC
-O3 is always "supported" in that it'll just use O2 if it doesn't support it (so you could put -O99 and gcc will pick the highest level it's got).

The concern was whether this would introduce optimization bugs, and apparently on some platforms it does. On some, however, the blitters _do_ get a sweet boost from O3.

I say leave it at O2 for now...those that want to can explicitly set CFLAGS. 

I'll flag this bug as RESOLVED LATER so we revisit it at some point, though.

--ryan.

Comment 7 Ryan C. Gordon 2009-10-10 22:43:13 UTC
Reopening this bug for SDL 1.3. We shouldn't change this for 1.2 at this point, but it should definitely become the default for 1.3, especially since a lot of the nasty low-level code is gone, compilers are better, etc.

--ryan.
Comment 8 Sam Lantinga 2009-10-10 23:14:46 UTC
Yeah, let's try this for SDL 1.3.

I'll take care of the command line build.  Eric, you want to take care of the Xcode project?
Comment 9 Sam Lantinga 2009-10-10 23:46:02 UTC
Okay, the command line build defaults to -O3 with gcc now.
Comment 10 Nathaniel J Fries 2011-01-07 13:16:23 UTC
I can verify that I frequently get optimization bugs with -03 using MinGW in other projects I've worked on.

I'd suggest figuring out which optimizations speed up the blitters, and only enabling those. That will make debugging easier (if we notice one of the -f-optimizations causes a bug, we can just remove it).

I have never experienced such an issue with optimized MSVC builds of the same projects, though; so it may be beneficial to use maximum optimization there.
Comment 11 Sam Lantinga 2012-01-07 00:54:23 UTC
SDL 1.3 is set to build -O3 by default on the command line.  We'll look into optimizer related bugs as they're reported.