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.
Merge pull request #1426 from jszakmeister/change-release-opt-default

build: default to using -O2 for release builds