public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* newlib & libgcov
@ 2008-06-12 15:08 Bingfeng Mei
  2008-06-12 18:11 ` Adam Nemet
  2008-06-16  1:54 ` Jan Hubicka
  0 siblings, 2 replies; 4+ messages in thread
From: Bingfeng Mei @ 2008-06-12 15:08 UTC (permalink / raw)
  To: gcc

Hello,
In our GCC porting, we use newlib instead of libc.  Today I tried to use
profiling feedback based optimization with option -fprofile-arcs.  But
the executable doesn't produce .gcda file.  I examined the disassembled
binary file and found the following functions are basically just dummy
ones: __gcov_init, __gcov_flush,  __gcov_merge_add. I checked libgcov.c
that contains these functions and found following code. 


#if defined(inhibit_libc)
/* If libc and its header files are not available, provide dummy
functions.  */

#ifdef L_gcov
void __gcov_init (struct gcov_info *p __attribute__ ((unused))) {}
void __gcov_flush (void) {}
#endif

#ifdef L_gcov_merge_add
void __gcov_merge_add (gcov_type *counters  __attribute__ ((unused)),
		       unsigned n_counters __attribute__ ((unused))) {}
#endif

#ifdef L_gcov_merge_single
void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)),
			  unsigned n_counters __attribute__ ((unused)))
{}
#endif

#ifdef L_gcov_merge_delta
void __gcov_merge_delta (gcov_type *counters  __attribute__ ((unused)),
			 unsigned n_counters __attribute__ ((unused)))
{}
#endif


Both -Dinhibit_libc and -DL_gcov are used as shown in our building log
file.  I guess -Dinhibit_libc is added because we used newlibc instead
of glibc. I tried to grep these functions in newlibc and didn't find
them.  My question is how to enable gcov with newlibc.  Do I need to
write my own versions of them?  Any suggestion is greatly appreciated.  

Cheers,
Bingfeng Mei

Broadcom UK

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

* Re: newlib & libgcov
  2008-06-12 15:08 newlib & libgcov Bingfeng Mei
@ 2008-06-12 18:11 ` Adam Nemet
  2008-06-16  1:54 ` Jan Hubicka
  1 sibling, 0 replies; 4+ messages in thread
From: Adam Nemet @ 2008-06-12 18:11 UTC (permalink / raw)
  To: Bingfeng Mei; +Cc: gcc

"Bingfeng Mei" <bmei@broadcom.com> writes:
> Both -Dinhibit_libc and -DL_gcov are used as shown in our building log
> file.  I guess -Dinhibit_libc is added because we used newlibc instead
> of glibc. I tried to grep these functions in newlibc and didn't find
> them.  My question is how to enable gcov with newlibc.  Do I need to
> write my own versions of them?  Any suggestion is greatly appreciated.  

You need to configure with --with-headers so that the headers are used during
the build and that inhibit_libc is not defined.  I think this is what the
crosstool-newlib script does as well.

Adam

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

* Re: newlib & libgcov
  2008-06-12 15:08 newlib & libgcov Bingfeng Mei
  2008-06-12 18:11 ` Adam Nemet
@ 2008-06-16  1:54 ` Jan Hubicka
  2008-06-16  8:30   ` Bingfeng Mei
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2008-06-16  1:54 UTC (permalink / raw)
  To: Bingfeng Mei; +Cc: gcc

> Hello,
> In our GCC porting, we use newlib instead of libc.  Today I tried to use
> profiling feedback based optimization with option -fprofile-arcs.  But
> the executable doesn't produce .gcda file.  I examined the disassembled
> binary file and found the following functions are basically just dummy
> ones: __gcov_init, __gcov_flush,  __gcov_merge_add. I checked libgcov.c
> that contains these functions and found following code. 
> 
> 
> #if defined(inhibit_libc)

I am not much expert in this area, but the inhibit_libc check here is
mainly to disable gcov functions for freestanding targets that don't
support normal IO.  If you use newlib instead of glibc, you still do
have libc, so why inhibit_libc is defined at first place?

Honza
> /* If libc and its header files are not available, provide dummy
> functions.  */
> 
> #ifdef L_gcov
> void __gcov_init (struct gcov_info *p __attribute__ ((unused))) {}
> void __gcov_flush (void) {}
> #endif
> 
> #ifdef L_gcov_merge_add
> void __gcov_merge_add (gcov_type *counters  __attribute__ ((unused)),
> 		       unsigned n_counters __attribute__ ((unused))) {}
> #endif
> 
> #ifdef L_gcov_merge_single
> void __gcov_merge_single (gcov_type *counters  __attribute__ ((unused)),
> 			  unsigned n_counters __attribute__ ((unused)))
> {}
> #endif
> 
> #ifdef L_gcov_merge_delta
> void __gcov_merge_delta (gcov_type *counters  __attribute__ ((unused)),
> 			 unsigned n_counters __attribute__ ((unused)))
> {}
> #endif
> 
> 
> Both -Dinhibit_libc and -DL_gcov are used as shown in our building log
> file.  I guess -Dinhibit_libc is added because we used newlibc instead
> of glibc. I tried to grep these functions in newlibc and didn't find
> them.  My question is how to enable gcov with newlibc.  Do I need to
> write my own versions of them?  Any suggestion is greatly appreciated.  
> 
> Cheers,
> Bingfeng Mei
> 
> Broadcom UK

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

* RE: newlib & libgcov
  2008-06-16  1:54 ` Jan Hubicka
@ 2008-06-16  8:30   ` Bingfeng Mei
  0 siblings, 0 replies; 4+ messages in thread
From: Bingfeng Mei @ 2008-06-16  8:30 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc

I don't know why GCC defines inhibit_libc during configuration. Now I
use --with-headers according to another mail's suggestion, this problem
is solved. Thanks.

Bingfeng

-----Original Message-----
From: Jan Hubicka [mailto:hubicka@ucw.cz] 
Sent: 16 June 2008 02:54
To: Bingfeng Mei
Cc: gcc@gcc.gnu.org
Subject: Re: newlib & libgcov

> Hello,
> In our GCC porting, we use newlib instead of libc.  Today I tried to
use
> profiling feedback based optimization with option -fprofile-arcs.  But
> the executable doesn't produce .gcda file.  I examined the
disassembled
> binary file and found the following functions are basically just dummy
> ones: __gcov_init, __gcov_flush,  __gcov_merge_add. I checked
libgcov.c
> that contains these functions and found following code. 
> 
> 
> #if defined(inhibit_libc)

I am not much expert in this area, but the inhibit_libc check here is
mainly to disable gcov functions for freestanding targets that don't
support normal IO.  If you use newlib instead of glibc, you still do
have libc, so why inhibit_libc is defined at first place?

Honza
> /* If libc and its header files are not available, provide dummy
> functions.  */
> 
> #ifdef L_gcov
> void __gcov_init (struct gcov_info *p __attribute__ ((unused))) {}
> void __gcov_flush (void) {}
> #endif
> 
> #ifdef L_gcov_merge_add
> void __gcov_merge_add (gcov_type *counters  __attribute__ ((unused)),
> 		       unsigned n_counters __attribute__ ((unused))) {}
> #endif
> 
> #ifdef L_gcov_merge_single
> void __gcov_merge_single (gcov_type *counters  __attribute__
((unused)),
> 			  unsigned n_counters __attribute__ ((unused)))
> {}
> #endif
> 
> #ifdef L_gcov_merge_delta
> void __gcov_merge_delta (gcov_type *counters  __attribute__
((unused)),
> 			 unsigned n_counters __attribute__ ((unused)))
> {}
> #endif
> 
> 
> Both -Dinhibit_libc and -DL_gcov are used as shown in our building log
> file.  I guess -Dinhibit_libc is added because we used newlibc instead
> of glibc. I tried to grep these functions in newlibc and didn't find
> them.  My question is how to enable gcov with newlibc.  Do I need to
> write my own versions of them?  Any suggestion is greatly appreciated.

> 
> Cheers,
> Bingfeng Mei
> 
> Broadcom UK


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

end of thread, other threads:[~2008-06-16  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-12 15:08 newlib & libgcov Bingfeng Mei
2008-06-12 18:11 ` Adam Nemet
2008-06-16  1:54 ` Jan Hubicka
2008-06-16  8:30   ` Bingfeng Mei

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