diff mbox

[i386,Android] -mandroid support for i386 target

Message ID CAMbmDYaCrH-WjE5oerBBV_f_YFbewYR7U3LXZuyq1QiEKzMkyw@mail.gmail.com
State New
Headers show

Commit Message

Ilya Enkovich Feb. 22, 2012, 2:54 p.m. UTC
Hello,

This patch adds -mandroid support to i386 target. OK for trunk?

Thanks,
Ilya
--

2012-02-22  Enkovich Ilya  <ilya.enkovich@intel.com>

	* config/i386/gnu-user.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.

	* config/linux-android.h (ANDROID_STARTFILE_SPEC): Use
	crtbegin_so%O%s for -shared.
	(ANDROID_ENDFILE_SPEC): Use crtend_so%O%s for -shared.

Comments

H.J. Lu Feb. 22, 2012, 5:37 p.m. UTC | #1
On Wed, Feb 22, 2012 at 6:54 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hello,
>
> This patch adds -mandroid support to i386 target. OK for trunk?
>
> Thanks,
> Ilya
> --
>
> 2012-02-22  Enkovich Ilya  <ilya.enkovich@intel.com>
>
>        * config/i386/gnu-user.h (LINUX_TARGET_CC1_SPEC): New.

I don't think you should define LINUX_* in gnu-user.h.

>        (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.

There is a feedback at

http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01283.html

to my earlier patch to define GNU_USER_TARGET_* in gnu-user.h
and use them in linux.h.

>        * config/linux-android.h (ANDROID_STARTFILE_SPEC): Use
>        crtbegin_so%O%s for -shared.
>        (ANDROID_ENDFILE_SPEC): Use crtend_so%O%s for -shared.
>
>

I think you should separate this part similar to

http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01109.html
diff mbox

Patch

diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 98d0a25..f114432 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -77,8 +77,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 GNU userspace.  Here we provide support
    for the special GCC options -static and -shared, which allow us to
@@ -97,22 +104,42 @@  along with GCC; see the file COPYING3.  If not see
   { "link_emulation", GNU_USER_LINK_EMULATION },\
   { "dynamic_linker", GNU_USER_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 GNU userspace, 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
diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h
index 94c5274..acbc662 100644
--- a/gcc/config/linux-android.h
+++ b/gcc/config/linux-android.h
@@ -53,8 +53,8 @@ 
   "%{!static: -ldl}"

 #define ANDROID_STARTFILE_SPEC						\
-  "%{!shared:"								\
+  "%{shared: crtbegin_so%O%s;:"						\
   "  %{static: crtbegin_static%O%s;: crtbegin_dynamic%O%s}}"

 #define ANDROID_ENDFILE_SPEC \
-  "%{!shared: crtend_android%O%s}"
+  "%{shared: crtend_so%O%s;: crtend_android%O%s}"