When gcc is configured and compiled for x32 mode (x86_64-linux-gnux32 triplet), the flag -m16 doesn't work. The bug was reproduced on gcc-4.9.1-13 from Debian Ports x32 distribution (https://wiki.debian.org/X32Port) Attempting to compile or assemble anything with "gcc -m16 -march=i386" results in this error message: error: CPU you selected does not support x86-64 instruction set (this error causes linux kernel 3.16.2 compilation failure) If you remove "-march=i386", the file is compiled, but it can't be assembled, because gcc generates incorrect assembler as if it was x86_64 target. For example, compiling a file test.c containing "int bla(void) { return 3; }" with "gcc -c -m16 test.c", results in these error messages: /tmp/cc89iTZG.s: Assembler messages: /tmp/cc89iTZG.s:9: Error: bad register name `%rbp' /tmp/cc89iTZG.s:15: Error: bad register name `%rbp' When gcc is configured for x86_64 mode (x86_64-unknown-linux-gnu), -m16 works correctly.
A patch is posted at https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00987.html
Author: hjl Date: Thu Sep 11 22:18:06 2014 New Revision: 215194 URL: https://gcc.gnu.org/viewcvs?rev=215194&root=gcc&view=rev Log: Also turn off OPTION_MASK_ABI_X32 for -m16 PR target/63228 * config/i386/i386.c (ix86_option_override_internal): Also turn off OPTION_MASK_ABI_X32 for -m16. Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c
Author: hjl Date: Thu Sep 11 22:28:16 2014 New Revision: 215195 URL: https://gcc.gnu.org/viewcvs?rev=215195&root=gcc&view=rev Log: Also turn off OPTION_MASK_ABI_X32 for -m16 Backport from mainline PR target/63228 * config/i386/i386.c (ix86_option_override_internal): Also turn off OPTION_MASK_ABI_X32 for -m16. Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/config/i386/i386.c
Fixed.