The ebuild prepends "-march=x86-64" to TARGET_C(PP)FLAGS, so an -march=xxx in CFLAGS overrides -march=x86-64, and fails if xxx is incompatible with -m64. I suggest filtering -march from user-supplied C(PP)FLAGS for platform=efi-64 in grub_src_configure() (hopefully this can be done while leaving other platforms unaffected). It's a bootloader, so even if the user has another m64-compatible -march in CFLAGS, the difference is bound to be miniscule (especially with -mtune). i686-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I/var/tmp/portage/sys-boot/grub-2.00/work/grub-2.00/grub-core -I.. -march=x86-64 -Wall -W -I/var/tmp/portage/sys-boot/grub-2.00/work/grub-2.00/include -I../include -DGRUB_MACHINE_EFI=1 -DGRUB_MACHINE=X86_64_EFI -DGRUB_TARGET_CPU_X86_64=1 -m64 -nostdinc -isystem /usr/lib/gcc/i686-pc-linux-gnu/4.5.3/include -DGRUB_FILE=\"trigtables.c\" -I. -I/var/tmp/portage/sys-boot/grub-2.00/work/grub-2.00/grub-core -I.. -I/var/tmp/portage/sys-boot/grub-2.00/work/grub-2.00 -I/var/tmp/portage/sys-boot/grub-2.00/work/grub-2.00/include -I../include -Os -march=x86-64 -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -m64 -mcmodel=large -mno-red-zone -fno-PIE -fno-PIC -fno-stack-protector -mno-stack-arg-probe -Wno-trampolines -DUSE_ASCII_FAILBACK=1 -DHAVE_UNIFONT_WIDTHSPEC=1 -ffreestanding -Os -march=pentium3 -mtune=core2 -mfpmath=sse -fomit-frame-pointer -pipe -c -o trig_module-trigtables.o `test -f 'trigtables.c' || echo '/var/tmp/portage/sys-boot/grub-2.00/work/grub-2.00/grub-core/'`trigtables.c trigtables.c:1:0: error: CPU you selected does not support x86-64 instruction set
You can probably resolve this by un-setting CFLAGS and using HOST_CFLAGS instead. I don't want to insert workarounds for custom-cflags.
Well, -march=x86-64 is already a workaround. I understand that custom-cflags is a "you are on your own" territory, but I think that the USE flag itself should be well-supported.
Actually, IIRC (bug 360513), '-march' might be plain broken for grub - it was in grub1 case.