When building kgcc64 (the kernel compiler) on sparc, toolchain.eclass decides that it is doing a cross-compile because (I suppose) the sparc64 userland is always 32 bits, but kgcc64 must build 64-bit kernel code. It then sets CFLAGS="-O2 -pipe" with the comment: # Set this to something sane for both native and target However, when building for target=sparc64, CFLAGS="-O2 -pipe" is probably never sane, and results in just about the worst performance possible for the resulting program. If the user gives you "-mcpu=ultrasparc", "-mcpu=ultrasparc3", or "-mcpu=v8" you probably must use that unless the application is known not to build for that -mcpu= flag (and this is should have been handled by the ebuild for the package itself.) Please see Bug 59506 for a discussion of why you shouldn't filter out -mcpu= flags.
you skipped the important comments in the eclass: # CFLAGS: # This conflicts when creating a crosscompiler, so set to a sane # default in this case: # used in ./configure and elsewhere for the native compiler # used by gcc when creating libiberty.a # used by xgcc when creating libstdc++ (and probably others)! # this behavior should be removed...