From 3c56bfe053e26778fb137a2c4cb0af5ef1c49e38 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner <digit@google.com> Date: Tue, 21 Feb 2012 14:42:55 +0100 Subject: Enable x86 gcc defaults Enabling the same built-in defaults for the x86 toolchain as is currently done for ARM. Change-Id: I1118569246c70496ae8e0971036916286321274c --- gcc-4.4.3/gcc/config.gcc | 4 +- gcc-4.4.3/gcc/config/arm/linux-eabi.h | 2 +- gcc-4.4.3/gcc/config/i386/linux.h | 38 +++++++++++++++++++++++++++----- gcc-4.4.3/gcc/config/linux-android.h | 4 +- gcc-4.6/gcc/config.gcc | 4 +- gcc-4.6/gcc/config/arm/linux-eabi.h | 2 +- gcc-4.6/gcc/config/i386/linux.h | 37 ++++++++++++++++++++++++++----- gcc-4.6/gcc/config/linux-android.h | 12 +++++----- 8 files changed, 77 insertions(+), 26 deletions(-) diff --git a/gcc-4.4.3/gcc/config.gcc b/gcc-4.4.3/gcc/config.gcc index 321cf55..e758dc4 100644 --- a/gcc-4.4.3/gcc/config.gcc +++ b/gcc-4.4.3/gcc/config.gcc @@ -515,7 +515,7 @@ case ${target} in tm_defines="$tm_defines OPTION_GLIBC=1";; esac case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" ;; *-*-*uclibc*) @@ -538,7 +538,7 @@ case ${target} in esac # Enable compilation for Android by default for *android* targets. case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines ANDROID_DEFAULT=1" ;; *) diff --git a/gcc-4.4.3/gcc/config/arm/linux-eabi.h b/gcc-4.4.3/gcc/config/arm/linux-eabi.h index 2ca8818..b295423 100644 --- a/gcc-4.4.3/gcc/config/arm/linux-eabi.h +++ b/gcc-4.4.3/gcc/config/arm/linux-eabi.h @@ -74,7 +74,7 @@ #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) diff --git a/gcc-4.4.3/gcc/config/i386/linux.h b/gcc-4.4.3/gcc/config/i386/linux.h index f3a98c2..bc2a5d5 100644 --- a/gcc-4.4.3/gcc/config/i386/linux.h +++ b/gcc-4.4.3/gcc/config/i386/linux.h @@ -72,15 +72,36 @@ along with GCC; see the file COPYING3. If not see #define TARGET_OS_CPP_BUILTINS() \ do \ { \ - LINUX_TARGET_OS_CPP_BUILTINS(); \ + LINUX_TARGET_OS_CPP_BUILTINS(); \ + ANDROID_TARGET_OS_CPP_BUILTINS(); \ } \ while (0) #undef CPP_SPEC #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" +#define OVERRIDE_LINUX_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}" #undef CC1_SPEC -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}" +#define CC1_SPEC \ + LINUX_OR_ANDROID_CC (OVERRIDE_LINUX_TARGET_CC1_SPEC, \ + OVERRIDE_LINUX_TARGET_CC1_SPEC \ + " -march=i686 -mtune=atom" \ + " -mstackrealign -msse3 -mfpmath=sse" \ + " -m32 -fno-short-enums" \ + " " \ + ANDROID_CC1_SPEC("-fPIC")) + +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) + +#undef LIB_SPEC +#define LIB_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_LIB_SPEC, \ + LINUX_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC) + +#undef STARTFILE_SPEC +#define STARTFILE_SPEC \ + LINUX_OR_ANDROID_LD (LINUX_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC) /* Provide a LINK_SPEC appropriate for Linux. Here we provide support for the special GCC options -static and -shared, which allow us to @@ -121,23 +142,28 @@ along with GCC; see the file COPYING3. If not see { "link_emulation", LINK_EMULATION },\ { "dynamic_linker", LINUX_DYNAMIC_LINKER } -#undef LINK_SPEC -#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ +#define OVERRIDE_LINUX_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \ %{!shared: \ %{!ibcs: \ %{!static: \ %{rdynamic:-export-dynamic} \ %{!dynamic-linker:-dynamic-linker %(dynamic_linker)}} \ %{static:-static}}}" +#undef LINK_SPEC +#define LINK_SPEC \ + LINUX_OR_ANDROID_LD (OVERRIDE_LINUX_TARGET_LINK_SPEC, \ + OVERRIDE_LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC) /* Similar to standard Linux, but adding -ffast-math support. */ -#undef ENDFILE_SPEC -#define ENDFILE_SPEC \ +#define OVERRIDE_LINUX_TARGET_ENDFILE_SPEC \ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ %{mpc32:crtprec32.o%s} \ %{mpc64:crtprec64.o%s} \ %{mpc80:crtprec80.o%s} \ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" +#undef ENDFILE_SPEC +#define ENDFILE_SPEC \ + LINUX_OR_ANDROID_LD (OVERRIDE_LINUX_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC) /* A C statement (sans semicolon) to output to the stdio stream FILE the assembler definition of uninitialized global DECL named diff --git a/gcc-4.4.3/gcc/config/linux-android.h b/gcc-4.4.3/gcc/config/linux-android.h index d938c22..d30e157 100644 --- a/gcc-4.4.3/gcc/config/linux-android.h +++ b/gcc-4.4.3/gcc/config/linux-android.h @@ -41,9 +41,9 @@ #define ANDROID_LINK_SPEC \ "%{shared: -Bsymbolic}" -#define ANDROID_CC1_SPEC \ +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" #define ANDROID_CC1PLUS_SPEC \ "%{!fexceptions:%{!fno-exceptions: -fexceptions}} " \ diff --git a/gcc-4.6/gcc/config.gcc b/gcc-4.6/gcc/config.gcc index d9ac0fa..514b0f3 100644 --- a/gcc-4.6/gcc/config.gcc +++ b/gcc-4.6/gcc/config.gcc @@ -585,7 +585,7 @@ case ${target} in tm_defines="$tm_defines SINGLE_LIBC";; esac case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC" ;; *-*-*uclibc*) @@ -609,7 +609,7 @@ case ${target} in esac # Enable compilation for Android by default for *android* targets. case $target in - *-*-*android*) + *-*-*android* | *-android-linux-*) tm_defines="$tm_defines ANDROID_DEFAULT=1" ;; *) diff --git a/gcc-4.6/gcc/config/arm/linux-eabi.h b/gcc-4.6/gcc/config/arm/linux-eabi.h index 3a32188..00809d7 100644 --- a/gcc-4.6/gcc/config/arm/linux-eabi.h +++ b/gcc-4.6/gcc/config/arm/linux-eabi.h @@ -74,7 +74,7 @@ #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ - GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC("-fpic")) #define CC1PLUS_SPEC \ LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) diff --git a/gcc-4.6/gcc/config/i386/linux.h b/gcc-4.6/gcc/config/i386/linux.h index 3a23598..78a4170 100644 --- a/gcc-4.6/gcc/config/i386/linux.h +++ b/gcc-4.6/gcc/config/i386/linux.h @@ -85,7 +85,15 @@ #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (LINUX_TARGET_CC1_SPEC, \ - LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC) + LINUX_TARGET_CC1_SPEC \ + " -march=i686 -mtune=atom" \ + " -mstackrealign -msse3 -mfpmath=sse" \ + " -m32 -fno-short-enums" \ + " " \ + ANDROID_CC1_SPEC("-fPIC")) + +#define CC1PLUS_SPEC \ + LINUX_OR_ANDROID_CC ("", ANDROID_CC1PLUS_SPEC) /* Provide a LINK_SPEC appropriate for Linux. Here we provide support for the special GCC options -static and -shared, which allow us to diff --git a/gcc-4.6/gcc/config/linux-android.h b/gcc-4.6/gcc/config/linux-android.h index 7256082..d30e157 100644 --- a/gcc-4.6/gcc/config/linux-android.h +++ b/gcc-4.6/gcc/config/linux-android.h @@ -41,9 +41,9 @@ #define ANDROID_LINK_SPEC \ "%{shared: -Bsymbolic}" -#define ANDROID_CC1_SPEC \ +#define ANDROID_CC1_SPEC(ANDROID_PIC_DEFAULT) \ "%{!mglibc:%{!muclibc:%{!mbionic: -mbionic}}} " \ - "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: -fPIC}}}}" + "%{!fno-pic:%{!fno-PIC:%{!fpic:%{!fPIC: " ANDROID_PIC_DEFAULT "}}}}" #define ANDROID_CC1PLUS_SPEC \ "%{!fexceptions:%{!fno-exceptions: -fexceptions}} " \ -- 1.7.6.rc0