1 From 3c56bfe053e26778fb137a2c4cb0af5ef1c49e38 Mon Sep 17 00:00:00 2001 2 From: David 'Digit' Turner <digit (a] google.com> 3 Date: Tue, 21 Feb 2012 14:42:55 +0100 4 Subject: Enable x86 gcc defaults 5 6 Enabling the same built-in defaults for the x86 7 toolchain as is currently done for ARM. 8 9 Change-Id: I1118569246c70496ae8e0971036916286321274c 10 --- 11 gcc-4.4.3/gcc/config.gcc | 4 +- 12 gcc-4.4.3/gcc/config/arm/linux-eabi.h | 2 +- 13 gcc-4.4.3/gcc/config/i386/linux.h | 38 +++++++++++++++++++++++++++----- 14 gcc-4.4.3/gcc/config/linux-android.h | 4 +- 15 gcc-4.6/gcc/config.gcc | 4 +- 16 gcc-4.6/gcc/config/arm/linux-eabi.h | 2 +- 17 gcc-4.6/gcc/config/i386/linux.h | 37 ++++++++++++++++++++++++++----- 18 gcc-4.6/gcc/config/linux-android.h | 12 +++++----- 19 8 files changed, 77 insertions(+), 26 deletions(-) 20 21 diff --git a/gcc-4.4.3/gcc/config.gcc b/gcc-4.4.3/gcc/config.gcc 22 index 321cf55..e758dc4 100644 23 --- a/gcc-4.4.3/gcc/config.gcc 24 +++ b/gcc-4.4.3/gcc/config.gcc 25 @@ -515,7 +515,7 @@ case ${target} in 26 tm_defines="$tm_defines OPTION_GLIBC=1";; 27 esac 28 case $target in 29 - *-*-*android*) 30 + *-*-*android* | *-android-linux-*) 31 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" 32 ;; 33 *-*-*uclibc*) 34 @@ -538,7 +538,7 @@ case ${target} in 35 esac 36 # Enable compilation for Android by default for *android* targets. 37 case $target in 38 - *-*-*android*) 39 + *-*-*android* | *-android-linux-*) 40 tm_defines="$tm_defines ANDROID_DEFAULT=1" 41 ;; 42 *) 43 diff --git a/gcc-4.4.3/gcc/config/arm/linux-eabi.h b/gcc-4.4.3/gcc/config/arm/linux-eabi.h 44 index 2ca8818..b295423 100644 45 --- a/gcc-4.4.3/gcc/config/arm/linux-eabi.h 46 +++ b/gcc-4.4.3/gcc/config/arm/linux-eabi.h 47 @@ -74,7 +74,7 @@ 48 #undef CC1_SPEC 49 #define CC1_SPEC \ 50 LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ 51 - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) 52 + LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) 53 54 #define CC1PLUS_SPEC \ 55 LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) 56 diff --git a/gcc-4.4.3/gcc/config/i386/linux.h b/gcc-4.4.3/gcc/config/i386/linux.h 57 index f3a98c2..bc2a5d5 100644 58 --- a/gcc-4.4.3/gcc/config/i386/linux.h 59 +++ b/gcc-4.4.3/gcc/config/i386/linux.h 60 @@ -72,15 +72,36 @@ along with GCC; see the file COPYING3. If not see 61 #define TARGET_OS_CPP_BUILTINS() \ 62 do \ 63 { \ 64 - LINUX_TARGET_OS_CPP_BUILTINS(); \ 65 + LINUX_TARGET_OS_CPP_BUILTINS(); \ 66 + ANDROID_TARGET_OS_CPP_BUILTINS(); \ 67 } \ 68 while (0) 69 70 #undef CPP_SPEC 71 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" 72 73 +#define OVERRIDE_LINUX_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}" 74 #undef CC1_SPEC 75 -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" 76 +#define CC1_SPEC \ 77 + LINUX_OR_ANDROID_CC (OVERRIDE_LINUX_TARGET_CC1_SPEC, \ 78 + OVERRIDE_LINUX_TARGET_CC1_SPEC \ 79 + " -march=i686 -mtune=atom" \ 80 + " -mstackrealign -msse3 -mfpmath=sse" \ 81 + " -m32 -fno-short-enums" \ 82 + " " \ 83 + ANDROID_CC1_SPEC("-fPIC")) 84 + 85 +#define CC1PLUS_SPEC \ 86 + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) 87 + 88 +#undef LIB_SPEC 89 +#define LIB_SPEC \ 90 + LINUX_OR_ANDROID_LD (LINUX_TARGET_LIB_SPEC, \ 91 + LINUX_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC) 92 + 93 +#undef STARTFILE_SPEC 94 +#define STARTFILE_SPEC \ 95 + LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) 96 97 /* Provide a LINK_SPEC appropriate for Linux. Here we provide support 98 for the special GCC options -static and -shared, which allow us to 99 @@ -121,23 +142,28 @@ along with GCC; see the file COPYING3. If not see 100 { "link_emulation", LINK_EMULATION },\ 101 { "dynamic_linker", LINUX_DYNAMIC_LINKER } 102 103 -#undef LINK_SPEC 104 -#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ 105 +#define OVERRIDE_LINUX_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ 106 %{!shared: \ 107 %{!ibcs: \ 108 %{!static: \ 109 %{rdynamic:-export-dynamic} \ 110 %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \ 111 %{static:-static}}}" 112 +#undef LINK_SPEC 113 +#define LINK_SPEC \ 114 + LINUX_OR_ANDROID_LD (OVERRIDE_LINUX_TARGET_LINK_SPEC, \ 115 + OVERRIDE_LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) 116 117 /* Similar to standard Linux, but adding -ffast-math support. */ 118 -#undef ENDFILE_SPEC 119 -#define ENDFILE_SPEC \ 120 +#define OVERRIDE_LINUX_TARGET_ENDFILE_SPEC \ 121 "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ 122 %{mpc32:crtprec32.o%s} \ 123 %{mpc64:crtprec64.o%s} \ 124 %{mpc80:crtprec80.o%s} \ 125 %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" 126 +#undef ENDFILE_SPEC 127 +#define ENDFILE_SPEC \ 128 + LINUX_OR_ANDROID_LD (OVERRIDE_LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) 129 130 /* A C statement (sans semicolon) to output to the stdio stream 131 FILE the assembler definition of uninitialized global DECL named 132 diff --git a/gcc-4.4.3/gcc/config/linux-android.h b/gcc-4.4.3/gcc/config/linux-android.h 133 index d938c22..d30e157 100644 134 --- a/gcc-4.4.3/gcc/config/linux-android.h 135 +++ b/gcc-4.4.3/gcc/config/linux-android.h 136 @@ -41,9 +41,9 @@ 137 #define ANDROID_LINK_SPEC \ 138 "%{shared: -Bsymbolic}" 139 140 -#define ANDROID_CC1_SPEC \ 141 +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ 142 "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ 143 - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" 144 + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" 145 146 #define ANDROID_CC1PLUS_SPEC \ 147 "%{!fexceptions:%{!fno-exceptions: -fexceptions}} " \ 148 diff --git a/gcc-4.6/gcc/config.gcc b/gcc-4.6/gcc/config.gcc 149 index d9ac0fa..514b0f3 100644 150 --- a/gcc-4.6/gcc/config.gcc 151 +++ b/gcc-4.6/gcc/config.gcc 152 @@ -585,7 +585,7 @@ case ${target} in 153 tm_defines="$tm_defines SINGLE_LIBC";; 154 esac 155 case $target in 156 - *-*-*android*) 157 + *-*-*android* | *-android-linux-*) 158 tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" 159 ;; 160 *-*-*uclibc*) 161 @@ -609,7 +609,7 @@ case ${target} in 162 esac 163 # Enable compilation for Android by default for *android* targets. 164 case $target in 165 - *-*-*android*) 166 + *-*-*android* | *-android-linux-*) 167 tm_defines="$tm_defines ANDROID_DEFAULT=1" 168 ;; 169 *) 170 diff --git a/gcc-4.6/gcc/config/arm/linux-eabi.h b/gcc-4.6/gcc/config/arm/linux-eabi.h 171 index 3a32188..00809d7 100644 172 --- a/gcc-4.6/gcc/config/arm/linux-eabi.h 173 +++ b/gcc-4.6/gcc/config/arm/linux-eabi.h 174 @@ -74,7 +74,7 @@ 175 #undef CC1_SPEC 176 #define CC1_SPEC \ 177 LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ 178 - GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) 179 + GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) 180 181 #define CC1PLUS_SPEC \ 182 LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) 183 diff --git a/gcc-4.6/gcc/config/i386/linux.h b/gcc-4.6/gcc/config/i386/linux.h 184 index 3a23598..78a4170 100644 185 --- a/gcc-4.6/gcc/config/i386/linux.h 186 +++ b/gcc-4.6/gcc/config/i386/linux.h 187 @@ -85,7 +85,15 @@ 188 #undef CC1_SPEC 189 #define CC1_SPEC \ 190 LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ 191 - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) 192 + LINUX_TARGET_CC1_SPEC \ 193 + " -march=i686 -mtune=atom" \ 194 + " -mstackrealign -msse3 -mfpmath=sse" \ 195 + " -m32 -fno-short-enums" \ 196 + " " \ 197 + ANDROID_CC1_SPEC("-fPIC")) 198 + 199 +#define CC1PLUS_SPEC \ 200 + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) 201 202 /* Provide a LINK_SPEC appropriate for Linux. Here we provide support 203 for the special GCC options -static and -shared, which allow us to 204 diff --git a/gcc-4.6/gcc/config/linux-android.h b/gcc-4.6/gcc/config/linux-android.h 205 index 7256082..d30e157 100644 206 --- a/gcc-4.6/gcc/config/linux-android.h 207 +++ b/gcc-4.6/gcc/config/linux-android.h 208 @@ -41,9 +41,9 @@ 209 #define ANDROID_LINK_SPEC \ 210 "%{shared: -Bsymbolic}" 211 212 -#define ANDROID_CC1_SPEC \ 213 +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ 214 "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ 215 - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" 216 + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" 217 218 #define ANDROID_CC1PLUS_SPEC \ 219 "%{!fexceptions:%{!fno-exceptions: -fexceptions}} " \ 220 -- 221 1.7.6.rc0 222 223