This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]