While we probably should get to the root of the flags and specify them more completely if needed, I would highly recommend using the gcc compiler built by ARM.
https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm It is kept quite up-to-date and tends to fix some issue I have had in the past with the distro delivered packages for embedded builds. This is also the toolchain our CI system uses. --Brennan