1

What's the "standard" optimization level used for clang? I believe that "O2" is a good choice for gcc - does that hold for clang also, or is there a generally better alternative?

Colen
  • 13,428
  • 21
  • 78
  • 107

2 Answers2

3

-O2 and -Os are both good choices for general use with clang.

servn
  • 3,049
  • 14
  • 8
  • According to http://stackoverflow.com/questions/15548023/clang-optimization-levels, -O2 and -Os are identical. – Stefan May 11 '17 at 16:12
0

-O3 will usually give you both the smallest and fastest code, but does tend to expose non obvious bugs in your code.

In general, you should make sure your code runs fine with all possible optimizations.

Willem Hengeveld
  • 2,758
  • 23
  • 19