gcc7/gcc-4.7.0-linux32.patch
2012-07-11 13:05:14 +04:00

72 lines
2.2 KiB
Diff

--- gcc-4.7-20120128/gcc/config/i386/biarch64.h.orig 2012-01-28 22:24:56.451983823 -0200
+++ gcc-4.7-20120128/gcc/config/i386/biarch64.h 2012-01-28 22:25:26.035118110 -0200
@@ -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 <sys/syscall.h>
+#include <sys/personality.h>
+#define TARGET_32BIT_PERSONALITY \
+ ((syscall(SYS_personality, 0xffffffff) & PER_MASK) == PER_LINUX32)
+#endif
+#endif
--- gcc-4.7-20120128/gcc/opts-common.c.orig 2012-01-28 22:25:46.864212679 -0200
+++ gcc-4.7-20120128/gcc/opts-common.c 2012-01-28 22:27:47.956762260 -0200
@@ -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"
@@ -711,6 +712,10 @@ decode_cmdline_options_to_array (unsigne
unsigned int n, i;
struct cl_decoded_option *opt_array;
unsigned int num_decoded_options;
+#ifdef TARGET_32BIT_PERSONALITY
+ bool arch_flag = false;
+ bool arch_32bit = TARGET_32BIT_PERSONALITY;
+#endif
opt_array = XNEWVEC (struct cl_decoded_option, argc);
@@ -739,12 +744,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)
+ {
+ const char **argvec = XNEWVEC (const 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
+
*decoded_options = opt_array;
*decoded_options_count = num_decoded_options;
prune_options (decoded_options, decoded_options_count);