Various fixes for latest gcc
Use whole-program link-time optimisation