RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-18 Thread Joey Ye


 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Tuesday, December 18, 2012 12:10
 To: Joseph Prostko
 Cc: Joey Ye; gcc-patches@gcc.gnu.org
 Subject: Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 
 On Mon, Dec 17, 2012 at 5:23 PM, Joseph Prostko joe.pros...@gmail.com
 wrote:
  On Mon, Dec 17, 2012 at 2:28 PM, H.J. Lu hjl.to...@gmail.com wrote:
  On Mon, Dec 17, 2012 at 1:50 AM, Joey Ye joey...@arm.com wrote:
 
* libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
* libgcc/configure.ac (use_jcr_section): New variable.
* libgcc/configure: Regenerated.
* libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.
 
 
  I would use JAVA_IS_ENABLED instead of TARGET_USE_JCR_SECTION.
  But it is only my personal preference.
 
  I believe Joey did that to be consistent with the
  TARGET_USE_JCR_SECTION macro used in gcc/defaults.h that can be turned
  on or off for targets that specify it .  If JAVA_IS_ENABLED is used
  instead, should TARGET_USE_JCR_SECTION be deprecated?
 
 
 TARGET_USE_JCR_SECTION determines whether to use the JCR section
 to register Java classes. We don't need to do anything for Java if Java
 isn't enabled. The change can be as simple as
 
 #ifndef JAVA_IS_ENABLED
 #undef JCR_SECTION_NAME
 #endif
 
 in crtstuff.c.  Can you give it a try?
Tried and it simply worked. But undef JCR_SECTION_NAME here is very hacking.

 
 
 --
 H.J.






RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-17 Thread Joey Ye


 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Saturday, December 15, 2012 01:20
 To: Joey Ye
 Cc: gcc-patches@gcc.gnu.org; Joseph Prostko
 Subject: Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 Can't you do
 
 +# Disable jcr section if we're not building java
 +case ,${enable_languages}, in
 +  *java*)
 +use_jcr_section=1
 +;;
 +  *)
 +use_jcr_section=0
 +;;
 +esac
 
 in libgcc/configure.ac?
 
 BTW, checking *,java,* is wrong for
 
 --enable-languages=c,c++,java
Oh yes, it works. I didn't expect top level configure expands
--enable-languages=all to individual languages. Patch simplified.

However, I noticed that patterns like *,java,*) are widely used in
configure and they do work. Can you explain more why it is wrong?

  * libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
  * libgcc/configure.ac (use_jcr_section): New variable.
  * libgcc/configure: Regenerated.
  * libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.

jcr_diable_non_java-1217.patch
Description: Binary data


Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-17 Thread H.J. Lu
On Mon, Dec 17, 2012 at 1:50 AM, Joey Ye joey...@arm.com wrote:
 Can't you do

 +# Disable jcr section if we're not building java
 +case ,${enable_languages}, in
 +  *java*)
 +use_jcr_section=1
 +;;
 +  *)
 +use_jcr_section=0
 +;;
 +esac

 in libgcc/configure.ac?

 BTW, checking *,java,* is wrong for

 --enable-languages=c,c++,java
 Oh yes, it works. I didn't expect top level configure expands
 --enable-languages=all to individual languages. Patch simplified.

 However, I noticed that patterns like *,java,*) are widely used in
 configure and they do work. Can you explain more why it is wrong?

Yes,  *,java,*) works since java is always placed between c++
and lto.

   * libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
   * libgcc/configure.ac (use_jcr_section): New variable.
   * libgcc/configure: Regenerated.
   * libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.


I would use JAVA_IS_ENABLED instead of TARGET_USE_JCR_SECTION.
But it is only my personal preference.

-- 
H.J.


Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-17 Thread H.J. Lu
On Mon, Dec 17, 2012 at 5:23 PM, Joseph Prostko joe.pros...@gmail.com wrote:
 On Mon, Dec 17, 2012 at 2:28 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Mon, Dec 17, 2012 at 1:50 AM, Joey Ye joey...@arm.com wrote:

   * libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
   * libgcc/configure.ac (use_jcr_section): New variable.
   * libgcc/configure: Regenerated.
   * libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.


 I would use JAVA_IS_ENABLED instead of TARGET_USE_JCR_SECTION.
 But it is only my personal preference.

 I believe Joey did that to be consistent with the
 TARGET_USE_JCR_SECTION macro used in gcc/defaults.h that can be turned
 on or off for targets that specify it .  If JAVA_IS_ENABLED is used
 instead, should TARGET_USE_JCR_SECTION be deprecated?


TARGET_USE_JCR_SECTION determines whether to use the JCR section
to register Java classes. We don't need to do anything for Java if Java
isn't enabled. The change can be as simple as

#ifndef JAVA_IS_ENABLED
#undef JCR_SECTION_NAME
#endif

in crtstuff.c.  Can you give it a try?


-- 
H.J.


Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-14 Thread H.J. Lu
On Thu, Dec 13, 2012 at 10:56 PM, Joey Ye joey...@arm.com wrote:
 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Friday, December 14, 2012 11:55
 To: Joey Ye
 Cc: gcc-patches@gcc.gnu.org; Joseph Prostko
 Subject: Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

  2012-12-12  Joey Ye  joey...@arm.com
 
   * configure.ac (enable-jcr-section): New target_configargs.
   * configure: Regenerated.
   * libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
   * libgcc/configure.ac (use_jcr_section): New variable.
   * libgcc/configure: Regenerated.
   * libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.

 Why do we need a new configure option at toplevel?
 Can't you check --enable-languages=.. in libgcc?
 Although --enable-languages=... is passed to sub-configure, it needs a whole
 bunch of code to process with consideration of --disable-languages and
 targets. These code doesn't exist in libgcc/configure, and I intend not to
 duplicate them.


Can't you do

+# Disable jcr section if we're not building java
+case ,${enable_languages}, in
+  *java*)
+use_jcr_section=1
+;;
+  *)
+use_jcr_section=0
+;;
+esac

in libgcc/configure.ac?

BTW, checking *,java,* is wrong for

--enable-languages=c,c++,java

-- 
H.J.


RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-13 Thread Joey Ye
 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Tuesday, November 27, 2012 12:56
 To: Joey Ye
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
  
   OK to trunk?
  
   2012-09-21  Joey Ye  joey...@arm.com
  
   * crtstuff.c: Check TARGET_USE_JCR_SECTION.
  
 
 Since we have --enable-languages=.., can't we disable
 JCR_SECTION section if java isn't enabled?
Updated configure disabling jcr section usage if not configured with java.

2012-12-12  Joey Ye  joey...@arm.com

 * configure.ac (enable-jcr-section): New target_configargs.
 * configure: Regenerated.
 * libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
 * libgcc/configure.ac (use_jcr_section): New variable.
 * libgcc/configure: Regenerated.
 * libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.

jcr_diable_non_java-1212.patch
Description: Binary data


RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-12-13 Thread Joey Ye
 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Friday, December 14, 2012 11:55
 To: Joey Ye
 Cc: gcc-patches@gcc.gnu.org; Joseph Prostko
 Subject: Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 
  2012-12-12  Joey Ye  joey...@arm.com
 
   * configure.ac (enable-jcr-section): New target_configargs.
   * configure: Regenerated.
   * libgcc/Makefile.in: Include TARGET_USE_JCR_SECTION in CFLAGS.
   * libgcc/configure.ac (use_jcr_section): New variable.
   * libgcc/configure: Regenerated.
   * libgcc/crtstuff.c: Check TARGET_USE_JCR_SECTION.
 
 Why do we need a new configure option at toplevel?
 Can't you check --enable-languages=.. in libgcc?
Although --enable-languages=... is passed to sub-configure, it needs a whole
bunch of code to process with consideration of --disable-languages and
targets. These code doesn't exist in libgcc/configure, and I intend not to
duplicate them.

- Joey





RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-11-26 Thread Joey Ye
Ping^2

 -Original Message-
 From: Joey Ye
 Sent: Tuesday, November 20, 2012 10:09
 To: gcc-patches@gcc.gnu.org
 Cc: Joey Ye
 Subject: RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 
 Ping, as Joseph Prostko is saying that this patch shall solve the same
 problem he's facing.
 
  -Original Message-
  From: Joey Ye [mailto:joey...@arm.com]
  Sent: Friday, September 21, 2012 15:42
  To: gcc-patches@gcc.gnu.org
  Subject: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 
  Current crtstuff.c checks if JCR_SECTION_NAME is defined to decide
  whether
  do work for JCR. However, defaults.h always defines JCR_SECTION_NAME:
 
  #ifndef JCR_SECTION_NAME
  #define JCR_SECTION_NAME .jcr
  #endif
 
  So it is impossible to disable JCR related code in crtbegin.o, which
  can
  save some bytes for every applications that doesn't need java.
 
  This patch revise the check of JCR_SECTION_NAME to
  TARGET_USE_JCR_SECTION.
  By defining latter to zero disable JCR in crtstuff. This change
 doesn't
  impact logic of any target given following defines in defaults.h:
 
  #ifndef TARGET_USE_JCR_SECTION
  #ifdef JCR_SECTION_NAME
  #define TARGET_USE_JCR_SECTION 1
  #else
  #define TARGET_USE_JCR_SECTION 0
  #endif
  #endif
 
  Again, this patch doesn't impact libgcc on any target, unless
  TARGET_USE_JCR_SECTION is explicitly defined to 0 with make
  CFLAGS_FOR_TARGET=-DTARGET_USE_JCR_SECTION=0. AIX defines
  TARGET_USE_JCR_SECTION to 0, but it has no crtbegin/end stuff. So also
  no impact.
 
  OK to trunk?
 
  2012-09-21  Joey Ye  joey...@arm.com
 
  * crtstuff.c: Check TARGET_USE_JCR_SECTION.
 
  Index: libgcc/crtstuff.c
  ===
  --- libgcc/crtstuff.c   (revision 190556)
  +++ libgcc/crtstuff.c   (working copy)
  @@ -256,13 +256,13 @@
= { };
   #endif /* USE_EH_FRAME_REGISTRY */
 
  -#ifdef JCR_SECTION_NAME
  +#if TARGET_USE_JCR_SECTION  defined (JCR_SECTION_NAME)
   /* Stick a label at the beginning of the java class registration info
  so we can register them properly.  */
   STATIC void *__JCR_LIST__[]
 __attribute__ ((used, section(JCR_SECTION_NAME),
  aligned(sizeof(void*
 = { };
  -#endif /* JCR_SECTION_NAME */
  +#endif /* TARGET_USE_JCR_SECTION  JCR_SECTION_NAME */
 
   #if USE_TM_CLONE_REGISTRY
   STATIC func_ptr __TMC_LIST__[]
  @@ -438,7 +438,7 @@
   #endif
 
   #if defined(USE_EH_FRAME_REGISTRY) \
  -|| defined(JCR_SECTION_NAME) \
  +|| defined(TARGET_USE_JCR_SECTION) \
   || defined(USE_TM_CLONE_REGISTRY)
   /* Stick a call to __register_frame_info into the .init section.  For
  some
  reason calls with no arguments work more reliably in .init, so
  stick the
  @@ -461,7 +461,7 @@
   #endif /* CRT_GET_RFIB_DATA */
   #endif /* USE_EH_FRAME_REGISTRY */
 
  -#ifdef JCR_SECTION_NAME
  +#if TARGET_USE_JCR_SECTION
 if (__JCR_LIST__[0])
   {
 void (*register_classes) (void *) = _Jv_RegisterClasses;
  @@ -469,7 +469,7 @@
 if (register_classes)
  register_classes (__JCR_LIST__);
   }
  -#endif /* JCR_SECTION_NAME */
  +#endif /* TARGET_USE_JCR_SECTION */
 
   #if USE_TM_CLONE_REGISTRY
 register_tm_clones ();
  @@ -483,7 +483,7 @@
 __attribute__ ((__used__, section(.init_array),
  aligned(sizeof(func_ptr
 = { frame_dummy };
   #endif /* !defined(INIT_SECTION_ASM_OP) */
  -#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME ||
  USE_TM_CLONE_REGISTRY */
  +#endif /* USE_EH_FRAME_REGISTRY || TARGET_USE_JCR_SECTION ||
  USE_TM_CLONE_REGISTRY */
 
   #else  /* OBJECT_FORMAT_ELF */
 
  @@ -551,7 +551,7 @@
   }
 
   #if defined(USE_EH_FRAME_REGISTRY) \
  -|| defined(JCR_SECTION_NAME) \
  +|| defined(TARGET_USE_JCR_SECTION) \
   || defined(USE_TM_CLONE_REGISTRY)
   /* A helper function for __do_global_ctors, which is in crtend.o.
  Here
  in crtbegin.o, we can reference a couple of symbols not visible
  there.
  @@ -566,7 +566,7 @@
   __register_frame_info (__EH_FRAME_BEGIN__, object);
   #endif
 
  -#ifdef JCR_SECTION_NAME
  +#if TARGET_USE_JCR_SECTION
 if (__JCR_LIST__[0])
   {
 void (*register_classes) (void *) = _Jv_RegisterClasses;
  @@ -580,7 +580,7 @@
 register_tm_clones ();
   #endif /* USE_TM_CLONE_REGISTRY */
   }
  -#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME ||
  USE_TM_CLONE_REGISTRY */
  +#endif /* USE_EH_FRAME_REGISTRY || TARGET_USE_JCR_SECTION ||
  USE_TM_CLONE_REGISTRY */
 
   #else /* ! INIT_SECTION_ASM_OP  ! HAS_INIT_SECTION */
   #error What are you doing with crtstuff.c, then?
  @@ -656,13 +656,13 @@
= { 0 };
   #endif /* EH_FRAME_SECTION_NAME */
 
  -#ifdef JCR_SECTION_NAME
  +#if TARGET_USE_JCR_SECTION  defined (JCR_SECTION_NAME)
   /* Null terminate the .jcr section array.  */
   STATIC void *__JCR_END__[1]
  __attribute__ ((used, section(JCR_SECTION_NAME),
 aligned(sizeof(void *
  = { 0 };
  -#endif /* JCR_SECTION_NAME

Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-11-26 Thread H.J. Lu
On Mon, Nov 26, 2012 at 7:19 PM, Joey Ye joey...@arm.com wrote:
 Ping^2

 -Original Message-
 From: Joey Ye
 Sent: Tuesday, November 20, 2012 10:09
 To: gcc-patches@gcc.gnu.org
 Cc: Joey Ye
 Subject: RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

 Ping, as Joseph Prostko is saying that this patch shall solve the same
 problem he's facing.

  -Original Message-
  From: Joey Ye [mailto:joey...@arm.com]
  Sent: Friday, September 21, 2012 15:42
  To: gcc-patches@gcc.gnu.org
  Subject: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 
  Current crtstuff.c checks if JCR_SECTION_NAME is defined to decide
  whether
  do work for JCR. However, defaults.h always defines JCR_SECTION_NAME:
 
  #ifndef JCR_SECTION_NAME
  #define JCR_SECTION_NAME .jcr
  #endif
 
  So it is impossible to disable JCR related code in crtbegin.o, which
  can
  save some bytes for every applications that doesn't need java.
 
  This patch revise the check of JCR_SECTION_NAME to
  TARGET_USE_JCR_SECTION.
  By defining latter to zero disable JCR in crtstuff. This change
 doesn't
  impact logic of any target given following defines in defaults.h:
 
  #ifndef TARGET_USE_JCR_SECTION
  #ifdef JCR_SECTION_NAME
  #define TARGET_USE_JCR_SECTION 1
  #else
  #define TARGET_USE_JCR_SECTION 0
  #endif
  #endif
 
  Again, this patch doesn't impact libgcc on any target, unless
  TARGET_USE_JCR_SECTION is explicitly defined to 0 with make
  CFLAGS_FOR_TARGET=-DTARGET_USE_JCR_SECTION=0. AIX defines
  TARGET_USE_JCR_SECTION to 0, but it has no crtbegin/end stuff. So also
  no impact.
 
  OK to trunk?
 
  2012-09-21  Joey Ye  joey...@arm.com
 
  * crtstuff.c: Check TARGET_USE_JCR_SECTION.
 

Since we have --enable-languages=.., can't we disable
JCR_SECTION section if java isn't enabled?

-- 
H.J.


Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-11-26 Thread Joseph Prostko
On Mon, Nov 26, 2012 at 10:19 PM, Joey Ye joey...@arm.com wrote:
 Ping^2

 -Original Message-
 From: Joey Ye
 Sent: Tuesday, November 20, 2012 10:09
 To: gcc-patches@gcc.gnu.org
 Cc: Joey Ye
 Subject: RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

 Ping, as Joseph Prostko is saying that this patch shall solve the same
 problem he's facing.

Indeed.  I am working on updating Haiku's GCC port to GCC 4.7.2, and
in the past we always ended up editing defaults.h to not define
JCR_SECTION_NAME as a way to get around this issue.  Basically, in
Haiku, we don't want _Jv_RegisterClasses to end up in crtbegin.o so we
patched things in what I consider an unsatisfactory manner.  I hope to
get Haiku's GCC changes upstreamed at some point, and I admit our
current fix wouldn't stand any chance at being upstreamed compared to
Joey's suggested fix.

- joe


Re: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-11-26 Thread Joseph Prostko
On Mon, Nov 26, 2012 at 11:55 PM, H.J. Lu hjl.to...@gmail.com wrote:
 On Mon, Nov 26, 2012 at 7:19 PM, Joey Ye joey...@arm.com wrote:
 Ping^2

 -Original Message-
 From: Joey Ye
 Sent: Tuesday, November 20, 2012 10:09
 To: gcc-patches@gcc.gnu.org
 Cc: Joey Ye
 Subject: RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

 Since we have --enable-languages=.., can't we disable
 JCR_SECTION section if java isn't enabled?

I suppose that is certainly another option.  My main goal is to not
have _Jv_RegisterClasses show up in crtbegin.o, as it simply isn't
needed or desired in the case of Haiku.  Right now we only enable C
and C++, and it simply makes no sense to have anything Java-related
show up in our crtbegin.o.

- joe


RE: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-11-19 Thread Joey Ye
Ping, as Joseph Prostko is saying that this patch shall solve the same
problem he's facing.

 -Original Message-
 From: Joey Ye [mailto:joey...@arm.com]
 Sent: Friday, September 21, 2012 15:42
 To: gcc-patches@gcc.gnu.org
 Subject: [PATCH, libgcc] Make possible to disable JCR in crtstuff.c
 
 Current crtstuff.c checks if JCR_SECTION_NAME is defined to decide
 whether
 do work for JCR. However, defaults.h always defines JCR_SECTION_NAME:
 
 #ifndef JCR_SECTION_NAME
 #define JCR_SECTION_NAME .jcr
 #endif
 
 So it is impossible to disable JCR related code in crtbegin.o, which
 can
 save some bytes for every applications that doesn't need java.
 
 This patch revise the check of JCR_SECTION_NAME to
 TARGET_USE_JCR_SECTION.
 By defining latter to zero disable JCR in crtstuff. This change doesn't
 impact logic of any target given following defines in defaults.h:
 
 #ifndef TARGET_USE_JCR_SECTION
 #ifdef JCR_SECTION_NAME
 #define TARGET_USE_JCR_SECTION 1
 #else
 #define TARGET_USE_JCR_SECTION 0
 #endif
 #endif
 
 Again, this patch doesn't impact libgcc on any target, unless
 TARGET_USE_JCR_SECTION is explicitly defined to 0 with make
 CFLAGS_FOR_TARGET=-DTARGET_USE_JCR_SECTION=0. AIX defines
 TARGET_USE_JCR_SECTION to 0, but it has no crtbegin/end stuff. So also
 no impact.
 
 OK to trunk?
 
 2012-09-21  Joey Ye  joey...@arm.com
 
   * crtstuff.c: Check TARGET_USE_JCR_SECTION.
 
 Index: libgcc/crtstuff.c
 ===
 --- libgcc/crtstuff.c (revision 190556)
 +++ libgcc/crtstuff.c (working copy)
 @@ -256,13 +256,13 @@
   = { };
  #endif /* USE_EH_FRAME_REGISTRY */
 
 -#ifdef JCR_SECTION_NAME
 +#if TARGET_USE_JCR_SECTION  defined (JCR_SECTION_NAME)
  /* Stick a label at the beginning of the java class registration info
 so we can register them properly.  */
  STATIC void *__JCR_LIST__[]
__attribute__ ((used, section(JCR_SECTION_NAME),
 aligned(sizeof(void*
= { };
 -#endif /* JCR_SECTION_NAME */
 +#endif /* TARGET_USE_JCR_SECTION  JCR_SECTION_NAME */
 
  #if USE_TM_CLONE_REGISTRY
  STATIC func_ptr __TMC_LIST__[]
 @@ -438,7 +438,7 @@
  #endif
 
  #if defined(USE_EH_FRAME_REGISTRY) \
 -|| defined(JCR_SECTION_NAME) \
 +|| defined(TARGET_USE_JCR_SECTION) \
  || defined(USE_TM_CLONE_REGISTRY)
  /* Stick a call to __register_frame_info into the .init section.  For
 some
 reason calls with no arguments work more reliably in .init, so
 stick the
 @@ -461,7 +461,7 @@
  #endif /* CRT_GET_RFIB_DATA */
  #endif /* USE_EH_FRAME_REGISTRY */
 
 -#ifdef JCR_SECTION_NAME
 +#if TARGET_USE_JCR_SECTION
if (__JCR_LIST__[0])
  {
void (*register_classes) (void *) = _Jv_RegisterClasses;
 @@ -469,7 +469,7 @@
if (register_classes)
   register_classes (__JCR_LIST__);
  }
 -#endif /* JCR_SECTION_NAME */
 +#endif /* TARGET_USE_JCR_SECTION */
 
  #if USE_TM_CLONE_REGISTRY
register_tm_clones ();
 @@ -483,7 +483,7 @@
__attribute__ ((__used__, section(.init_array),
 aligned(sizeof(func_ptr
= { frame_dummy };
  #endif /* !defined(INIT_SECTION_ASM_OP) */
 -#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME ||
 USE_TM_CLONE_REGISTRY */
 +#endif /* USE_EH_FRAME_REGISTRY || TARGET_USE_JCR_SECTION ||
 USE_TM_CLONE_REGISTRY */
 
  #else  /* OBJECT_FORMAT_ELF */
 
 @@ -551,7 +551,7 @@
  }
 
  #if defined(USE_EH_FRAME_REGISTRY) \
 -|| defined(JCR_SECTION_NAME) \
 +|| defined(TARGET_USE_JCR_SECTION) \
  || defined(USE_TM_CLONE_REGISTRY)
  /* A helper function for __do_global_ctors, which is in crtend.o.
 Here
 in crtbegin.o, we can reference a couple of symbols not visible
 there.
 @@ -566,7 +566,7 @@
  __register_frame_info (__EH_FRAME_BEGIN__, object);
  #endif
 
 -#ifdef JCR_SECTION_NAME
 +#if TARGET_USE_JCR_SECTION
if (__JCR_LIST__[0])
  {
void (*register_classes) (void *) = _Jv_RegisterClasses;
 @@ -580,7 +580,7 @@
register_tm_clones ();
  #endif /* USE_TM_CLONE_REGISTRY */
  }
 -#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME ||
 USE_TM_CLONE_REGISTRY */
 +#endif /* USE_EH_FRAME_REGISTRY || TARGET_USE_JCR_SECTION ||
 USE_TM_CLONE_REGISTRY */
 
  #else /* ! INIT_SECTION_ASM_OP  ! HAS_INIT_SECTION */
  #error What are you doing with crtstuff.c, then?
 @@ -656,13 +656,13 @@
   = { 0 };
  #endif /* EH_FRAME_SECTION_NAME */
 
 -#ifdef JCR_SECTION_NAME
 +#if TARGET_USE_JCR_SECTION  defined (JCR_SECTION_NAME)
  /* Null terminate the .jcr section array.  */
  STATIC void *__JCR_END__[1]
 __attribute__ ((used, section(JCR_SECTION_NAME),
  aligned(sizeof(void *
 = { 0 };
 -#endif /* JCR_SECTION_NAME */
 +#endif /* TARGET_USE_JCR_SECTION  JCR_SECTION_NAME */
 
  #if USE_TM_CLONE_REGISTRY
  # ifndef HAVE_GAS_HIDDEN
 @@ -742,7 +742,7 @@
  {
func_ptr *p;
  #if defined(USE_EH_FRAME_REGISTRY) \
 -|| defined(JCR_SECTION_NAME) \
 +|| defined(TARGET_USE_JCR_SECTION) \
  || defined(USE_TM_CLONE_REGISTRY)
__do_global_ctors_1

[PATCH, libgcc] Make possible to disable JCR in crtstuff.c

2012-09-21 Thread Joey Ye
Current crtstuff.c checks if JCR_SECTION_NAME is defined to decide whether
do work for JCR. However, defaults.h always defines JCR_SECTION_NAME:

#ifndef JCR_SECTION_NAME
#define JCR_SECTION_NAME .jcr
#endif

So it is impossible to disable JCR related code in crtbegin.o, which can
save some bytes for every applications that doesn't need java. 

This patch revise the check of JCR_SECTION_NAME to TARGET_USE_JCR_SECTION.
By defining latter to zero disable JCR in crtstuff. This change doesn't
impact logic of any target given following defines in defaults.h:

#ifndef TARGET_USE_JCR_SECTION
#ifdef JCR_SECTION_NAME
#define TARGET_USE_JCR_SECTION 1
#else
#define TARGET_USE_JCR_SECTION 0
#endif
#endif

Again, this patch doesn't impact libgcc on any target, unless
TARGET_USE_JCR_SECTION is explicitly defined to 0 with make
CFLAGS_FOR_TARGET=-DTARGET_USE_JCR_SECTION=0. AIX defines
TARGET_USE_JCR_SECTION to 0, but it has no crtbegin/end stuff. So also no
impact.

OK to trunk?

2012-09-21  Joey Ye  joey...@arm.com

* crtstuff.c: Check TARGET_USE_JCR_SECTION.

Index: libgcc/crtstuff.c
===
--- libgcc/crtstuff.c   (revision 190556)
+++ libgcc/crtstuff.c   (working copy)
@@ -256,13 +256,13 @@
  = { };
 #endif /* USE_EH_FRAME_REGISTRY */
 
-#ifdef JCR_SECTION_NAME
+#if TARGET_USE_JCR_SECTION  defined (JCR_SECTION_NAME)
 /* Stick a label at the beginning of the java class registration info
so we can register them properly.  */
 STATIC void *__JCR_LIST__[]
   __attribute__ ((used, section(JCR_SECTION_NAME), aligned(sizeof(void*
   = { };
-#endif /* JCR_SECTION_NAME */
+#endif /* TARGET_USE_JCR_SECTION  JCR_SECTION_NAME */
 
 #if USE_TM_CLONE_REGISTRY
 STATIC func_ptr __TMC_LIST__[]
@@ -438,7 +438,7 @@
 #endif
 
 #if defined(USE_EH_FRAME_REGISTRY) \
-|| defined(JCR_SECTION_NAME) \
+|| defined(TARGET_USE_JCR_SECTION) \
 || defined(USE_TM_CLONE_REGISTRY)
 /* Stick a call to __register_frame_info into the .init section.  For some
reason calls with no arguments work more reliably in .init, so stick the
@@ -461,7 +461,7 @@
 #endif /* CRT_GET_RFIB_DATA */
 #endif /* USE_EH_FRAME_REGISTRY */
 
-#ifdef JCR_SECTION_NAME
+#if TARGET_USE_JCR_SECTION
   if (__JCR_LIST__[0])
 {
   void (*register_classes) (void *) = _Jv_RegisterClasses;
@@ -469,7 +469,7 @@
   if (register_classes)
register_classes (__JCR_LIST__);
 }
-#endif /* JCR_SECTION_NAME */
+#endif /* TARGET_USE_JCR_SECTION */
 
 #if USE_TM_CLONE_REGISTRY
   register_tm_clones ();
@@ -483,7 +483,7 @@
   __attribute__ ((__used__, section(.init_array),
aligned(sizeof(func_ptr
   = { frame_dummy };
 #endif /* !defined(INIT_SECTION_ASM_OP) */
-#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME ||
USE_TM_CLONE_REGISTRY */
+#endif /* USE_EH_FRAME_REGISTRY || TARGET_USE_JCR_SECTION ||
USE_TM_CLONE_REGISTRY */
 
 #else  /* OBJECT_FORMAT_ELF */
 
@@ -551,7 +551,7 @@
 }
 
 #if defined(USE_EH_FRAME_REGISTRY) \
-|| defined(JCR_SECTION_NAME) \
+|| defined(TARGET_USE_JCR_SECTION) \
 || defined(USE_TM_CLONE_REGISTRY)
 /* A helper function for __do_global_ctors, which is in crtend.o.  Here
in crtbegin.o, we can reference a couple of symbols not visible there.
@@ -566,7 +566,7 @@
 __register_frame_info (__EH_FRAME_BEGIN__, object);
 #endif
 
-#ifdef JCR_SECTION_NAME
+#if TARGET_USE_JCR_SECTION
   if (__JCR_LIST__[0])
 {
   void (*register_classes) (void *) = _Jv_RegisterClasses;
@@ -580,7 +580,7 @@
   register_tm_clones ();
 #endif /* USE_TM_CLONE_REGISTRY */
 }
-#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME ||
USE_TM_CLONE_REGISTRY */
+#endif /* USE_EH_FRAME_REGISTRY || TARGET_USE_JCR_SECTION ||
USE_TM_CLONE_REGISTRY */
 
 #else /* ! INIT_SECTION_ASM_OP  ! HAS_INIT_SECTION */
 #error What are you doing with crtstuff.c, then?
@@ -656,13 +656,13 @@
  = { 0 };
 #endif /* EH_FRAME_SECTION_NAME */
 
-#ifdef JCR_SECTION_NAME
+#if TARGET_USE_JCR_SECTION  defined (JCR_SECTION_NAME)
 /* Null terminate the .jcr section array.  */
 STATIC void *__JCR_END__[1]
__attribute__ ((used, section(JCR_SECTION_NAME),
   aligned(sizeof(void *
= { 0 };
-#endif /* JCR_SECTION_NAME */
+#endif /* TARGET_USE_JCR_SECTION  JCR_SECTION_NAME */
 
 #if USE_TM_CLONE_REGISTRY
 # ifndef HAVE_GAS_HIDDEN
@@ -742,7 +742,7 @@
 {
   func_ptr *p;
 #if defined(USE_EH_FRAME_REGISTRY) \
-|| defined(JCR_SECTION_NAME) \
+|| defined(TARGET_USE_JCR_SECTION) \
 || defined(USE_TM_CLONE_REGISTRY)
   __do_global_ctors_1();
 #endif