1From ab09874f60eb601243e801dadf3395135d2df13a Mon Sep 17 00:00:00 2001 2From: David 'Digit' Turner <digit@google.com> 3Date: Fri, 4 May 2012 10:26:30 +0200 4Subject: Port MIPS Android support to GCC 4.6 5 6Change-Id: I61f4e9e41ee5f13887d75160bd7a530a864b576a 7--- 8 gcc-4.6/gcc/config.gcc | 6 ++++ 9 gcc-4.6/gcc/config/mips/linux.h | 50 ++++++++++++++++++++++++------ 10 gcc-4.6/gcc/config/mips/t-linux-android | 3 ++ 11 gcc-4.6/gcc/unwind-dw2-fde-glibc.c | 6 ++- 12 4 files changed, 53 insertions(+), 12 deletions(-) 13 create mode 100644 gcc-4.6/gcc/config/mips/t-linux-android 14 15diff --git a/gcc-4.6/gcc/config.gcc b/gcc-4.6/gcc/config.gcc 16index 514b0f3..3f1fab3 100644 17--- a/gcc-4.6/gcc/config.gcc 18+++ b/gcc-4.6/gcc/config.gcc 19@@ -1918,6 +1918,12 @@ mips*-*-linux*) # Linux MIPS, either endian. 20 mipsisa32*) 21 tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32" 22 esac 23+ case ${target} in 24+ *android*) 25+ # Default to little-endian for MIPS Android 26+ # tm_defines="${tm_defines} TARGET_ENDIAN_DEFAULT=0" 27+ tmake_file="$tmake_file mips/t-linux-android" 28+ esac 29 extra_parts="$extra_parts crtfastmath.o" 30 test x$with_llsc != x || with_llsc=yes 31 ;; 32diff --git a/gcc-4.6/gcc/config/mips/linux.h b/gcc-4.6/gcc/config/mips/linux.h 33index a78f6bc..9ee5808 100644 34--- a/gcc-4.6/gcc/config/mips/linux.h 35+++ b/gcc-4.6/gcc/config/mips/linux.h 36@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see 37 /* The GNU C++ standard library requires this. */ \ 38 if (c_dialect_cxx ()) \ 39 builtin_define ("_GNU_SOURCE"); \ 40+ ANDROID_TARGET_OS_CPP_BUILTINS(); \ 41 } while (0) 42 43 #undef SUBTARGET_CPP_SPEC 44@@ -52,8 +53,8 @@ along with GCC; see the file COPYING3. If not see 45 /* A standard GNU/Linux mapping. On most targets, it is included in 46 CC1_SPEC itself by config/linux.h, but mips.h overrides CC1_SPEC 47 and provides this hook instead. */ 48-#undef SUBTARGET_CC1_SPEC 49-#define SUBTARGET_CC1_SPEC "%{profile:-p}" 50+#undef LINUX_SUBTARGET_CC1_SPEC 51+#define LINUX_SUBTARGET_CC1_SPEC "%{profile:-p}" 52 53 /* From iris5.h */ 54 /* -G is incompatible with -KPIC which is the default, so only allow objects 55@@ -64,8 +65,8 @@ along with GCC; see the file COPYING3. If not see 56 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" 57 58 /* Borrowed from sparc/linux.h */ 59-#undef LINK_SPEC 60-#define LINK_SPEC \ 61+#undef LINUX_SUBTARGET_LINK_SPEC 62+#define LINUX_SUBTARGET_LINK_SPEC \ 63 "%(endian_spec) \ 64 %{shared:-shared} \ 65 %{!shared: \ 66@@ -99,8 +100,8 @@ along with GCC; see the file COPYING3. If not see 67 #undef ASM_OUTPUT_REG_PUSH 68 #undef ASM_OUTPUT_REG_POP 69 70-#undef LIB_SPEC 71-#define LIB_SPEC "\ 72+#undef LINUX_SUBTARGET_LIB_SPEC 73+#define LINUX_SUBTARGET_LIB_SPEC "\ 74 %{pthread:-lpthread} \ 75 %{shared:-lc} \ 76 %{!shared: \ 77@@ -131,7 +131,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); 78 #endif 79 80 #define LINUX_DRIVER_SELF_SPECS \ 81- NO_SHARED_SPECS \ 82+ LINUX_OR_ANDROID_CC(NO_SHARED_SPECS, "") \ 83 MARCH_MTUNE_NATIVE_SPECS, \ 84 /* -mplt has no effect without -mno-shared. Simplify later \ 85 specs handling by removing a redundant option. */ \ 86@@ -145,7 +146,36 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); 87 LINUX_DRIVER_SELF_SPECS 88 89 /* Similar to standard Linux, but adding -ffast-math support. */ 90-#undef ENDFILE_SPEC 91-#define ENDFILE_SPEC \ 92- "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ 93- %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" 94+#undef LINUX_TARGET_MATHFILE_SPEC 95+#define LINUX_TARGET_MATHFILE_SPEC \ 96+ "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s}" 97+ 98+#undef LINK_SPEC 99+#define LINK_SPEC \ 100+ LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LINK_SPEC, \ 101+ LINUX_SUBTARGET_LINK_SPEC " " ANDROID_LINK_SPEC) 102+ 103+#undef SUBTARGET_CC1_SPEC 104+#define SUBTARGET_CC1_SPEC \ 105+ LINUX_OR_ANDROID_CC (LINUX_SUBTARGET_CC1_SPEC, \ 106+ LINUX_SUBTARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) 107+ 108+#undef CC1PLUS_SPEC 109+#define CC1PLUS_SPEC \ 110+ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) 111+ 112+#undef LIB_SPEC 113+#define LIB_SPEC \ 114+ LINUX_OR_ANDROID_LD (LINUX_SUBTARGET_LIB_SPEC, \ 115+ LINUX_SUBTARGET_LIB_SPEC " " ANDROID_LIB_SPEC) 116+ 117+#undef STARTFILE_SPEC 118+#define STARTFILE_SPEC \ 119+ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) 120+ 121+#undef ENDFILE_SPEC 122+#define ENDFILE_SPEC \ 123+ LINUX_OR_ANDROID_LD (LINUX_TARGET_MATHFILE_SPEC " " \ 124+ GNU_USER_TARGET_ENDFILE_SPEC, \ 125+ LINUX_TARGET_MATHFILE_SPEC " " \ 126+ ANDROID_ENDFILE_SPEC) 127diff --git a/gcc-4.6/gcc/config/mips/t-linux-android b/gcc-4.6/gcc/config/mips/t-linux-android 128new file mode 100644 129index 0000000..298cad9 130--- /dev/null 131+++ b/gcc-4.6/gcc/config/mips/t-linux-android 132@@ -0,0 +1,3 @@ 133+MULTILIB_OPTIONS = mips32r2 134+MULTILIB_DIRNAMES = mips-r2 135+MULTILIB_EXCLUSIONS := 136-- 1371.7.6.rc0 138 139