Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shouldn't suggest using -O3 #37

Closed
pixelherodev opened this issue Jul 15, 2019 · 2 comments
Closed

Shouldn't suggest using -O3 #37

pixelherodev opened this issue Jul 15, 2019 · 2 comments

Comments

@pixelherodev
Copy link

-O3 for GCC is explicitly unsafe, enabling - among other things - non-standards compliant floating point maths.

Given what's being discussed here, why is -O3 being suggested as a good idea? -O2 or -Os are usually much safer.

Compiling with -O3 is not a guaranteed way to improve performance, and in fact in many cases can slow down a system due to larger binaries and increased memory usage. -O3 is also known to break several packages. Therefore, using -O3 is not recommended.

A better, safer option for local builds is -O2 -march=native -mtune=native, possibly also with -flto.

@Ravenslofty
Copy link

I'm very late, but you appear to confuse -O3 (standards compliant) with -Ofast (explicitly non-standards compliant). -O3 is entirely safe providing your code is correct. Packages sometimes break with -O3 because they are not correct, and the analysis at -O3 can prove as such.

For modern, new programs there is very little reason to prefer -O2 over -O3 unless you're doing very hairy things with templates, especially because the more detailed flow analysis of -O3 can produce warnings (find bugs) that -O2 does not.

@pixelherodev
Copy link
Author

...very late also, but I believe you are correct. I was remembering warnings not to use -O3 because a lot of code is not correct, and hasn't been fixed.

@ssloy ssloy closed this as completed Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants