build: default to using -O2 for release builds

The -O3 optimization level can often lead to dangerous (and sometimes
incorrect) optimizations being performed.  So let's use a level that's
more stable.