title: GCC-Go - Optimize builds for specific architecture
body: <p>How does one uses environment variables to optimize a go binary?</p>
  <p>For instance, with C and GCC, you would set <code>CFLAGS=&quot;-O2 -march=znver1</code> to build with tier 2 optimizations, with specific optimizations for the Zen microarchitecture.
  I couldn't find an equivalent environment variable in Golang's documentation.</p>
  <p>Go does provide a way to disable them all, but not to specify which one to use in case you are using gccgo as the compiler back-end. It is thus very different from other questions asked about optimizations flags for Go in general (<a href="https://stackoverflow.com/questions/45003259/passing-an-optimization-flag-to-a-go-compiler?noredirect=1&amp;lq=1">Passing an optimization flag to a Go compiler?</a> for instance)</p>