--- gcc-4.6-20110415/gcc/config/i386/biarch64.h.orig 2011-04-24 05:41:14.296592400 -0300 +++ gcc-4.6-20110415/gcc/config/i386/biarch64.h 2011-04-24 05:41:32.776642363 -0300 @@ -27,3 +27,12 @@ see the files COPYING3 and COPYING.RUNTI #define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT #define TARGET_BI_ARCH 1 + +#if defined(__linux__) +#ifndef inhibit_libc +#include +#include +#define TARGET_32BIT_PERSONALITY \ + ((syscall(SYS_personality, 0xffffffff) & PER_MASK) == PER_LINUX32) +#endif +#endif --- gcc-4.6-20110415/gcc/opts-common.c.orig 2011-04-24 05:41:22.864615786 -0300 +++ gcc-4.6-20110415/gcc/opts-common.c 2011-04-24 05:41:59.006715082 -0300 @@ -21,6 +21,7 @@ along with GCC; see the file COPYING3. #include "system.h" #include "intl.h" #include "coretypes.h" +#include "tm.h" #include "opts.h" #include "flags.h" #include "diagnostic.h" @@ -678,6 +679,10 @@ decode_cmdline_options_to_array (unsigne struct cl_decoded_option *opt_array; unsigned int num_decoded_options; bool argv_copied = false; +#ifdef TARGET_32BIT_PERSONALITY + bool arch_flag = false; + bool arch_32bit = TARGET_32BIT_PERSONALITY; +#endif opt_array = XNEWVEC (struct cl_decoded_option, argc); @@ -706,12 +711,34 @@ decode_cmdline_options_to_array (unsigne n = 1; continue; } - +#ifdef TARGET_32BIT_PERSONALITY + if (!arch_flag && arch_32bit + && opt[1] == 'm' && ((opt[2] == '3' && opt[3] == '2') + || (opt[2] == '6' && opt[3] == '4')) + && opt[4] == '\0') + arch_flag = true; +#endif n = decode_cmdline_option (argv + i, lang_mask, &opt_array[num_decoded_options]); num_decoded_options++; } +#ifdef TARGET_32BIT_PERSONALITY + if (!arch_flag && arch_32bit) + { + char **argvec = XNEWVEC (char *, 2); + + argvec[0] = "-m32"; + argvec[1] = NULL; + if (++num_decoded_options > argc) + opt_array = XRESIZEVEC (struct cl_decoded_option, + opt_array, num_decoded_options); + (void)decode_cmdline_option (argvec, lang_mask, + &opt_array[num_decoded_options - 1]); + free (argvec); + } +#endif + if (argv_copied) free (argv); *decoded_options = opt_array;