public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, i386, Android] -mandroid support for i386 target
@ 2012-02-22 14:58 Ilya Enkovich
  2012-02-22 17:50 ` H.J. Lu
  0 siblings, 1 reply; 26+ messages in thread
From: Ilya Enkovich @ 2012-02-22 14:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: pavel.v.chupin, Jing Yu, H.J. Lu

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.


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}"

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-22 14:58 [PATCH, i386, Android] -mandroid support for i386 target Ilya Enkovich
@ 2012-02-22 17:50 ` H.J. Lu
  2012-02-24 15:57   ` Ilya Enkovich
  0 siblings, 1 reply; 26+ messages in thread
From: H.J. Lu @ 2012-02-22 17:50 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches, pavel.v.chupin, Jing Yu

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


-- 
H.J.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-22 17:50 ` H.J. Lu
@ 2012-02-24 15:57   ` Ilya Enkovich
  2012-02-24 16:17     ` H.J. Lu
  0 siblings, 1 reply; 26+ messages in thread
From: Ilya Enkovich @ 2012-02-24 15:57 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, pavel.v.chupin, Jing Yu

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

Thanks for the link. I fixed patch according to this feedback.

>>        * 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

I removed this part from the patch.

>
>
> --
> H.J.

Here is a new patch version. Does it look better?

Thanks,
Ilya
--

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

	* gcc/config/i386/gnu-user.h (CC1_SPEC): Rename to ...
	(GNU_USER_TARGET_CC1_SPEC): ... this.
	(LINK_SPEC): Rename to ...
	(GNU_USER_TARGET_LINK_SPEC): ... this.
	(ENDFILE_SPEC): Delete.
	(GNU_USER_TARGET_MATHFILE_SPEC): New.

	* gcc/config/i386/linux.h (CC1_SPEC): New.
	(LINK_SPEC): New.
	(LIB_SPEC): New.
	(STARTFILE_SPEC): New.
	(ENDFILE_SPEC): New.


diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 98d0a25..59d7062 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -77,8 +77,8 @@ along with GCC; see the file COPYING3.  If not see
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"

-#undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
+#undef GNU_USER_TARGET_CC1_SPEC
+#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"

 /* 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,8 +97,8 @@ 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 GNU_USER_TARGET_LINK_SPEC \
+  "-m %(link_emulation) %{shared:-shared} \
   %{!shared: \
     %{!static: \
       %{rdynamic:-export-dynamic} \
@@ -106,13 +106,11 @@ along with GCC; see the file COPYING3.  If not see
       %{static:-static}}"

 /* Similar to standard GNU userspace, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define GNU_USER_TARGET_MATHFILE_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}"

 /* 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/i386/linux.h b/gcc/config/i386/linux.h
index 73681fe..a832ddc 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see

 #define GNU_USER_LINK_EMULATION "elf_i386"
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+#undef CC1_SPEC
+#define CC1_SPEC \
+  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
+		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#undef	LINK_SPEC
+#define LINK_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
+		       GNU_USER_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)
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
+		       GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-24 15:57   ` Ilya Enkovich
@ 2012-02-24 16:17     ` H.J. Lu
  2012-02-27 15:19       ` Ilya Enkovich
  0 siblings, 1 reply; 26+ messages in thread
From: H.J. Lu @ 2012-02-24 16:17 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: gcc-patches, pavel.v.chupin, Jing Yu

On Fri, Feb 24, 2012 at 7:17 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 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.
>>
>
> Thanks for the link. I fixed patch according to this feedback.
>
>>>        * 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
>
> I removed this part from the patch.
>
>>
>>
>> --
>> H.J.
>
> Here is a new patch version. Does it look better?
>
> Thanks,
> Ilya
> --
>
> 2012-02-24  Enkovich Ilya  <ilya.enkovich@intel.com>
>
>        * gcc/config/i386/gnu-user.h (CC1_SPEC): Rename to ...
>        (GNU_USER_TARGET_CC1_SPEC): ... this.
>        (LINK_SPEC): Rename to ...
>        (GNU_USER_TARGET_LINK_SPEC): ... this.
>        (ENDFILE_SPEC): Delete.
>        (GNU_USER_TARGET_MATHFILE_SPEC): New.
>

You should keep those *_SPEC and define them with new
GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
by other non-linux targets.  In linux.h, you undef *_SPEC
before defining them.


-- 
H.J.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-24 16:17     ` H.J. Lu
@ 2012-02-27 15:19       ` Ilya Enkovich
  2012-03-13 11:13         ` Ilya Enkovich
                           ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-02-27 15:19 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, pavel.v.chupin, Jing Yu

> You should keep those *_SPEC and define them with new
> GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
> by other non-linux targets.  In linux.h, you undef *_SPEC
> before defining them.
>
>
> --
> H.J.

Thanks for the note. Here is fixed version. Is it OK now?

Thanks,
Ilya
--
2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>

	* gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
	(CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
	(GNU_USER_TARGET_LINK_SPEC): New.
	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
	(GNU_USER_TARGET_MATHFILE_SPEC): New.
	(ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.

	* gcc/config/i386/linux.h (CC1_SPEC): New.
	(LINK_SPEC): New.
	(LIB_SPEC): New.
	(STARTFILE_SPEC): New.
	(ENDFILE_SPEC): New.


diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 98d0a25..33ceab7 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -77,8 +77,11 @@ along with GCC; see the file COPYING3.  If not see
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"

+#undef GNU_USER_TARGET_CC1_SPEC
+#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
+
 #undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
+#define CC1_SPEC GNU_USER_TARGET_CC1_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 +100,28 @@ 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 GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
+
 /* Similar to standard GNU userspace, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define GNU_USER_TARGET_MATHFILE_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 \
+  GNU_USER_TARGET_MATHFILE_SPEC " " \
+  GNU_USER_TARGET_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/i386/linux.h b/gcc/config/i386/linux.h
index 73681fe..a832ddc 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see

 #define GNU_USER_LINK_EMULATION "elf_i386"
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+#undef CC1_SPEC
+#define CC1_SPEC \
+  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
+		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#undef	LINK_SPEC
+#define LINK_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
+		       GNU_USER_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)
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
+		       GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-27 15:19       ` Ilya Enkovich
@ 2012-03-13 11:13         ` Ilya Enkovich
  2012-03-27 13:56           ` Ilya Enkovich
  2012-03-29  4:21         ` Maxim Kuvyrkov
  2012-03-29 17:49         ` Jan Hubicka
  2 siblings, 1 reply; 26+ messages in thread
From: Ilya Enkovich @ 2012-03-13 11:13 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, pavel.v.chupin, Jing Yu

Ping

27 февраля 2012 г. 6:41 пользователь Ilya Enkovich
<enkovich.gnu@gmail.com> написал:
>> You should keep those *_SPEC and define them with new
>> GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
>> by other non-linux targets.  In linux.h, you undef *_SPEC
>> before defining them.
>>
>>
>> --
>> H.J.
>
> Thanks for the note. Here is fixed version. Is it OK now?
>
> Thanks,
> Ilya
> --
> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
>
>        * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
>        (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
>        (GNU_USER_TARGET_LINK_SPEC): New.
>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>        (GNU_USER_TARGET_MATHFILE_SPEC): New.
>        (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
>
>        * gcc/config/i386/linux.h (CC1_SPEC): New.
>        (LINK_SPEC): New.
>        (LIB_SPEC): New.
>        (STARTFILE_SPEC): New.
>        (ENDFILE_SPEC): New.
>
>
> diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
> index 98d0a25..33ceab7 100644
> --- a/gcc/config/i386/gnu-user.h
> +++ b/gcc/config/i386/gnu-user.h
> @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3.  If not see
>  #undef CPP_SPEC
>  #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
>
> +#undef GNU_USER_TARGET_CC1_SPEC
> +#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
> +
>  #undef CC1_SPEC
> -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
> +#define CC1_SPEC GNU_USER_TARGET_CC1_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 +100,28 @@ 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 GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
> +
>  /* Similar to standard GNU userspace, but adding -ffast-math support.  */
> -#undef  ENDFILE_SPEC
> -#define ENDFILE_SPEC \
> +#define GNU_USER_TARGET_MATHFILE_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 \
> +  GNU_USER_TARGET_MATHFILE_SPEC " " \
> +  GNU_USER_TARGET_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/i386/linux.h b/gcc/config/i386/linux.h
> index 73681fe..a832ddc 100644
> --- a/gcc/config/i386/linux.h
> +++ b/gcc/config/i386/linux.h
> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
>
>  #define GNU_USER_LINK_EMULATION "elf_i386"
>  #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
> +
> +#undef CC1_SPEC
> +#define CC1_SPEC \
> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
> +                      GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
> +
> +#undef LINK_SPEC
> +#define LINK_SPEC \
> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
> +                      GNU_USER_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)
> +
> +#undef  ENDFILE_SPEC
> +#define ENDFILE_SPEC \
> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
> +                      GNU_USER_TARGET_ENDFILE_SPEC,     \
> +                      GNU_USER_TARGET_MATHFILE_SPEC " " \
> +                      ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-03-13 11:13         ` Ilya Enkovich
@ 2012-03-27 13:56           ` Ilya Enkovich
  2012-03-28 22:58             ` Jing Yu
  0 siblings, 1 reply; 26+ messages in thread
From: Ilya Enkovich @ 2012-03-27 13:56 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, pavel.v.chupin, Jing Yu

Ping

13 марта 2012 г. 15:13 пользователь Ilya Enkovich
<enkovich.gnu@gmail.com> написал:
> Ping
>
> 27 февраля 2012 г. 6:41 пользователь Ilya Enkovich
> <enkovich.gnu@gmail.com> написал:
>>> You should keep those *_SPEC and define them with new
>>> GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
>>> by other non-linux targets.  In linux.h, you undef *_SPEC
>>> before defining them.
>>>
>>>
>>> --
>>> H.J.
>>
>> Thanks for the note. Here is fixed version. Is it OK now?
>>
>> Thanks,
>> Ilya
>> --
>> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
>>
>>        * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
>>        (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
>>        (GNU_USER_TARGET_LINK_SPEC): New.
>>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>>        (GNU_USER_TARGET_MATHFILE_SPEC): New.
>>        (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
>>
>>        * gcc/config/i386/linux.h (CC1_SPEC): New.
>>        (LINK_SPEC): New.
>>        (LIB_SPEC): New.
>>        (STARTFILE_SPEC): New.
>>        (ENDFILE_SPEC): New.
>>
>>
>> diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
>> index 98d0a25..33ceab7 100644
>> --- a/gcc/config/i386/gnu-user.h
>> +++ b/gcc/config/i386/gnu-user.h
>> @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3.  If not see
>>  #undef CPP_SPEC
>>  #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
>>
>> +#undef GNU_USER_TARGET_CC1_SPEC
>> +#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>> +
>>  #undef CC1_SPEC
>> -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>> +#define CC1_SPEC GNU_USER_TARGET_CC1_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 +100,28 @@ 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 GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
>> +
>>  /* Similar to standard GNU userspace, but adding -ffast-math support.  */
>> -#undef  ENDFILE_SPEC
>> -#define ENDFILE_SPEC \
>> +#define GNU_USER_TARGET_MATHFILE_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 \
>> +  GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +  GNU_USER_TARGET_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/i386/linux.h b/gcc/config/i386/linux.h
>> index 73681fe..a832ddc 100644
>> --- a/gcc/config/i386/linux.h
>> +++ b/gcc/config/i386/linux.h
>> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
>>
>>  #define GNU_USER_LINK_EMULATION "elf_i386"
>>  #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
>> +
>> +#undef CC1_SPEC
>> +#define CC1_SPEC \
>> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
>> +                      GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
>> +
>> +#undef LINK_SPEC
>> +#define LINK_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
>> +                      GNU_USER_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)
>> +
>> +#undef  ENDFILE_SPEC
>> +#define ENDFILE_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +                      GNU_USER_TARGET_ENDFILE_SPEC,     \
>> +                      GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +                      ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-03-27 13:56           ` Ilya Enkovich
@ 2012-03-28 22:58             ` Jing Yu
  0 siblings, 0 replies; 26+ messages in thread
From: Jing Yu @ 2012-03-28 22:58 UTC (permalink / raw)
  To: rth, jh, ubizjak; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Ilya Enkovich

This patch looks good for Android toolchain. But I am not a maintainer.
Can any x86 backend maintainer help to review the patch?

Thanks,
Jing

On Tue, Mar 27, 2012 at 6:55 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Ping
>
> 13 марта 2012 г. 15:13 пользователь Ilya Enkovich
> <enkovich.gnu@gmail.com> написал:
>> Ping
>>
>> 27 февраля 2012 г. 6:41 пользователь Ilya Enkovich
>> <enkovich.gnu@gmail.com> написал:
>>>> You should keep those *_SPEC and define them with new
>>>> GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
>>>> by other non-linux targets.  In linux.h, you undef *_SPEC
>>>> before defining them.
>>>>
>>>>
>>>> --
>>>> H.J.
>>>
>>> Thanks for the note. Here is fixed version. Is it OK now?
>>>
>>> Thanks,
>>> Ilya
>>> --
>>> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
>>>
>>>        * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
>>>        (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
>>>        (GNU_USER_TARGET_LINK_SPEC): New.
>>>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>>>        (GNU_USER_TARGET_MATHFILE_SPEC): New.
>>>        (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
>>>
>>>        * gcc/config/i386/linux.h (CC1_SPEC): New.
>>>        (LINK_SPEC): New.
>>>        (LIB_SPEC): New.
>>>        (STARTFILE_SPEC): New.
>>>        (ENDFILE_SPEC): New.
>>>
>>>
>>> diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
>>> index 98d0a25..33ceab7 100644
>>> --- a/gcc/config/i386/gnu-user.h
>>> +++ b/gcc/config/i386/gnu-user.h
>>> @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3.  If not see
>>>  #undef CPP_SPEC
>>>  #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
>>>
>>> +#undef GNU_USER_TARGET_CC1_SPEC
>>> +#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>>> +
>>>  #undef CC1_SPEC
>>> -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>>> +#define CC1_SPEC GNU_USER_TARGET_CC1_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 +100,28 @@ 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 GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
>>> +
>>>  /* Similar to standard GNU userspace, but adding -ffast-math support.  */
>>> -#undef  ENDFILE_SPEC
>>> -#define ENDFILE_SPEC \
>>> +#define GNU_USER_TARGET_MATHFILE_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 \
>>> +  GNU_USER_TARGET_MATHFILE_SPEC " " \
>>> +  GNU_USER_TARGET_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/i386/linux.h b/gcc/config/i386/linux.h
>>> index 73681fe..a832ddc 100644
>>> --- a/gcc/config/i386/linux.h
>>> +++ b/gcc/config/i386/linux.h
>>> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
>>>
>>>  #define GNU_USER_LINK_EMULATION "elf_i386"
>>>  #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
>>> +
>>> +#undef CC1_SPEC
>>> +#define CC1_SPEC \
>>> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
>>> +                      GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
>>> +
>>> +#undef LINK_SPEC
>>> +#define LINK_SPEC \
>>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
>>> +                      GNU_USER_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)
>>> +
>>> +#undef  ENDFILE_SPEC
>>> +#define ENDFILE_SPEC \
>>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
>>> +                      GNU_USER_TARGET_ENDFILE_SPEC,     \
>>> +                      GNU_USER_TARGET_MATHFILE_SPEC " " \
>>> +                      ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-27 15:19       ` Ilya Enkovich
  2012-03-13 11:13         ` Ilya Enkovich
@ 2012-03-29  4:21         ` Maxim Kuvyrkov
  2012-04-01 15:23           ` Ilya Enkovich
  2012-03-29 17:49         ` Jan Hubicka
  2 siblings, 1 reply; 26+ messages in thread
From: Maxim Kuvyrkov @ 2012-03-29  4:21 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

On 28/02/2012, at 3:41 AM, Ilya Enkovich wrote:

>> You should keep those *_SPEC and define them with new
>> GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
>> by other non-linux targets.  In linux.h, you undef *_SPEC
>> before defining them.
>> 
>> 
>> --
>> H.J.
> 
> Thanks for the note. Here is fixed version. Is it OK now?

This version looks mostly OK, but still needs a bit of work and testing.

How did you test this patch?  You should have built before- and after-patch compilers for both Linux and Android and run regression testsuites at least for Linux, and make sure there are no new failures.

As is, it appears this patch did not see much testing, I'm pretty sure it breaks building shared libraries and PIE executable for Linux.


> 
> Thanks,
> Ilya
> --
> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
> 
> 	* gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
> 	(CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
> 	(GNU_USER_TARGET_LINK_SPEC): New.
> 	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
> 	(GNU_USER_TARGET_MATHFILE_SPEC): New.
> 	(ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
> 
> 	* gcc/config/i386/linux.h (CC1_SPEC): New.
> 	(LINK_SPEC): New.
> 	(LIB_SPEC): New.
> 	(STARTFILE_SPEC): New.
> 	(ENDFILE_SPEC): New.
> 
> 
> diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
> index 98d0a25..33ceab7 100644
> --- a/gcc/config/i386/gnu-user.h
> +++ b/gcc/config/i386/gnu-user.h
> @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3.  If not see
> #undef CPP_SPEC
> #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
> 
> +#undef GNU_USER_TARGET_CC1_SPEC
> +#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"

Here and in other instances below you use "GNU_USER_TARGET_" prefix.  I would prefer using a shorter "GNU_USER_" instead unless there is a good reason to add "TARGET" too.

> +
> #undef CC1_SPEC
> -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
> +#define CC1_SPEC GNU_USER_TARGET_CC1_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 +100,28 @@ 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 GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
> +
> /* Similar to standard GNU userspace, but adding -ffast-math support.  */
> -#undef  ENDFILE_SPEC
> -#define ENDFILE_SPEC \
> +#define GNU_USER_TARGET_MATHFILE_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 \
> +  GNU_USER_TARGET_MATHFILE_SPEC " " \
> +  GNU_USER_TARGET_ENDFILE_SPEC

Here you remove "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s".  Presumably, you are moving that to GNU_USER[_TARGET]_ENDFILE_SPEC, but you never define it.

> 
> /* 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/i386/linux.h b/gcc/config/i386/linux.h
> index 73681fe..a832ddc 100644
> --- a/gcc/config/i386/linux.h
> +++ b/gcc/config/i386/linux.h

i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains.  Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds.  I improve on this situation I suggest:
- rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc),
- put below definitions to new i386/linux.h (remember to add license notice header to the new file),
- include i386/linux.h from both i386/linux32.h and i386/linux64.h.

> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
> 
> #define GNU_USER_LINK_EMULATION "elf_i386"
> #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
> +
> +#undef CC1_SPEC
> +#define CC1_SPEC \
> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
> +		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
> +
> +#undef	LINK_SPEC
> +#define LINK_SPEC \
> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
> +		       GNU_USER_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)
> +
> +#undef  ENDFILE_SPEC
> +#define ENDFILE_SPEC \
> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
> +		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
> +		       GNU_USER_TARGET_MATHFILE_SPEC " " \
> +		       ANDROID_ENDFILE_SPEC)


--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-02-27 15:19       ` Ilya Enkovich
  2012-03-13 11:13         ` Ilya Enkovich
  2012-03-29  4:21         ` Maxim Kuvyrkov
@ 2012-03-29 17:49         ` Jan Hubicka
  2012-04-01 15:39           ` Ilya Enkovich
  2012-04-01 19:40           ` Maxim Kuvyrkov
  2 siblings, 2 replies; 26+ messages in thread
From: Jan Hubicka @ 2012-03-29 17:49 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
> 
> 	* gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
> 	(CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
> 	(GNU_USER_TARGET_LINK_SPEC): New.
> 	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
> 	(GNU_USER_TARGET_MATHFILE_SPEC): New.
> 	(ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
> 
> 	* gcc/config/i386/linux.h (CC1_SPEC): New.
> 	(LINK_SPEC): New.
> 	(LIB_SPEC): New.
> 	(STARTFILE_SPEC): New.
> 	(ENDFILE_SPEC): New.
OK.
I guess the patch now follows quite closely the arm implementation, right?
I am not quite sure if it makes sense to go around hassle and breaking up
the following into generic linux-or-android.h?

Honza

> diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
> index 73681fe..a832ddc 100644
> --- a/gcc/config/i386/linux.h
> +++ b/gcc/config/i386/linux.h
> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
> 
>  #define GNU_USER_LINK_EMULATION "elf_i386"
>  #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
> +
> +#undef CC1_SPEC
> +#define CC1_SPEC \
> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
> +		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
> +
> +#undef	LINK_SPEC
> +#define LINK_SPEC \
> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
> +		       GNU_USER_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)
> +
> +#undef  ENDFILE_SPEC
> +#define ENDFILE_SPEC \
> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
> +		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
> +		       GNU_USER_TARGET_MATHFILE_SPEC " " \
> +		       ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-03-29  4:21         ` Maxim Kuvyrkov
@ 2012-04-01 15:23           ` Ilya Enkovich
  2012-04-01 16:13             ` H.J. Lu
  2012-04-01 19:33             ` Maxim Kuvyrkov
  0 siblings, 2 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-01 15:23 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

Hello Maxim,

Thanks a lot for review. My comments are below.

> On 28/02/2012, at 3:41 AM, Ilya Enkovich wrote:
>
>>> You should keep those *_SPEC and define them with new
>>> GNU_*_SPEC in gnu-user.h since gnu-user.h is also used
>>> by other non-linux targets.  In linux.h, you undef *_SPEC
>>> before defining them.
>>>
>>>
>>> --
>>> H.J.
>>
>> Thanks for the note. Here is fixed version. Is it OK now?
>
> This version looks mostly OK, but still needs a bit of work and testing.
>
> How did you test this patch?  You should have built before- and after-patch compilers for both Linux and Android and run regression testsuites at least for Linux, and make sure there are no new failures.
>
> As is, it appears this patch did not see much testing, I'm pretty sure it breaks building shared libraries and PIE executable for Linux.

I do not expect any changes in compiler behavior for non Android
targets. I bootstrapped and checked patched compiler on linux-x86_64.
I also built ptched compiler for Android target using NDK scripts.

>
>
>>
>> Thanks,
>> Ilya
>> --
>> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
>>
>>       * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
>>       (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
>>       (GNU_USER_TARGET_LINK_SPEC): New.
>>       (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>>       (GNU_USER_TARGET_MATHFILE_SPEC): New.
>>       (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
>>
>>       * gcc/config/i386/linux.h (CC1_SPEC): New.
>>       (LINK_SPEC): New.
>>       (LIB_SPEC): New.
>>       (STARTFILE_SPEC): New.
>>       (ENDFILE_SPEC): New.
>>
>>
>> diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
>> index 98d0a25..33ceab7 100644
>> --- a/gcc/config/i386/gnu-user.h
>> +++ b/gcc/config/i386/gnu-user.h
>> @@ -77,8 +77,11 @@ along with GCC; see the file COPYING3.  If not see
>> #undef CPP_SPEC
>> #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
>>
>> +#undef GNU_USER_TARGET_CC1_SPEC
>> +#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>
> Here and in other instances below you use "GNU_USER_TARGET_" prefix.  I would prefer using a shorter "GNU_USER_" instead unless there is a good reason to add "TARGET" too.

The reason is that some macroses are defined in other files and I just
redefine them (i.e. GNU_USER_TARGET_CC1_SPEC). This prefix is also
used for other targets (i.e. in linux-eabi.h). So I do not see a good
reason to change it everywhere or mix it with other prefix
"GNU_USER_".

>
>> +
>> #undef CC1_SPEC
>> -#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
>> +#define CC1_SPEC GNU_USER_TARGET_CC1_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 +100,28 @@ 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 GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
>> +
>> /* Similar to standard GNU userspace, but adding -ffast-math support.  */
>> -#undef  ENDFILE_SPEC
>> -#define ENDFILE_SPEC \
>> +#define GNU_USER_TARGET_MATHFILE_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 \
>> +  GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +  GNU_USER_TARGET_ENDFILE_SPEC
>
> Here you remove "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s".  Presumably, you are moving that to GNU_USER[_TARGET]_ENDFILE_SPEC, but you never define it.

You are right. It is in GNU_USER_TARGET_ENDFILE_SPEC which is defined
in gcc/config/gnu-user.h.

>
>>
>> /* 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/i386/linux.h b/gcc/config/i386/linux.h
>> index 73681fe..a832ddc 100644
>> --- a/gcc/config/i386/linux.h
>> +++ b/gcc/config/i386/linux.h
>
> i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains.  Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds.  I improve on this situation I suggest:
> - rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc),
> - put below definitions to new i386/linux.h (remember to add license notice header to the new file),
> - include i386/linux.h from both i386/linux32.h and i386/linux64.h.

Android does not support x86_64 target and therefore I do not want
-mandroid support for this target. When Android supports x86_64 target
this change would be appropriate.

>
>> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
>>
>> #define GNU_USER_LINK_EMULATION "elf_i386"
>> #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
>> +
>> +#undef CC1_SPEC
>> +#define CC1_SPEC \
>> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
>> +                    GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
>> +
>> +#undef       LINK_SPEC
>> +#define LINK_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
>> +                    GNU_USER_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)
>> +
>> +#undef  ENDFILE_SPEC
>> +#define ENDFILE_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +                    GNU_USER_TARGET_ENDFILE_SPEC,     \
>> +                    GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +                    ANDROID_ENDFILE_SPEC)
>
>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-03-29 17:49         ` Jan Hubicka
@ 2012-04-01 15:39           ` Ilya Enkovich
  2012-04-01 19:40           ` Maxim Kuvyrkov
  1 sibling, 0 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-01 15:39 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

Hello Honza,

>> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
>>
>>       * gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
>>       (CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
>>       (GNU_USER_TARGET_LINK_SPEC): New.
>>       (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>>       (GNU_USER_TARGET_MATHFILE_SPEC): New.
>>       (ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
>>
>>       * gcc/config/i386/linux.h (CC1_SPEC): New.
>>       (LINK_SPEC): New.
>>       (LIB_SPEC): New.
>>       (STARTFILE_SPEC): New.
>>       (ENDFILE_SPEC): New.
> OK.
> I guess the patch now follows quite closely the arm implementation, right?
> I am not quite sure if it makes sense to go around hassle and breaking up
> the following into generic linux-or-android.h?

Right, impementations are quite close but do not same. For example
ENDFILE_SPEC and CC1PLUS_SPEC are defined differently. Therefore we
will have target specific parts anyway.

Ilya
>
> Honza
>
>> diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
>> index 73681fe..a832ddc 100644
>> --- a/gcc/config/i386/linux.h
>> +++ b/gcc/config/i386/linux.h
>> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
>>
>>  #define GNU_USER_LINK_EMULATION "elf_i386"
>>  #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
>> +
>> +#undef CC1_SPEC
>> +#define CC1_SPEC \
>> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
>> +                    GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
>> +
>> +#undef       LINK_SPEC
>> +#define LINK_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
>> +                    GNU_USER_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)
>> +
>> +#undef  ENDFILE_SPEC
>> +#define ENDFILE_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +                    GNU_USER_TARGET_ENDFILE_SPEC,     \
>> +                    GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +                    ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-01 15:23           ` Ilya Enkovich
@ 2012-04-01 16:13             ` H.J. Lu
  2012-04-01 19:33             ` Maxim Kuvyrkov
  1 sibling, 0 replies; 26+ messages in thread
From: H.J. Lu @ 2012-04-01 16:13 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

On Sun, Apr 1, 2012 at 8:23 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:

>> i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains.  Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds.  I improve on this situation I suggest:
>> - rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc),
>> - put below definitions to new i386/linux.h (remember to add license notice header to the new file),
>> - include i386/linux.h from both i386/linux32.h and i386/linux64.h.
>
> Android does not support x86_64 target and therefore I do not want
> -mandroid support for this target. When Android supports x86_64 target
> this change would be appropriate.
>

Please add x86-64 Android support as suggested by Maxim.  It can also
be used for x32 Android.


-- 
H.J.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-01 15:23           ` Ilya Enkovich
  2012-04-01 16:13             ` H.J. Lu
@ 2012-04-01 19:33             ` Maxim Kuvyrkov
  2012-04-02 14:16               ` Ilya Enkovich
  1 sibling, 1 reply; 26+ messages in thread
From: Maxim Kuvyrkov @ 2012-04-01 19:33 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

On 2/04/2012, at 3:23 AM, Ilya Enkovich wrote:

>> As is, it appears this patch did not see much testing, I'm pretty sure it breaks building shared libraries and PIE executable for Linux.
> 
> I do not expect any changes in compiler behavior for non Android
> targets. I bootstrapped and checked patched compiler on linux-x86_64.
> I also built ptched compiler for Android target using NDK scripts.

OK.

>> 
>> Here and in other instances below you use "GNU_USER_TARGET_" prefix.  I would prefer using a shorter "GNU_USER_" instead unless there is a good reason to add "TARGET" too.
> 
> The reason is that some macroses are defined in other files and I just
> redefine them (i.e. GNU_USER_TARGET_CC1_SPEC). This prefix is also
> used for other targets (i.e. in linux-eabi.h). So I do not see a good
> reason to change it everywhere or mix it with other prefix
> "GNU_USER_".

OK.

>> Here you remove "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s".  Presumably, you are moving that to GNU_USER[_TARGET]_ENDFILE_SPEC, but you never define it.
> 
> You are right. It is in GNU_USER_TARGET_ENDFILE_SPEC which is defined
> in gcc/config/gnu-user.h.

OK.  I missed that GNU_USER_TARGET_ENDFILE_SPEC was already defined.

> 
>> 
>>> 
>>> /* 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/i386/linux.h b/gcc/config/i386/linux.h
>>> index 73681fe..a832ddc 100644
>>> --- a/gcc/config/i386/linux.h
>>> +++ b/gcc/config/i386/linux.h
>> 
>> i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains.  Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds.  I improve on this situation I suggest:
>> - rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc),
>> - put below definitions to new i386/linux.h (remember to add license notice header to the new file),
>> - include i386/linux.h from both i386/linux32.h and i386/linux64.h.
> 
> Android does not support x86_64 target and therefore I do not want
> -mandroid support for this target. When Android supports x86_64 target
> this change would be appropriate.

The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?

Thank you,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-03-29 17:49         ` Jan Hubicka
  2012-04-01 15:39           ` Ilya Enkovich
@ 2012-04-01 19:40           ` Maxim Kuvyrkov
  1 sibling, 0 replies; 26+ messages in thread
From: Maxim Kuvyrkov @ 2012-04-01 19:40 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Ilya Enkovich, H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

On 30/03/2012, at 6:48 AM, Jan Hubicka wrote:

>> 2012-02-27  Enkovich Ilya  <ilya.enkovich@intel.com>
>> 
>> 	* gcc/config/i386/gnu-user.h (GNU_USER_TARGET_CC1_SPEC): New.
>> 	(CC1_SPEC): Use GNU_USER_TARGET_CC1_SPEC.
>> 	(GNU_USER_TARGET_LINK_SPEC): New.
>> 	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>> 	(GNU_USER_TARGET_MATHFILE_SPEC): New.
>> 	(ENDFILE_SPEC): Use GNU_USER_TARGET_MATHFILE_SPEC.
>> 
>> 	* gcc/config/i386/linux.h (CC1_SPEC): New.
>> 	(LINK_SPEC): New.
>> 	(LIB_SPEC): New.
>> 	(STARTFILE_SPEC): New.
>> 	(ENDFILE_SPEC): New.
> OK.
> I guess the patch now follows quite closely the arm implementation, right?
> I am not quite sure if it makes sense to go around hassle and breaking up
> the following into generic linux-or-android.h?

I think this is clear as one can reasonably get.  It would be possible to include linux-or-android.h at the end of linux*.h that would #undef/#define *_SPEC macros like below, but it seems clearer to give the final choice of what is going into the *_SPEC macros to individual targets.

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics

>> diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
>> index 73681fe..a832ddc 100644
>> --- a/gcc/config/i386/linux.h
>> +++ b/gcc/config/i386/linux.h
>> @@ -22,3 +22,30 @@ along with GCC; see the file COPYING3.  If not see
>> 
>> #define GNU_USER_LINK_EMULATION "elf_i386"
>> #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
>> +
>> +#undef CC1_SPEC
>> +#define CC1_SPEC \
>> +  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
>> +		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
>> +
>> +#undef	LINK_SPEC
>> +#define LINK_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
>> +		       GNU_USER_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)
>> +
>> +#undef  ENDFILE_SPEC
>> +#define ENDFILE_SPEC \
>> +  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
>> +		       GNU_USER_TARGET_MATHFILE_SPEC " " \
>> +		       ANDROID_ENDFILE_SPEC)

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-01 19:33             ` Maxim Kuvyrkov
@ 2012-04-02 14:16               ` Ilya Enkovich
  2012-04-02 14:27                 ` H.J. Lu
  2012-04-02 17:06                 ` Maxim Kuvyrkov
  0 siblings, 2 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-02 14:16 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

> On 2/04/2012, at 3:23 AM, Ilya Enkovich wrote:
>
>>> As is, it appears this patch did not see much testing, I'm pretty sure it breaks building shared libraries and PIE executable for Linux.
>>
>> I do not expect any changes in compiler behavior for non Android
>> targets. I bootstrapped and checked patched compiler on linux-x86_64.
>> I also built ptched compiler for Android target using NDK scripts.
>
> OK.
>
>>>
>>> Here and in other instances below you use "GNU_USER_TARGET_" prefix.  I would prefer using a shorter "GNU_USER_" instead unless there is a good reason to add "TARGET" too.
>>
>> The reason is that some macroses are defined in other files and I just
>> redefine them (i.e. GNU_USER_TARGET_CC1_SPEC). This prefix is also
>> used for other targets (i.e. in linux-eabi.h). So I do not see a good
>> reason to change it everywhere or mix it with other prefix
>> "GNU_USER_".
>
> OK.
>
>>> Here you remove "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s".  Presumably, you are moving that to GNU_USER[_TARGET]_ENDFILE_SPEC, but you never define it.
>>
>> You are right. It is in GNU_USER_TARGET_ENDFILE_SPEC which is defined
>> in gcc/config/gnu-user.h.
>
> OK.  I missed that GNU_USER_TARGET_ENDFILE_SPEC was already defined.
>
>>
>>>
>>>>
>>>> /* 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/i386/linux.h b/gcc/config/i386/linux.h
>>>> index 73681fe..a832ddc 100644
>>>> --- a/gcc/config/i386/linux.h
>>>> +++ b/gcc/config/i386/linux.h
>>>
>>> i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains.  Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds.  I improve on this situation I suggest:
>>> - rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc),
>>> - put below definitions to new i386/linux.h (remember to add license notice header to the new file),
>>> - include i386/linux.h from both i386/linux32.h and i386/linux64.h.
>>
>> Android does not support x86_64 target and therefore I do not want
>> -mandroid support for this target. When Android supports x86_64 target
>> this change would be appropriate.
>
> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>

I think I see your point. And it seems to make all this work I'll also
have to rename i386/gnu-user.h into i386/gnu-user32.h and create
i386/gnu-user.h with common definitions to be included by
gnu-user[32|64].h. Otherwise I wont be able to use some definitions
(i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
linux64.h. Right?

Thanks,
Ilya

> Thank you,
>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-02 14:16               ` Ilya Enkovich
@ 2012-04-02 14:27                 ` H.J. Lu
  2012-04-02 17:06                 ` Maxim Kuvyrkov
  1 sibling, 0 replies; 26+ messages in thread
From: H.J. Lu @ 2012-04-02 14:27 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

On Mon, Apr 2, 2012 at 7:16 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> On 2/04/2012, at 3:23 AM, Ilya Enkovich wrote:
>>
>>>> As is, it appears this patch did not see much testing, I'm pretty sure it breaks building shared libraries and PIE executable for Linux.
>>>
>>> I do not expect any changes in compiler behavior for non Android
>>> targets. I bootstrapped and checked patched compiler on linux-x86_64.
>>> I also built ptched compiler for Android target using NDK scripts.
>>
>> OK.
>>
>>>>
>>>> Here and in other instances below you use "GNU_USER_TARGET_" prefix.  I would prefer using a shorter "GNU_USER_" instead unless there is a good reason to add "TARGET" too.
>>>
>>> The reason is that some macroses are defined in other files and I just
>>> redefine them (i.e. GNU_USER_TARGET_CC1_SPEC). This prefix is also
>>> used for other targets (i.e. in linux-eabi.h). So I do not see a good
>>> reason to change it everywhere or mix it with other prefix
>>> "GNU_USER_".
>>
>> OK.
>>
>>>> Here you remove "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s".  Presumably, you are moving that to GNU_USER[_TARGET]_ENDFILE_SPEC, but you never define it.
>>>
>>> You are right. It is in GNU_USER_TARGET_ENDFILE_SPEC which is defined
>>> in gcc/config/gnu-user.h.
>>
>> OK.  I missed that GNU_USER_TARGET_ENDFILE_SPEC was already defined.
>>
>>>
>>>>
>>>>>
>>>>> /* 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/i386/linux.h b/gcc/config/i386/linux.h
>>>>> index 73681fe..a832ddc 100644
>>>>> --- a/gcc/config/i386/linux.h
>>>>> +++ b/gcc/config/i386/linux.h
>>>>
>>>> i386/linux.h is used only for simple x86 32-bit builds; i386/linux64.h is used for multilib-enabled x86 toolchains.  Placing below definitions in i386/linux.h will not allow adding an Android as an additional multilib to -m32/-m64 x86 builds.  I improve on this situation I suggest:
>>>> - rename i386/linux.h to i386/linux32.h (with corresponding change to config.gcc),
>>>> - put below definitions to new i386/linux.h (remember to add license notice header to the new file),
>>>> - include i386/linux.h from both i386/linux32.h and i386/linux64.h.
>>>
>>> Android does not support x86_64 target and therefore I do not want
>>> -mandroid support for this target. When Android supports x86_64 target
>>> this change would be appropriate.
>>
>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>>
>
> I think I see your point. And it seems to make all this work I'll also
> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
> i386/gnu-user.h with common definitions to be included by
> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
> linux64.h. Right?
>

I think it is a good idea.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-02 14:16               ` Ilya Enkovich
  2012-04-02 14:27                 ` H.J. Lu
@ 2012-04-02 17:06                 ` Maxim Kuvyrkov
  2012-04-03 10:50                   ` Ilya Enkovich
  1 sibling, 1 reply; 26+ messages in thread
From: Maxim Kuvyrkov @ 2012-04-02 17:06 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

On 3/04/2012, at 2:16 AM, Ilya Enkovich wrote:

>> 
>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>> 
> 
> I think I see your point. And it seems to make all this work I'll also
> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
> i386/gnu-user.h with common definitions to be included by
> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
> linux64.h. Right?

It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.

Thanks,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-02 17:06                 ` Maxim Kuvyrkov
@ 2012-04-03 10:50                   ` Ilya Enkovich
  2012-04-03 14:56                     ` H.J. Lu
  0 siblings, 1 reply; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-03 10:50 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: H.J. Lu, gcc-patches, pavel.v.chupin, Jing Yu

[-- Attachment #1: Type: text/plain, Size: 2470 bytes --]

> On 3/04/2012, at 2:16 AM, Ilya Enkovich wrote:
>
>>>
>>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>>>
>>
>> I think I see your point. And it seems to make all this work I'll also
>> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
>> i386/gnu-user.h with common definitions to be included by
>> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
>> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
>> linux64.h. Right?
>
> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>
> Thanks,
>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>


Hi,

I prepared version with common linux.h and gnu-user.h. Does it look OK?

Bootstrapped and checked on linux-x86_64.

Thanks,
Ilya
---
2012-04-03  Enkovich Ilya  <ilya.enkovich@intel.com>

	* config/i386/linux.h: Renamed to ...
	* config/i386/linux32.h: ... this.

	* config/i386/gnu-user.h: Renamed to ...
	* config/i386/gnu-user32.h: ... this.
	(CPP_SPEC): Remove.
	(CC1_SPEC): Remove.
	(ENDFILE_SPEC): Remove.
	(GNU_USER_TARGET_LINK_SPEC): New.
	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.

	* config.gcc: Rename i386/linux.h to i386/linux32.h and
	i386/gnu-user.h to i386/gnu-user32.h.

	* config/i386/linux.h: New.

	* config/i386/gnu-user.h: New.

	* config/i386/linux64.h: Include i386/linux.h.

	* config/i386/gnu-user64.h: Include i386/gnu-user.h
	(CPP_SPEC): Remove.
	(CC1_SPEC): Remove.
	(ENDFILE_SPEC): Remove.
	(GNU_USER_TARGET_LINK_SPEC): New.
	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.

[-- Attachment #2: mandroid.patch --]
[-- Type: application/octet-stream, Size: 21197 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 3eb2c70..dc33ea3 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1263,20 +1263,20 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i
 				;;
 			esac
 		else
-			tm_file="${tm_file} i386/gnu-user.h i386/linux.h"
+			tm_file="${tm_file} i386/gnu-user32.h i386/linux32.h"
 		fi
 		;;
 	i[34567]86-*-knetbsd*-gnu)
-		tm_file="${tm_file} i386/gnu-user.h knetbsd-gnu.h i386/knetbsd-gnu.h"
+		tm_file="${tm_file} i386/gnu-user32.h knetbsd-gnu.h i386/knetbsd-gnu.h"
 		;;
 	i[34567]86-*-kfreebsd*-gnu)
-		tm_file="${tm_file} i386/gnu-user.h kfreebsd-gnu.h i386/kfreebsd-gnu.h"
+		tm_file="${tm_file} i386/gnu-user32.h kfreebsd-gnu.h i386/kfreebsd-gnu.h"
 		;;
 	i[34567]86-*-kopensolaris*-gnu)
-		tm_file="${tm_file} i386/gnu-user.h kopensolaris-gnu.h i386/kopensolaris-gnu.h"
+		tm_file="${tm_file} i386/gnu-user32.h kopensolaris-gnu.h i386/kopensolaris-gnu.h"
 		;;
 	i[34567]86-*-gnu*)
-		tm_file="$tm_file i386/gnu-user.h gnu.h i386/gnu.h"
+		tm_file="$tm_file i386/gnu-user32.h gnu.h i386/gnu.h"
 		;;
 	esac
 	;;
diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 98d0a25..d74b540 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -1,8 +1,6 @@
-/* Definitions for Intel 386 systems using GNU userspace.
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
-   Contributed by Eric Youngdale.
-   Modified for stabs-in-ELF by H.J. Lu.
+/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   Contributed by Ilya Enkovich.
 
 This file is part of GCC.
 
@@ -20,185 +18,24 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* Output at beginning of assembler file.  */
-/* The .file command should always begin the output.  */
-#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
-
-/* The svr4 ABI for the i386 says that records and unions are returned
-   in memory.  */
-#undef DEFAULT_PCC_STRUCT_RETURN
-#define DEFAULT_PCC_STRUCT_RETURN 1
-
-/* We arrange for the whole %gs segment to map the tls area.  */
-#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
-#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
-
-#undef ASM_COMMENT_START
-#define ASM_COMMENT_START "#"
-
-#undef DBX_REGISTER_NUMBER
-#define DBX_REGISTER_NUMBER(n) \
-  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
-
-/* Output assembler code to FILE to call the profiler.
-   To the best of my knowledge, no GNU userspace libc has required the label
-   argument to mcount.  */
-
-#define NO_PROFILE_COUNTERS	1
-
-#undef MCOUNT_NAME
-#define MCOUNT_NAME "mcount"
-
-/* The GLIBC version of mcount for the x86 assumes that there is a
-   frame, so we cannot allow profiling without a frame pointer.  */
-
-#undef SUBTARGET_FRAME_POINTER_REQUIRED
-#define SUBTARGET_FRAME_POINTER_REQUIRED crtl->profile
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
- 
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-  
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "long int"
-   
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE BITS_PER_WORD
-    
-#define TARGET_OS_CPP_BUILTINS()		\
-  do						\
-    {						\
-	GNU_USER_TARGET_OS_CPP_BUILTINS();	\
-    }						\
-  while (0)
-
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
 
-#undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
-
-/* Provide a LINK_SPEC appropriate for GNU userspace.  Here we provide support
-   for the special GCC options -static and -shared, which allow us to
-   link things in one of these three modes by applying the appropriate
-   combinations of options at link-time.
-
-   When the -shared link option is used a final link is not being
-   done.  */
-
-#undef  ASM_SPEC
-#define ASM_SPEC \
-  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
-
-#undef  SUBTARGET_EXTRA_SPECS
-#define SUBTARGET_EXTRA_SPECS \
-  { "link_emulation", GNU_USER_LINK_EMULATION },\
-  { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+#undef GNU_USER_TARGET_CC1_SPEC
+#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
 
-#undef	LINK_SPEC
-#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
-  %{!shared: \
-    %{!static: \
-      %{rdynamic:-export-dynamic} \
-      -dynamic-linker %(dynamic_linker)} \
-      %{static:-static}}"
+#undef CC1_SPEC
+#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC
 
 /* Similar to standard GNU userspace, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define GNU_USER_TARGET_MATHFILE_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"
-
-/* A C statement (sans semicolon) to output to the stdio stream
-   FILE the assembler definition of uninitialized global DECL named
-   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
-   Try to use asm_output_aligned_bss to implement this macro.  */
-
-#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
-  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
-
-/* A C statement to output to the stdio stream FILE an assembler
-   command to advance the location counter to a multiple of 1<<LOG
-   bytes if it is within MAX_SKIP bytes.
-
-   This is used to align code labels according to Intel recommendations.  */
-
-#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
-#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
-  do {									\
-    if ((LOG) != 0) {							\
-      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
-      else {								\
-	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
-	/* Make sure that we have at least 8 byte alignment if > 8 byte \
-	   alignment is preferred.  */					\
-	if ((LOG) > 3							\
-	    && (1 << (LOG)) > ((MAX_SKIP) + 1)				\
-	    && (MAX_SKIP) >= 7)						\
-	  fputs ("\t.p2align 3\n", (FILE));				\
-      }									\
-    }									\
-  } while (0)
-#endif
+   %{mpc80:crtprec80.o%s}"
 
-/* Handle special EH pointer encodings.  Absolute, pc-relative, and
-   indirect are handled automatically.  */
-#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
-  do {									\
-    if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)		\
-      {									\
-        fputs (ASM_LONG, FILE);			\
-        assemble_name (FILE, XSTR (ADDR, 0));				\
-	fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
-        goto DONE;							\
-      }									\
-  } while (0)
-
-/* Used by crtstuff.c to initialize the base of data-relative relocations.
-   These are GOT relative on x86, so return the pic register.  */
-#ifdef __PIC__
-#define CRT_GET_RFIB_DATA(BASE)			\
-  {						\
-    register void *ebx_ __asm__("ebx");		\
-    BASE = ebx_;				\
-  }
-#else
-#define CRT_GET_RFIB_DATA(BASE)						\
-  __asm__ ("call\t.LPR%=\n"						\
-	   ".LPR%=:\n\t"						\
-	   "pop{l}\t%0\n\t"						\
-	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
-	      smaller than the traditional EBX, which results in the	\
-	      offset being off by one.  */				\
-	   "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"		\
-		   "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"		\
-	   : "=d"(BASE))
-#endif
-
-/* Put all *tf routines in libgcc.  */
-#undef LIBGCC2_HAS_TF_MODE
-#define LIBGCC2_HAS_TF_MODE 1
-#define LIBGCC2_TF_CEXT q
-#define TF_SIZE 113
-
-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
-/* The stack pointer needs to be moved while checking the stack.  */
-#define STACK_CHECK_MOVING_SP 1
-
-/* Static stack checking is supported by means of probes.  */
-#define STACK_CHECK_STATIC_BUILTIN 1
-
-#ifdef TARGET_LIBC_PROVIDES_SSP
-/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
-#define TARGET_THREAD_SSP_OFFSET	0x14
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  GNU_USER_TARGET_MATHFILE_SPEC " " \
+  GNU_USER_TARGET_ENDFILE_SPEC
 
-/* We steal the last transactional memory word.  */
-#define TARGET_CAN_SPLIT_STACK
-#define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
-#endif
diff --git a/gcc/config/i386/gnu-user32.h b/gcc/config/i386/gnu-user32.h
new file mode 100644
index 0000000..5409421
--- /dev/null
+++ b/gcc/config/i386/gnu-user32.h
@@ -0,0 +1,194 @@
+/* Definitions for Intel 386 systems using GNU userspace.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
+   2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config/i386/gnu-user.h"
+
+/* Output at beginning of assembler file.  */
+/* The .file command should always begin the output.  */
+#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
+
+/* The svr4 ABI for the i386 says that records and unions are returned
+   in memory.  */
+#undef DEFAULT_PCC_STRUCT_RETURN
+#define DEFAULT_PCC_STRUCT_RETURN 1
+
+/* We arrange for the whole %gs segment to map the tls area.  */
+#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
+#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
+
+#undef ASM_COMMENT_START
+#define ASM_COMMENT_START "#"
+
+#undef DBX_REGISTER_NUMBER
+#define DBX_REGISTER_NUMBER(n) \
+  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
+
+/* Output assembler code to FILE to call the profiler.
+   To the best of my knowledge, no GNU userspace libc has required the label
+   argument to mcount.  */
+
+#define NO_PROFILE_COUNTERS	1
+
+#undef MCOUNT_NAME
+#define MCOUNT_NAME "mcount"
+
+/* The GLIBC version of mcount for the x86 assumes that there is a
+   frame, so we cannot allow profiling without a frame pointer.  */
+
+#undef SUBTARGET_FRAME_POINTER_REQUIRED
+#define SUBTARGET_FRAME_POINTER_REQUIRED crtl->profile
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "unsigned int"
+ 
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "int"
+  
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "long int"
+   
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE BITS_PER_WORD
+    
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+	GNU_USER_TARGET_OS_CPP_BUILTINS();	\
+    }						\
+  while (0)
+
+/* Provide a LINK_SPEC appropriate for GNU userspace.  Here we provide support
+   for the special GCC options -static and -shared, which allow us to
+   link things in one of these three modes by applying the appropriate
+   combinations of options at link-time.
+
+   When the -shared link option is used a final link is not being
+   done.  */
+
+#undef  ASM_SPEC
+#define ASM_SPEC \
+  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
+
+#undef  SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  { "link_emulation", GNU_USER_LINK_EMULATION },\
+  { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+
+#define GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
+
+/* A C statement (sans semicolon) to output to the stdio stream
+   FILE the assembler definition of uninitialized global DECL named
+   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
+   Try to use asm_output_aligned_bss to implement this macro.  */
+
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
+  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
+
+/* A C statement to output to the stdio stream FILE an assembler
+   command to advance the location counter to a multiple of 1<<LOG
+   bytes if it is within MAX_SKIP bytes.
+
+   This is used to align code labels according to Intel recommendations.  */
+
+#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
+  do {									\
+    if ((LOG) != 0) {							\
+      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
+      else {								\
+	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
+	/* Make sure that we have at least 8 byte alignment if > 8 byte \
+	   alignment is preferred.  */					\
+	if ((LOG) > 3							\
+	    && (1 << (LOG)) > ((MAX_SKIP) + 1)				\
+	    && (MAX_SKIP) >= 7)						\
+	  fputs ("\t.p2align 3\n", (FILE));				\
+      }									\
+    }									\
+  } while (0)
+#endif
+
+/* Handle special EH pointer encodings.  Absolute, pc-relative, and
+   indirect are handled automatically.  */
+#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
+  do {									\
+    if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)		\
+      {									\
+        fputs (ASM_LONG, FILE);			\
+        assemble_name (FILE, XSTR (ADDR, 0));				\
+	fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
+        goto DONE;							\
+      }									\
+  } while (0)
+
+/* Used by crtstuff.c to initialize the base of data-relative relocations.
+   These are GOT relative on x86, so return the pic register.  */
+#ifdef __PIC__
+#define CRT_GET_RFIB_DATA(BASE)			\
+  {						\
+    register void *ebx_ __asm__("ebx");		\
+    BASE = ebx_;				\
+  }
+#else
+#define CRT_GET_RFIB_DATA(BASE)						\
+  __asm__ ("call\t.LPR%=\n"						\
+	   ".LPR%=:\n\t"						\
+	   "pop{l}\t%0\n\t"						\
+	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
+	      smaller than the traditional EBX, which results in the	\
+	      offset being off by one.  */				\
+	   "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"		\
+		   "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"		\
+	   : "=d"(BASE))
+#endif
+
+/* Put all *tf routines in libgcc.  */
+#undef LIBGCC2_HAS_TF_MODE
+#define LIBGCC2_HAS_TF_MODE 1
+#define LIBGCC2_TF_CEXT q
+#define TF_SIZE 113
+
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+
+/* The stack pointer needs to be moved while checking the stack.  */
+#define STACK_CHECK_MOVING_SP 1
+
+/* Static stack checking is supported by means of probes.  */
+#define STACK_CHECK_STATIC_BUILTIN 1
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+#define TARGET_THREAD_SSP_OFFSET	0x14
+
+/* We steal the last transactional memory word.  */
+#define TARGET_CAN_SPLIT_STACK
+#define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+#endif
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 6f7b5de..38373bb 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -24,6 +24,8 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
+#include "config/i386/gnu-user.h"
+
 #define TARGET_OS_CPP_BUILTINS()				\
   do								\
     {								\
@@ -31,12 +33,6 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
     }								\
   while (0)
 
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
-#undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
-
 /* The svr4 ABI for the i386 says that records and unions are returned
    in memory.  In the 64bit compilation we will turn this flag off in
    ix86_option_override_internal, as we never do pcc_struct_return
@@ -77,8 +73,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  %{" SPEC_X32 ":--x32} \
  %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
 
-#undef	LINK_SPEC
-#define LINK_SPEC "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
+#define GNU_USER_TARGET_LINK_SPEC "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
                    %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
                    %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
   %{shared:-shared} \
@@ -90,14 +85,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
       %{" SPEC_X32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKERX32 "}} \
     %{static:-static}}"
 
-/* Similar to standard GNU userspace, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define 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"
+#undef	LINK_SPEC
+#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC
 
 #if TARGET_64BIT_DEFAULT
 #if TARGET_BI_ARCH == 2
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 73681fe..58f18a9 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -1,8 +1,6 @@
 /* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
-   Contributed by Eric Youngdale.
-   Modified for stabs-in-ELF by H.J. Lu.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   Contributed by Ilya Enkovich.
 
 This file is part of GCC.
 
@@ -20,5 +18,29 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define GNU_USER_LINK_EMULATION "elf_i386"
-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+#undef CC1_SPEC
+#define CC1_SPEC \
+  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
+		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#undef	LINK_SPEC
+#define LINK_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
+		       GNU_USER_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)
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
+		       GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       ANDROID_ENDFILE_SPEC)
diff --git a/gcc/config/i386/linux32.h b/gcc/config/i386/linux32.h
new file mode 100644
index 0000000..58c21c5
--- /dev/null
+++ b/gcc/config/i386/linux32.h
@@ -0,0 +1,26 @@
+/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
+   2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config/i386/linux.h"
+
+#define GNU_USER_LINK_EMULATION "elf_i386"
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index 5b0a212..5edd275 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -1,6 +1,6 @@
 /* Definitions for AMD x86-64 running Linux-based GNU systems with ELF format.
-   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
    Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h.
 
 This file is part of GCC.
@@ -24,6 +24,8 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
+#include "config/i386/linux.h"
+
 #define GNU_USER_LINK_EMULATION32 "elf_i386"
 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-03 10:50                   ` Ilya Enkovich
@ 2012-04-03 14:56                     ` H.J. Lu
  2012-04-03 19:42                       ` Maxim Kuvyrkov
  2012-04-03 21:02                       ` Ilya Enkovich
  0 siblings, 2 replies; 26+ messages in thread
From: H.J. Lu @ 2012-04-03 14:56 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

On Tue, Apr 3, 2012 at 3:49 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> On 3/04/2012, at 2:16 AM, Ilya Enkovich wrote:
>>
>>>>
>>>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>>>>
>>>
>>> I think I see your point. And it seems to make all this work I'll also
>>> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
>>> i386/gnu-user.h with common definitions to be included by
>>> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
>>> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
>>> linux64.h. Right?
>>
>> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>>
>> Thanks,
>>
>> --
>> Maxim Kuvyrkov
>> CodeSourcery / Mentor Graphics
>>
>
>
> Hi,
>
> I prepared version with common linux.h and gnu-user.h. Does it look OK?
>
> Bootstrapped and checked on linux-x86_64.
>

There are so many duplicates in gnu-user64.h and gnu-user32.h.
Please move all of them to gnu-user.h.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-03 14:56                     ` H.J. Lu
@ 2012-04-03 19:42                       ` Maxim Kuvyrkov
  2012-04-03 21:13                         ` Ilya Enkovich
  2012-04-03 21:02                       ` Ilya Enkovich
  1 sibling, 1 reply; 26+ messages in thread
From: Maxim Kuvyrkov @ 2012-04-03 19:42 UTC (permalink / raw)
  To: Ilya Enkovich, H.J. Lu; +Cc: gcc-patches Patches, pavel.v.chupin, Jing Yu

On 4/04/2012, at 2:56 AM, H.J. Lu wrote:

> On Tue, Apr 3, 2012 at 3:49 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> 
>>> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>>> 
>>> Thanks,
>>> 
>>> --
>>> Maxim Kuvyrkov
>>> CodeSourcery / Mentor Graphics
>>> 
>> 
>> 
>> Hi,
>> 
>> I prepared version with common linux.h and gnu-user.h. Does it look OK?
>> 
>> Bootstrapped and checked on linux-x86_64.
>> 
> 
> There are so many duplicates in gnu-user64.h and gnu-user32.h.
> Please move all of them to gnu-user.h.

Ilya,

Why i386/gnu-user.h had to change at all?  It seems like you trying to clean up/simplify stuff in i386/gnu-user.h, but in this case it seems (a) not required for the main purpose of this submission, and (b) excessive.

As a side note, if it were up to me, I would merge current i386/linux.h and i386/linux64.h into one file -- i386/linux.h -- instead of having similar definitions spread around.  But that would be a clean up in itself, and would require a separate submission.

Thank you,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-03 14:56                     ` H.J. Lu
  2012-04-03 19:42                       ` Maxim Kuvyrkov
@ 2012-04-03 21:02                       ` Ilya Enkovich
  2012-04-10 12:42                         ` Ilya Enkovich
  2012-04-11 16:24                         ` H.J. Lu
  1 sibling, 2 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-03 21:02 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

[-- Attachment #1: Type: text/plain, Size: 3811 bytes --]

> On Tue, Apr 3, 2012 at 3:49 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> On 3/04/2012, at 2:16 AM, Ilya Enkovich wrote:
>>>
>>>>>
>>>>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>>>>>
>>>>
>>>> I think I see your point. And it seems to make all this work I'll also
>>>> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
>>>> i386/gnu-user.h with common definitions to be included by
>>>> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
>>>> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
>>>> linux64.h. Right?
>>>
>>> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>>>
>>> Thanks,
>>>
>>> --
>>> Maxim Kuvyrkov
>>> CodeSourcery / Mentor Graphics
>>>
>>
>>
>> Hi,
>>
>> I prepared version with common linux.h and gnu-user.h. Does it look OK?
>>
>> Bootstrapped and checked on linux-x86_64.
>>
>
> There are so many duplicates in gnu-user64.h and gnu-user32.h.
> Please move all of them to gnu-user.h.
>
> Thanks.
>
> --
> H.J.

Hi,

Here is a new version with all gnu-user32.h and gnu-user64.h common
definitions moved to gnu-user.h.

Bootstrapped and checked on linux-x86_64.

Thanks,
Ilya
---
2012-04-04  Enkovich Ilya  <ilya.enkovich@intel.com>

	* config/i386/linux.h: Renamed to ...
	* config/i386/linux32.h: ... this.

	* config/i386/gnu-user.h: Renamed to ...
	* config/i386/gnu-user32.h: ... this.
	(CPP_SPEC): Removed.
	(CC1_SPEC): Removed.
	(ENDFILE_SPEC): Removed.
	(DEFAULT_PCC_STRUCT_RETURN): Removed.
	(TARGET_TLS_DIRECT_SEG_REFS_DEFAULT): Removed.
	(TARGET_OS_CPP_BUILTINS): Removed.
	(LIBGCC2_HAS_TF_MODE): Removed.
	(LIBGCC2_TF_CEXT): Removed.
	(TF_SIZE): Removed.
	(TARGET_ASM_FILE_END): Removed.
	(STACK_CHECK_MOVING_SP): Removed.
	(STACK_CHECK_STATIC_BUILTIN): Removed.
	(TARGET_THREAD_SSP_OFFSET): Removed.
	(TARGET_CAN_SPLIT_STACK): Removed.
	(TARGET_THREAD_SPLIT_STACK_OFFSET): Removed.
	(GNU_USER_TARGET_LINK_SPEC): New.
	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.

	* config.gcc: Rename i386/linux.h to i386/linux32.h and
	i386/gnu-user.h to i386/gnu-user32.h.

	* config/i386/linux.h: New.

	* config/i386/gnu-user.h: New.

	* config/i386/linux64.h: Include i386/linux.h.

	* config/i386/gnu-user64.h: Include i386/gnu-user.h
	(CPP_SPEC): Removed.
	(CC1_SPEC): Removed.
	(ENDFILE_SPEC): Removed.
	(DEFAULT_PCC_STRUCT_RETURN): Removed.
	(TARGET_TLS_DIRECT_SEG_REFS_DEFAULT): Removed.
	(TARGET_OS_CPP_BUILTINS): Removed.
	(LIBGCC2_HAS_TF_MODE): Removed.
	(LIBGCC2_TF_CEXT): Removed.
	(TF_SIZE): Removed.
	(TARGET_ASM_FILE_END): Removed.
	(STACK_CHECK_MOVING_SP): Removed.
	(STACK_CHECK_STATIC_BUILTIN): Removed.
	(TARGET_THREAD_SSP_OFFSET): Removed.
	(TARGET_CAN_SPLIT_STACK): Removed.
	(TARGET_THREAD_SPLIT_STACK_OFFSET): Removed.
	(GNU_USER_TARGET_LINK_SPEC): New.
	(LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.

[-- Attachment #2: mandroid.patch --]
[-- Type: application/octet-stream, Size: 22025 bytes --]

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 3eb2c70..dc33ea3 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1263,20 +1263,20 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | i[34567]86-*-knetbsd*-gnu | i
 				;;
 			esac
 		else
-			tm_file="${tm_file} i386/gnu-user.h i386/linux.h"
+			tm_file="${tm_file} i386/gnu-user32.h i386/linux32.h"
 		fi
 		;;
 	i[34567]86-*-knetbsd*-gnu)
-		tm_file="${tm_file} i386/gnu-user.h knetbsd-gnu.h i386/knetbsd-gnu.h"
+		tm_file="${tm_file} i386/gnu-user32.h knetbsd-gnu.h i386/knetbsd-gnu.h"
 		;;
 	i[34567]86-*-kfreebsd*-gnu)
-		tm_file="${tm_file} i386/gnu-user.h kfreebsd-gnu.h i386/kfreebsd-gnu.h"
+		tm_file="${tm_file} i386/gnu-user32.h kfreebsd-gnu.h i386/kfreebsd-gnu.h"
 		;;
 	i[34567]86-*-kopensolaris*-gnu)
-		tm_file="${tm_file} i386/gnu-user.h kopensolaris-gnu.h i386/kopensolaris-gnu.h"
+		tm_file="${tm_file} i386/gnu-user32.h kopensolaris-gnu.h i386/kopensolaris-gnu.h"
 		;;
 	i[34567]86-*-gnu*)
-		tm_file="$tm_file i386/gnu-user.h gnu.h i386/gnu.h"
+		tm_file="$tm_file i386/gnu-user32.h gnu.h i386/gnu.h"
 		;;
 	esac
 	;;
diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index 98d0a25..dfabf4b 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -1,8 +1,6 @@
-/* Definitions for Intel 386 systems using GNU userspace.
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
-   Contributed by Eric Youngdale.
-   Modified for stabs-in-ELF by H.J. Lu.
+/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   Contributed by Ilya Enkovich.
 
 This file is part of GCC.
 
@@ -20,165 +18,44 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-/* Output at beginning of assembler file.  */
-/* The .file command should always begin the output.  */
-#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
-
 /* The svr4 ABI for the i386 says that records and unions are returned
-   in memory.  */
+   in memory.  In the 64bit compilation we will turn this flag off in
+   ix86_option_override_internal, as we never do pcc_struct_return
+   scheme on this target.  */
 #undef DEFAULT_PCC_STRUCT_RETURN
 #define DEFAULT_PCC_STRUCT_RETURN 1
 
-/* We arrange for the whole %gs segment to map the tls area.  */
+/* We arrange for the whole %fs segment to map the tls area.  */
 #undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
 #define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
 
-#undef ASM_COMMENT_START
-#define ASM_COMMENT_START "#"
-
-#undef DBX_REGISTER_NUMBER
-#define DBX_REGISTER_NUMBER(n) \
-  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
-
-/* Output assembler code to FILE to call the profiler.
-   To the best of my knowledge, no GNU userspace libc has required the label
-   argument to mcount.  */
-
-#define NO_PROFILE_COUNTERS	1
-
-#undef MCOUNT_NAME
-#define MCOUNT_NAME "mcount"
-
-/* The GLIBC version of mcount for the x86 assumes that there is a
-   frame, so we cannot allow profiling without a frame pointer.  */
-
-#undef SUBTARGET_FRAME_POINTER_REQUIRED
-#define SUBTARGET_FRAME_POINTER_REQUIRED crtl->profile
-
-#undef SIZE_TYPE
-#define SIZE_TYPE "unsigned int"
- 
-#undef PTRDIFF_TYPE
-#define PTRDIFF_TYPE "int"
-  
-#undef WCHAR_TYPE
-#define WCHAR_TYPE "long int"
-   
-#undef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE BITS_PER_WORD
-    
-#define TARGET_OS_CPP_BUILTINS()		\
-  do						\
-    {						\
-	GNU_USER_TARGET_OS_CPP_BUILTINS();	\
-    }						\
+#define TARGET_OS_CPP_BUILTINS()				\
+  do								\
+    {								\
+	GNU_USER_TARGET_OS_CPP_BUILTINS();			\
+    }								\
   while (0)
 
 #undef CPP_SPEC
 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
 
-#undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
-
-/* Provide a LINK_SPEC appropriate for GNU userspace.  Here we provide support
-   for the special GCC options -static and -shared, which allow us to
-   link things in one of these three modes by applying the appropriate
-   combinations of options at link-time.
-
-   When the -shared link option is used a final link is not being
-   done.  */
+#undef GNU_USER_TARGET_CC1_SPEC
+#define GNU_USER_TARGET_CC1_SPEC "%(cc1_cpu) %{profile:-p}"
 
-#undef  ASM_SPEC
-#define ASM_SPEC \
-  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
-
-#undef  SUBTARGET_EXTRA_SPECS
-#define SUBTARGET_EXTRA_SPECS \
-  { "link_emulation", GNU_USER_LINK_EMULATION },\
-  { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
-
-#undef	LINK_SPEC
-#define LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
-  %{!shared: \
-    %{!static: \
-      %{rdynamic:-export-dynamic} \
-      -dynamic-linker %(dynamic_linker)} \
-      %{static:-static}}"
+#undef CC1_SPEC
+#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC
 
 /* Similar to standard GNU userspace, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define ENDFILE_SPEC \
+#define GNU_USER_TARGET_MATHFILE_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"
-
-/* A C statement (sans semicolon) to output to the stdio stream
-   FILE the assembler definition of uninitialized global DECL named
-   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
-   Try to use asm_output_aligned_bss to implement this macro.  */
-
-#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
-  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
-
-/* A C statement to output to the stdio stream FILE an assembler
-   command to advance the location counter to a multiple of 1<<LOG
-   bytes if it is within MAX_SKIP bytes.
-
-   This is used to align code labels according to Intel recommendations.  */
-
-#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
-#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
-  do {									\
-    if ((LOG) != 0) {							\
-      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
-      else {								\
-	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
-	/* Make sure that we have at least 8 byte alignment if > 8 byte \
-	   alignment is preferred.  */					\
-	if ((LOG) > 3							\
-	    && (1 << (LOG)) > ((MAX_SKIP) + 1)				\
-	    && (MAX_SKIP) >= 7)						\
-	  fputs ("\t.p2align 3\n", (FILE));				\
-      }									\
-    }									\
-  } while (0)
-#endif
+   %{mpc80:crtprec80.o%s}"
 
-/* Handle special EH pointer encodings.  Absolute, pc-relative, and
-   indirect are handled automatically.  */
-#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
-  do {									\
-    if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)		\
-      {									\
-        fputs (ASM_LONG, FILE);			\
-        assemble_name (FILE, XSTR (ADDR, 0));				\
-	fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
-        goto DONE;							\
-      }									\
-  } while (0)
-
-/* Used by crtstuff.c to initialize the base of data-relative relocations.
-   These are GOT relative on x86, so return the pic register.  */
-#ifdef __PIC__
-#define CRT_GET_RFIB_DATA(BASE)			\
-  {						\
-    register void *ebx_ __asm__("ebx");		\
-    BASE = ebx_;				\
-  }
-#else
-#define CRT_GET_RFIB_DATA(BASE)						\
-  __asm__ ("call\t.LPR%=\n"						\
-	   ".LPR%=:\n\t"						\
-	   "pop{l}\t%0\n\t"						\
-	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
-	      smaller than the traditional EBX, which results in the	\
-	      offset being off by one.  */				\
-	   "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"		\
-		   "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"		\
-	   : "=d"(BASE))
-#endif
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  GNU_USER_TARGET_MATHFILE_SPEC " " \
+  GNU_USER_TARGET_ENDFILE_SPEC
 
 /* Put all *tf routines in libgcc.  */
 #undef LIBGCC2_HAS_TF_MODE
@@ -195,10 +72,14 @@ along with GCC; see the file COPYING3.  If not see
 #define STACK_CHECK_STATIC_BUILTIN 1
 
 #ifdef TARGET_LIBC_PROVIDES_SSP
-/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
-#define TARGET_THREAD_SSP_OFFSET	0x14
+/* i386 glibc provides __stack_chk_guard in %gs:0x14,
+   x32 glibc provides it in %fs:0x18.
+   x86_64 glibc provides it in %fs:0x28.  */
+#define TARGET_THREAD_SSP_OFFSET \
+  (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14)
 
 /* We steal the last transactional memory word.  */
 #define TARGET_CAN_SPLIT_STACK
-#define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
+#define TARGET_THREAD_SPLIT_STACK_OFFSET \
+  (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30)
 #endif
diff --git a/gcc/config/i386/gnu-user32.h b/gcc/config/i386/gnu-user32.h
new file mode 100644
index 0000000..b4cc5ff
--- /dev/null
+++ b/gcc/config/i386/gnu-user32.h
@@ -0,0 +1,155 @@
+/* Definitions for Intel 386 systems using GNU userspace.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
+   2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config/i386/gnu-user.h"
+
+/* Output at beginning of assembler file.  */
+/* The .file command should always begin the output.  */
+#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
+
+#undef ASM_COMMENT_START
+#define ASM_COMMENT_START "#"
+
+#undef DBX_REGISTER_NUMBER
+#define DBX_REGISTER_NUMBER(n) \
+  (TARGET_64BIT ? dbx64_register_map[n] : svr4_dbx_register_map[n])
+
+/* Output assembler code to FILE to call the profiler.
+   To the best of my knowledge, no GNU userspace libc has required the label
+   argument to mcount.  */
+
+#define NO_PROFILE_COUNTERS	1
+
+#undef MCOUNT_NAME
+#define MCOUNT_NAME "mcount"
+
+/* The GLIBC version of mcount for the x86 assumes that there is a
+   frame, so we cannot allow profiling without a frame pointer.  */
+
+#undef SUBTARGET_FRAME_POINTER_REQUIRED
+#define SUBTARGET_FRAME_POINTER_REQUIRED crtl->profile
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "unsigned int"
+ 
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "int"
+  
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "long int"
+   
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE BITS_PER_WORD
+    
+/* Provide a LINK_SPEC appropriate for GNU userspace.  Here we provide support
+   for the special GCC options -static and -shared, which allow us to
+   link things in one of these three modes by applying the appropriate
+   combinations of options at link-time.
+
+   When the -shared link option is used a final link is not being
+   done.  */
+
+#undef  ASM_SPEC
+#define ASM_SPEC \
+  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
+
+#undef  SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  { "link_emulation", GNU_USER_LINK_EMULATION },\
+  { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+
+#define GNU_USER_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 GNU_USER_TARGET_LINK_SPEC
+
+/* A C statement (sans semicolon) to output to the stdio stream
+   FILE the assembler definition of uninitialized global DECL named
+   NAME whose size is SIZE bytes and alignment is ALIGN bytes.
+   Try to use asm_output_aligned_bss to implement this macro.  */
+
+#define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
+  asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
+
+/* A C statement to output to the stdio stream FILE an assembler
+   command to advance the location counter to a multiple of 1<<LOG
+   bytes if it is within MAX_SKIP bytes.
+
+   This is used to align code labels according to Intel recommendations.  */
+
+#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE,LOG,MAX_SKIP)			\
+  do {									\
+    if ((LOG) != 0) {							\
+      if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG));	\
+      else {								\
+	fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP));	\
+	/* Make sure that we have at least 8 byte alignment if > 8 byte \
+	   alignment is preferred.  */					\
+	if ((LOG) > 3							\
+	    && (1 << (LOG)) > ((MAX_SKIP) + 1)				\
+	    && (MAX_SKIP) >= 7)						\
+	  fputs ("\t.p2align 3\n", (FILE));				\
+      }									\
+    }									\
+  } while (0)
+#endif
+
+/* Handle special EH pointer encodings.  Absolute, pc-relative, and
+   indirect are handled automatically.  */
+#define ASM_MAYBE_OUTPUT_ENCODED_ADDR_RTX(FILE, ENCODING, SIZE, ADDR, DONE) \
+  do {									\
+    if ((SIZE) == 4 && ((ENCODING) & 0x70) == DW_EH_PE_datarel)		\
+      {									\
+        fputs (ASM_LONG, FILE);			\
+        assemble_name (FILE, XSTR (ADDR, 0));				\
+	fputs (((ENCODING) & DW_EH_PE_indirect ? "@GOT" : "@GOTOFF"), FILE); \
+        goto DONE;							\
+      }									\
+  } while (0)
+
+/* Used by crtstuff.c to initialize the base of data-relative relocations.
+   These are GOT relative on x86, so return the pic register.  */
+#ifdef __PIC__
+#define CRT_GET_RFIB_DATA(BASE)			\
+  {						\
+    register void *ebx_ __asm__("ebx");		\
+    BASE = ebx_;				\
+  }
+#else
+#define CRT_GET_RFIB_DATA(BASE)						\
+  __asm__ ("call\t.LPR%=\n"						\
+	   ".LPR%=:\n\t"						\
+	   "pop{l}\t%0\n\t"						\
+	   /* Due to a GAS bug, this cannot use EAX.  That encodes	\
+	      smaller than the traditional EBX, which results in the	\
+	      offset being off by one.  */				\
+	   "add{l}\t{$_GLOBAL_OFFSET_TABLE_+[.-.LPR%=],%0"		\
+		   "|%0,_GLOBAL_OFFSET_TABLE_+(.-.LPR%=)}"		\
+	   : "=d"(BASE))
+#endif
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 6f7b5de..6136135 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -24,29 +24,7 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#define TARGET_OS_CPP_BUILTINS()				\
-  do								\
-    {								\
-	GNU_USER_TARGET_OS_CPP_BUILTINS();			\
-    }								\
-  while (0)
-
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
-
-#undef CC1_SPEC
-#define CC1_SPEC "%(cc1_cpu) %{profile:-p}"
-
-/* The svr4 ABI for the i386 says that records and unions are returned
-   in memory.  In the 64bit compilation we will turn this flag off in
-   ix86_option_override_internal, as we never do pcc_struct_return
-   scheme on this target.  */
-#undef DEFAULT_PCC_STRUCT_RETURN
-#define DEFAULT_PCC_STRUCT_RETURN 1
-
-/* We arrange for the whole %fs segment to map the tls area.  */
-#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
-#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT MASK_TLS_DIRECT_SEG_REFS
+#include "config/i386/gnu-user.h"
 
 /* Provide a LINK_SPEC.  Here we provide support for the special GCC
    options -static and -shared, which allow us to link things in one
@@ -77,10 +55,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
  %{" SPEC_X32 ":--x32} \
  %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
 
-#undef	LINK_SPEC
-#define LINK_SPEC "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
-                   %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
-                   %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
+#define GNU_USER_TARGET_LINK_SPEC \
+  "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
+  %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
+  %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
   %{shared:-shared} \
   %{!shared: \
     %{!static: \
@@ -90,14 +68,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
       %{" SPEC_X32 ":-dynamic-linker " GNU_USER_DYNAMIC_LINKERX32 "}} \
     %{static:-static}}"
 
-/* Similar to standard GNU userspace, but adding -ffast-math support.  */
-#undef  ENDFILE_SPEC
-#define 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"
+#undef	LINK_SPEC
+#define LINK_SPEC GNU_USER_TARGET_LINK_SPEC
 
 #if TARGET_64BIT_DEFAULT
 #if TARGET_BI_ARCH == 2
@@ -108,30 +80,3 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #else
 #define MULTILIB_DEFAULTS { "m32" }
 #endif
-
-/* Put all *tf routines in libgcc.  */
-#undef LIBGCC2_HAS_TF_MODE
-#define LIBGCC2_HAS_TF_MODE 1
-#define LIBGCC2_TF_CEXT q
-#define TF_SIZE 113
-
-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-
-/* The stack pointer needs to be moved while checking the stack.  */
-#define STACK_CHECK_MOVING_SP 1
-
-/* Static stack checking is supported by means of probes.  */
-#define STACK_CHECK_STATIC_BUILTIN 1
-
-#ifdef TARGET_LIBC_PROVIDES_SSP
-/* i386 glibc provides __stack_chk_guard in %gs:0x14,
-   x32 glibc provides it in %fs:0x18. 
-   x86_64 glibc provides it in %fs:0x28.  */
-#define TARGET_THREAD_SSP_OFFSET \
-  (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14)
-
-/* We steal the last transactional memory word.  */
-#define TARGET_CAN_SPLIT_STACK
-#define TARGET_THREAD_SPLIT_STACK_OFFSET \
-  (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30)
-#endif
diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
index 73681fe..58f18a9 100644
--- a/gcc/config/i386/linux.h
+++ b/gcc/config/i386/linux.h
@@ -1,8 +1,6 @@
 /* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
-   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
-   2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
-   Contributed by Eric Youngdale.
-   Modified for stabs-in-ELF by H.J. Lu.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   Contributed by Ilya Enkovich.
 
 This file is part of GCC.
 
@@ -20,5 +18,29 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#define GNU_USER_LINK_EMULATION "elf_i386"
-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+#undef CC1_SPEC
+#define CC1_SPEC \
+  LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
+		       GNU_USER_TARGET_CC1_SPEC " " ANDROID_CC1_SPEC)
+
+#undef	LINK_SPEC
+#define LINK_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
+		       GNU_USER_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)
+
+#undef  ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       GNU_USER_TARGET_ENDFILE_SPEC,	 \
+		       GNU_USER_TARGET_MATHFILE_SPEC " " \
+		       ANDROID_ENDFILE_SPEC)
diff --git a/gcc/config/i386/linux32.h b/gcc/config/i386/linux32.h
new file mode 100644
index 0000000..58c21c5
--- /dev/null
+++ b/gcc/config/i386/linux32.h
@@ -0,0 +1,26 @@
+/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
+   2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config/i386/linux.h"
+
+#define GNU_USER_LINK_EMULATION "elf_i386"
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
index 5b0a212..5edd275 100644
--- a/gcc/config/i386/linux64.h
+++ b/gcc/config/i386/linux64.h
@@ -1,6 +1,6 @@
 /* Definitions for AMD x86-64 running Linux-based GNU systems with ELF format.
-   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
+   2012 Free Software Foundation, Inc.
    Contributed by Jan Hubicka <jh@suse.cz>, based on linux.h.
 
 This file is part of GCC.
@@ -24,6 +24,8 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
+#include "config/i386/linux.h"
+
 #define GNU_USER_LINK_EMULATION32 "elf_i386"
 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-03 19:42                       ` Maxim Kuvyrkov
@ 2012-04-03 21:13                         ` Ilya Enkovich
  0 siblings, 0 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-03 21:13 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: H.J. Lu, gcc-patches Patches, pavel.v.chupin, Jing Yu

> On 4/04/2012, at 2:56 AM, H.J. Lu wrote:
>
>> On Tue, Apr 3, 2012 at 3:49 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>>
>>>> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Maxim Kuvyrkov
>>>> CodeSourcery / Mentor Graphics
>>>>
>>>
>>>
>>> Hi,
>>>
>>> I prepared version with common linux.h and gnu-user.h. Does it look OK?
>>>
>>> Bootstrapped and checked on linux-x86_64.
>>>
>>
>> There are so many duplicates in gnu-user64.h and gnu-user32.h.
>> Please move all of them to gnu-user.h.
>
> Ilya,
>
> Why i386/gnu-user.h had to change at all?  It seems like you trying to clean up/simplify stuff in i386/gnu-user.h, but in this case it seems (a) not required for the main purpose of this submission, and (b) excessive.

Hi,

Initially my patch introduced few macroses in i386/gnu-user.h to use
them in i386/linux.h. After I created new i386/linux.h and included it
into i386/linux64.h I got a build failure because new i386/linux.h
used these new definition from i386/gnu-user.h and only
i386/gnu-user64.h was included into tm.h. So, I renamed
i386/gnu-user.h into i386/gnu-user32.h and created new i386/gnu-user.h
with these missing definitions. Otherwise I would have to copy all
changes made in i386/gnu-user.h to i386/gnu-user64.h.

Thanks,
Ilya

>
> As a side note, if it were up to me, I would merge current i386/linux.h and i386/linux64.h into one file -- i386/linux.h -- instead of having similar definitions spread around.  But that would be a clean up in itself, and would require a separate submission.
>
> Thank you,
>
> --
> Maxim Kuvyrkov
> CodeSourcery / Mentor Graphics
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-03 21:02                       ` Ilya Enkovich
@ 2012-04-10 12:42                         ` Ilya Enkovich
  2012-04-11 16:24                         ` H.J. Lu
  1 sibling, 0 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-10 12:42 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

Ping.

On Apr 4, 2012 at 1:02, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> On Tue, Apr 3, 2012 at 3:49 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> On 3/04/2012, at 2:16 AM, Ilya Enkovich wrote:
>>>>
>>>>>>
>>>>>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>>>>>>
>>>>>
>>>>> I think I see your point. And it seems to make all this work I'll also
>>>>> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
>>>>> i386/gnu-user.h with common definitions to be included by
>>>>> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
>>>>> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
>>>>> linux64.h. Right?
>>>>
>>>> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Maxim Kuvyrkov
>>>> CodeSourcery / Mentor Graphics
>>>>
>>>
>>>
>>> Hi,
>>>
>>> I prepared version with common linux.h and gnu-user.h. Does it look OK?
>>>
>>> Bootstrapped and checked on linux-x86_64.
>>>
>>
>> There are so many duplicates in gnu-user64.h and gnu-user32.h.
>> Please move all of them to gnu-user.h.
>>
>> Thanks.
>>
>> --
>> H.J.
>
> Hi,
>
> Here is a new version with all gnu-user32.h and gnu-user64.h common
> definitions moved to gnu-user.h.
>
> Bootstrapped and checked on linux-x86_64.
>
> Thanks,
> Ilya
> ---
> 2012-04-04  Enkovich Ilya  <ilya.enkovich@intel.com>
>
>        * config/i386/linux.h: Renamed to ...
>        * config/i386/linux32.h: ... this.
>
>        * config/i386/gnu-user.h: Renamed to ...
>        * config/i386/gnu-user32.h: ... this.
>        (CPP_SPEC): Removed.
>        (CC1_SPEC): Removed.
>        (ENDFILE_SPEC): Removed.
>        (DEFAULT_PCC_STRUCT_RETURN): Removed.
>        (TARGET_TLS_DIRECT_SEG_REFS_DEFAULT): Removed.
>        (TARGET_OS_CPP_BUILTINS): Removed.
>        (LIBGCC2_HAS_TF_MODE): Removed.
>        (LIBGCC2_TF_CEXT): Removed.
>        (TF_SIZE): Removed.
>        (TARGET_ASM_FILE_END): Removed.
>        (STACK_CHECK_MOVING_SP): Removed.
>        (STACK_CHECK_STATIC_BUILTIN): Removed.
>        (TARGET_THREAD_SSP_OFFSET): Removed.
>        (TARGET_CAN_SPLIT_STACK): Removed.
>        (TARGET_THREAD_SPLIT_STACK_OFFSET): Removed.
>        (GNU_USER_TARGET_LINK_SPEC): New.
>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>
>        * config.gcc: Rename i386/linux.h to i386/linux32.h and
>        i386/gnu-user.h to i386/gnu-user32.h.
>
>        * config/i386/linux.h: New.
>
>        * config/i386/gnu-user.h: New.
>
>        * config/i386/linux64.h: Include i386/linux.h.
>
>        * config/i386/gnu-user64.h: Include i386/gnu-user.h
>        (CPP_SPEC): Removed.
>        (CC1_SPEC): Removed.
>        (ENDFILE_SPEC): Removed.
>        (DEFAULT_PCC_STRUCT_RETURN): Removed.
>        (TARGET_TLS_DIRECT_SEG_REFS_DEFAULT): Removed.
>        (TARGET_OS_CPP_BUILTINS): Removed.
>        (LIBGCC2_HAS_TF_MODE): Removed.
>        (LIBGCC2_TF_CEXT): Removed.
>        (TF_SIZE): Removed.
>        (TARGET_ASM_FILE_END): Removed.
>        (STACK_CHECK_MOVING_SP): Removed.
>        (STACK_CHECK_STATIC_BUILTIN): Removed.
>        (TARGET_THREAD_SSP_OFFSET): Removed.
>        (TARGET_CAN_SPLIT_STACK): Removed.
>        (TARGET_THREAD_SPLIT_STACK_OFFSET): Removed.
>        (GNU_USER_TARGET_LINK_SPEC): New.
>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-03 21:02                       ` Ilya Enkovich
  2012-04-10 12:42                         ` Ilya Enkovich
@ 2012-04-11 16:24                         ` H.J. Lu
  2012-04-12 11:19                           ` Ilya Enkovich
  1 sibling, 1 reply; 26+ messages in thread
From: H.J. Lu @ 2012-04-11 16:24 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

On Tue, Apr 3, 2012 at 2:02 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> On Tue, Apr 3, 2012 at 3:49 AM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> On 3/04/2012, at 2:16 AM, Ilya Enkovich wrote:
>>>>
>>>>>>
>>>>>> The point is that one can build a toolchain for i686-linux-gnu that will support both 32-bit and 64-bit multilibs.  The 32-bit multilib will be used by default, and compilation for 64-bit user-space can be requested with -m64 option.  Even though Android is not supported for -m64, such a toolchain can support Android as a additional "-m32 -mandroid" multilib.  I.e., the toolchain will have three multilibs in total: "-m32" (default), "-m64" and "-m32 -mandroid".  I386/linux64.h will be picked up for such a toolchain, even though by default it would compile for 32-bit target.  Does this clear up things?
>>>>>>
>>>>>
>>>>> I think I see your point. And it seems to make all this work I'll also
>>>>> have to rename i386/gnu-user.h into i386/gnu-user32.h and create
>>>>> i386/gnu-user.h with common definitions to be included by
>>>>> gnu-user[32|64].h. Otherwise I wont be able to use some definitions
>>>>> (i.e. GNU_USER_TARGET_LINK_SPEC and GNU_USER_TARGET_MATHFILE_SPEC) in
>>>>> linux64.h. Right?
>>>>
>>>> It's simpler that you think.  The target headers ($tm_file in config.gcc -- gnu-user.h, linux*.h, etc. in this case) are all included into tm.h, which serves as proxy to all those headers.  All definitions made in preceding headers are available in subsequent headers.  So, given that i386/gnu-user*.h precedes i386/linux*.h in config.gcc's $tm_file, you only need to touch linux*.h.
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Maxim Kuvyrkov
>>>> CodeSourcery / Mentor Graphics
>>>>
>>>
>>>
>>> Hi,
>>>
>>> I prepared version with common linux.h and gnu-user.h. Does it look OK?
>>>
>>> Bootstrapped and checked on linux-x86_64.
>>>
>>
>> There are so many duplicates in gnu-user64.h and gnu-user32.h.
>> Please move all of them to gnu-user.h.
>>
>> Thanks.
>>
>> --
>> H.J.
>
> Hi,
>
> Here is a new version with all gnu-user32.h and gnu-user64.h common
> definitions moved to gnu-user.h.
>
> Bootstrapped and checked on linux-x86_64.
>
> Thanks,
> Ilya
> ---
> 2012-04-04  Enkovich Ilya  <ilya.enkovich@intel.com>
>
>        * config/i386/linux.h: Renamed to ...
>        * config/i386/linux32.h: ... this.
>
>        * config/i386/gnu-user.h: Renamed to ...
>        * config/i386/gnu-user32.h: ... this.
>        (CPP_SPEC): Removed.
>        (CC1_SPEC): Removed.
>        (ENDFILE_SPEC): Removed.
>        (DEFAULT_PCC_STRUCT_RETURN): Removed.
>        (TARGET_TLS_DIRECT_SEG_REFS_DEFAULT): Removed.
>        (TARGET_OS_CPP_BUILTINS): Removed.
>        (LIBGCC2_HAS_TF_MODE): Removed.
>        (LIBGCC2_TF_CEXT): Removed.
>        (TF_SIZE): Removed.
>        (TARGET_ASM_FILE_END): Removed.
>        (STACK_CHECK_MOVING_SP): Removed.
>        (STACK_CHECK_STATIC_BUILTIN): Removed.
>        (TARGET_THREAD_SSP_OFFSET): Removed.
>        (TARGET_CAN_SPLIT_STACK): Removed.
>        (TARGET_THREAD_SPLIT_STACK_OFFSET): Removed.
>        (GNU_USER_TARGET_LINK_SPEC): New.
>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.
>
>        * config.gcc: Rename i386/linux.h to i386/linux32.h and
>        i386/gnu-user.h to i386/gnu-user32.h.
>
>        * config/i386/linux.h: New.
>
>        * config/i386/gnu-user.h: New.
>
>        * config/i386/linux64.h: Include i386/linux.h.
>
>        * config/i386/gnu-user64.h: Include i386/gnu-user.h
>        (CPP_SPEC): Removed.
>        (CC1_SPEC): Removed.
>        (ENDFILE_SPEC): Removed.
>        (DEFAULT_PCC_STRUCT_RETURN): Removed.
>        (TARGET_TLS_DIRECT_SEG_REFS_DEFAULT): Removed.
>        (TARGET_OS_CPP_BUILTINS): Removed.
>        (LIBGCC2_HAS_TF_MODE): Removed.
>        (LIBGCC2_TF_CEXT): Removed.
>        (TF_SIZE): Removed.
>        (TARGET_ASM_FILE_END): Removed.
>        (STACK_CHECK_MOVING_SP): Removed.
>        (STACK_CHECK_STATIC_BUILTIN): Removed.
>        (TARGET_THREAD_SSP_OFFSET): Removed.
>        (TARGET_CAN_SPLIT_STACK): Removed.
>        (TARGET_THREAD_SPLIT_STACK_OFFSET): Removed.
>        (GNU_USER_TARGET_LINK_SPEC): New.
>        (LINK_SPEC): Use GNU_USER_TARGET_LINK_SPEC.

This is a big change.  Maybe it is better to break it into 2
parts:

1. Introduce gnu-user32.h only, which can be reviewed by x86 backend
maintainers.   Another possibility is to add gnu-user-common.h instead of
gnu-user32.h so that no changes to config.gcc are needed.
2. Add Android support, which can reviewed by Android maintainer.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH, i386, Android] -mandroid support for i386 target
  2012-04-11 16:24                         ` H.J. Lu
@ 2012-04-12 11:19                           ` Ilya Enkovich
  0 siblings, 0 replies; 26+ messages in thread
From: Ilya Enkovich @ 2012-04-12 11:19 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Maxim Kuvyrkov, gcc-patches, pavel.v.chupin, Jing Yu

>
> This is a big change.  Maybe it is better to break it into 2
> parts:
>
> 1. Introduce gnu-user32.h only, which can be reviewed by x86 backend
> maintainers.   Another possibility is to add gnu-user-common.h instead of
> gnu-user32.h so that no changes to config.gcc are needed.
> 2. Add Android support, which can reviewed by Android maintainer.
>
> Thanks.
>
> --
> H.J.

OK, I'll split this patch and send new patches in separate threads.

Thanks
Ilya

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2012-04-12 11:19 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-22 14:58 [PATCH, i386, Android] -mandroid support for i386 target Ilya Enkovich
2012-02-22 17:50 ` H.J. Lu
2012-02-24 15:57   ` Ilya Enkovich
2012-02-24 16:17     ` H.J. Lu
2012-02-27 15:19       ` Ilya Enkovich
2012-03-13 11:13         ` Ilya Enkovich
2012-03-27 13:56           ` Ilya Enkovich
2012-03-28 22:58             ` Jing Yu
2012-03-29  4:21         ` Maxim Kuvyrkov
2012-04-01 15:23           ` Ilya Enkovich
2012-04-01 16:13             ` H.J. Lu
2012-04-01 19:33             ` Maxim Kuvyrkov
2012-04-02 14:16               ` Ilya Enkovich
2012-04-02 14:27                 ` H.J. Lu
2012-04-02 17:06                 ` Maxim Kuvyrkov
2012-04-03 10:50                   ` Ilya Enkovich
2012-04-03 14:56                     ` H.J. Lu
2012-04-03 19:42                       ` Maxim Kuvyrkov
2012-04-03 21:13                         ` Ilya Enkovich
2012-04-03 21:02                       ` Ilya Enkovich
2012-04-10 12:42                         ` Ilya Enkovich
2012-04-11 16:24                         ` H.J. Lu
2012-04-12 11:19                           ` Ilya Enkovich
2012-03-29 17:49         ` Jan Hubicka
2012-04-01 15:39           ` Ilya Enkovich
2012-04-01 19:40           ` Maxim Kuvyrkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).