diff mbox

PATCH: Add -mandroid support on Linux/i386

Message ID 20111214171332.GD6579@intel.com
State New
Headers show

Commit Message

H.J. Lu Dec. 14, 2011, 5:13 p.m. UTC
Hi,

This patch adds -mandroid support on Linux/i386, similar to Linux/ARM.
OK for trunk in stage 1?

Thanks.


H.J.
--
2011-12-13  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/linux.h (LINUX_TARGET_CC1_SPEC): New.
	(CC1_SPEC): Use LINUX_OR_ANDROID_CC.
	(CC1PLUS_SPEC): Likewise.
	(LINUX_TARGET_LINK_SPEC): New.
	(LINK_SPEC): Support LINUX_OR_ANDROID_LD.
	(LIB_SPEC): New.
	(STARTFILE_SPEC): New.
	(LINUX_TARGET_ENDFILE_SPEC): New.
	(ENDFILE_SPEC): Support LINUX_OR_ANDROID_LD.
---
 gcc/ChangeLog.android   |   12 ++++++++++++
 gcc/config/i386/linux.h |   41 ++++++++++++++++++++++++++++++++++-------
 2 files changed, 46 insertions(+), 7 deletions(-)

Comments

Joseph Myers Dec. 16, 2011, 10:49 p.m. UTC | #1
On Wed, 14 Dec 2011, H.J. Lu wrote:

> Hi,
> 
> This patch adds -mandroid support on Linux/i386, similar to Linux/ARM.
> OK for trunk in stage 1?

This does not appear to be a patch against current trunk, but against a 
much older version.

> diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
> index 3a23598..9918036 100644
> --- a/gcc/config/i386/linux.h
> +++ b/gcc/config/i386/linux.h
> @@ -79,8 +79,15 @@ along with GCC; see the file COPYING3.  If not see
>  #undef CPP_SPEC
>  #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"

config/i386/linux.h is almost empty; it only defines things that 
definitely vary between different kernels that may be used with GNU 
userspace.  Most of the contents currently go in gnu-user.h because they 
are equally applicable with HURD, GNU/kFreeBSD etc.

> +#define LINUX_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"

> -#undef	LINK_SPEC
> -#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
> +#define LINUX_TARGET_LINK_SPEC \

For various such definitions you probably want to define GNU_USER_TARGET_* 
in gnu-user.h; define the underlying macro such as LINK_SPEC in gnu-user.h 
to be GNU_USER_TARGET_LINK_SPEC etc.; then undefine and redefine LINK_SPEC 
in linux.h to add Android support.
H.J. Lu Dec. 17, 2011, 1:44 a.m. UTC | #2
On Fri, Dec 16, 2011 at 2:49 PM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Wed, 14 Dec 2011, H.J. Lu wrote:
>
>> Hi,
>>
>> This patch adds -mandroid support on Linux/i386, similar to Linux/ARM.
>> OK for trunk in stage 1?
>
> This does not appear to be a patch against current trunk, but against a
> much older version.
>
>> diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
>> index 3a23598..9918036 100644
>> --- a/gcc/config/i386/linux.h
>> +++ b/gcc/config/i386/linux.h
>> @@ -79,8 +79,15 @@ along with GCC; see the file COPYING3.  If not see
>>  #undef CPP_SPEC
>>  #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
>
> config/i386/linux.h is almost empty; it only defines things that
> definitely vary between different kernels that may be used with GNU
> userspace.  Most of the contents currently go in gnu-user.h because they
> are equally applicable with HURD, GNU/kFreeBSD etc.
>
>> +#define LINUX_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>
>> -#undef       LINK_SPEC
>> -#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
>> +#define LINUX_TARGET_LINK_SPEC \
>
> For various such definitions you probably want to define GNU_USER_TARGET_*
> in gnu-user.h; define the underlying macro such as LINK_SPEC in gnu-user.h
> to be GNU_USER_TARGET_LINK_SPEC etc.; then undefine and redefine LINK_SPEC
> in linux.h to add Android support.
>

I will take another look.

Thanks.
diff mbox

Patch

diff --git a/gcc/ChangeLog.android b/gcc/ChangeLog.android
index fc54522..b5ae492 100644
--- a/gcc/ChangeLog.android
+++ b/gcc/ChangeLog.android
@@ -1,5 +1,17 @@ 
 2011-12-13  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* config/i386/linux.h (LINUX_TARGET_CC1_SPEC): New.
+	(CC1_SPEC): Use LINUX_OR_ANDROID_CC.
+	(CC1PLUS_SPEC): Likewise.
+	(LINUX_TARGET_LINK_SPEC): New.
+	(LINK_SPEC): Support LINUX_OR_ANDROID_LD.
+	(LIB_SPEC): New.
+	(STARTFILE_SPEC): New.
+	(LINUX_TARGET_ENDFILE_SPEC): New.
+	(ENDFILE_SPEC): Support LINUX_OR_ANDROID_LD.
+
+2011-12-13  H.J. Lu  <hongjiu.lu@intel.com>
+
 	* config/linux-android.h (ANDROID_STARTFILE_SPEC): Use
 	crtbegin_so%O%s for -shared.
 	(ANDROID_ENDFILE_SPEC): Use crtend_so%O%s for -shared.
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 3a23598..9918036 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -79,8 +79,15 @@  along with GCC; see the file COPYING3.  If not see
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
 
+#define 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 (LINUX_TARGET_CC1_SPEC, \
+		       LINUX_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#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
@@ -112,22 +119,42 @@  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 LINUX_TARGET_LINK_SPEC \
+  "-m %(link_emulation) %{shared:-shared} \
   %{!shared: \
     %{!static: \
       %{rdynamic:-export-dynamic} \
       -dynamic-linker %(dynamic_linker)} \
       %{static:-static}}"
 
+#undef	LINK_SPEC
+#define LINK_SPEC \
+  LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC, \
+		       LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
+
+#undef  LIB_SPEC
+#define LIB_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \
+		       GNU_USER_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC)
+
+#undef  STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, \
+		       ANDROID_STARTFILE_SPEC)
+
 /* Similar to standard Linux, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define LINUX_TARGET_ENDFILE_SPEC \
   "%{Ofast|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"
+   %{mpc80:crtprec80.o%s}"
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  LINUX_OR_ANDROID_LD (LINUX_TARGET_ENDFILE_SPEC " " \
+		       GNU_USER_TARGET_ENDFILE_SPEC, \
+		       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