Google Groupes n'accepte plus les nouveaux posts ni abonnements Usenet. Les contenus de l'historique resteront visibles.

Any advice on building a code coverage build with gcov?

317 vues
Accéder directement au premier message non lu

Clint Talbert

non lue,
25 juin 2008, 23:28:2425/06/2008
à
I'm trying to build a code coverage instrumented build with gcov;
however, I'm not having much luck.

I'm using the mozilla central repo, on Ubuntu 8.04. My gcc version is:
4.2.3. My gcov version is also 4.2.3.

I've tried the following different settings in my mozconfig file, and I
note the output of each below them.

# Take 1
export CFLAGS="-fprofile-arcs -ftest-coverage"
export CXXFLAGS="-fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov"
--> DSO errors on compiled tests (see the error below)


# Take 2
export CFLAGS="-fprofile-arcs -ftest-coverage -shared"
export CXXFLAGS="-fprofile-arcs -ftest-coverage -shared"
export OS_CFLAGS="-fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov"
export XLDOPTS="-lgcov"
--> segfaults in binaries (see the error below)
--> note that this one did not hit any DSO errors. Also rebuilding the
specific DSO failures with the -shared option present caused those
builds to succeed, but I then hit the segfault issue once I tried to run
binaries generated that way.

# Take 3
export CFLAGS="-fprofile-arcs -ftest-coverage"
export CXXFLAGS="-fprofile-arcs -ftest-coverage"
export OS_CFLAGS="-fprofile-arcs -ftest-coverage"
export LDFLAGS="-lgcov"
export XLDOPTS="-lgcov"
# --> DSO errors on compiled tests (see the error below)

# Take 4 - bc's approach
export CFLAGS="--coverage"
export CXXFLAGS="--coverage"
export OS_CFLAGS="--coverage"
export LDFLAGS="--coverage"
export XLDOPTS="--coverage"
# --> DSO errors on compiled tests (see the error below)

== The Errors ==

Attempts 1, 3, and 4 all create the same error, it happens for every
compiled code test and it looks like this:

ar cr libxremote_client_s.a XRemoteClient.o
ranlib libxremote_client_s.a
/usr/bin/ld: mozilla-xremote-client: hidden symbol `__gcov_merge_add' in
/usr/lib/gcc/i486-linux-gnu/4.2.3/libgcov.a(_gcov_merge_add.o) is
referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[4]: *** [mozilla-xremote-client] Error 1
make[4]: Leaving directory
`/home/mozilla/mozcentral/dbg/widget/src/xremoteclient'
make[3]: *** [libs_tier_toolkit] Error 2
make[3]: Leaving directory `/home/mozilla/mozcentral/dbg'
make[2]: *** [tier_toolkit] Error 2
make[2]: Leaving directory `/home/mozilla/mozcentral/dbg'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/home/mozilla/mozcentral/dbg'
make: *** [build] Error 2

Attempt 2 causes a segfault immediately when any built binary is executed:

gcc -DOSTYPE=\"Linux2.6\" -DOSARCH=Linux
-I/home/mozilla/mozcentral/config -I. -I../dist/include
-I../dist/include -I../dist/include/nspr -I../dist/sdk/include
-fPIC -Wall -W -Wno-unused -Wpointer-arith -Wcast-align -W
-Wno-long-long -pedantic -fprofile-arcs -ftest-coverage -shared
-fno-strict-aliasing -pthread -pipe -DDEBUG -D_DEBUG -DDEBUG_mozilla
-DTRACING -g -fno-inline -include ../mozilla-config.h -DMOZILLA_CLIENT
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -o elf-dynstr-gc
/home/mozilla/mozcentral/config/elf-dynstr-gc.c -lpthread -lgcov
-Wl,-rpath-link,../dist/bin -lgobject-2.0 -lglib-2.0
gcc -o nsinstall -fprofile-arcs -ftest-coverage -shared -DXP_UNIX
host_nsinstall.o host_pathsub.o
/home/mozilla/mozcentral/dbg/config/nsinstall -R -m 644
../mozilla-config.h /home/mozilla/mozcentral/config/nsStaticComponents.h
../dist/include
make[4]: *** [export] Segmentation fault
make[4]: Leaving directory `/home/mozilla/mozcentral/dbg/config'
make[3]: *** [export_tier_base] Error 2
make[3]: Leaving directory `/home/mozilla/mozcentral/dbg'
make[2]: *** [tier_base] Error 2
make[2]: Leaving directory `/home/mozilla/mozcentral/dbg'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/home/mozilla/mozcentral/dbg'
make: *** [build] Error 2

I really appreciate any advice or direction you can give me on this.
I've also attempted this on Mac OS X 10.4 (gcc 4.0.1) and I got
something that looked a lot like the "DSO" error, though it had a
different wording it was still referring to the problem of being unable
to link with the shared libraries.

I've read that building with gcov in shared library is usually a
problem. Is there a way to build the core OS libaries in as statics?
Perhaps that would solve this.

Thanks for the help.

Clint

Peter Weilbacher

non lue,
27 juin 2008, 02:40:1127/06/2008
à
On 26.06.2008 05:28, Clint Talbert wrote:
> I'm trying to build a code coverage instrumented build with gcov;
> however, I'm not having much luck.
>
> I'm using the mozilla central repo, on Ubuntu 8.04. My gcc version is:
> 4.2.3. My gcov version is also 4.2.3.
[...]

> I've read that building with gcov in shared library is usually a
> problem. Is there a way to build the core OS libaries in as statics?
> Perhaps that would solve this.

I have done the exact same exercise yesterday, although with GCC 3.3.5
on OS/2. There I had to use -static-libgcc in the LDFLAGS to be able to
link without errors.

Peter.

Clint Talbert

non lue,
30 juin 2008, 17:08:3330/06/2008
à
Peter Weilbacher wrote:

> I have done the exact same exercise yesterday, although with GCC 3.3.5
> on OS/2. There I had to use -static-libgcc in the LDFLAGS to be able to
> link without errors.

Thanks Peter, let me give that a whirl on my Ubuntu box.

Clint

Clint Talbert

non lue,
2 juil. 2008, 19:31:0202/07/2008
à

I've tried this now with a couple of different attempts. The best
looking attempt (that got the furthest) has the mozconfig below. It
failed with this error:

c++ -o mozilla-xremote-client -fno-rtti -fno-exceptions -Wall
-Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-long-long
-pedantic -fprofile-arcs -ftest-coverage -fno-strict-aliasing
-fshort-wchar -pthread -pipe -DDEBUG -D_DEBUG -DDEBUG_mozilla -DTRACING
-g -fno-inline mozilla-xremote-client.o XRemoteClient_standalone.o
-lpthread -lgcov -static-libgcc
-Wl,-rpath-link,../../../dist/bin -L../../../dist/bin
-L../../../dist/lib -L../../../dist/lib -lplds4 -lplc4 -lnspr4 -lpthread
-ldl -lX11 -ldl -lm


ranlib libxremote_client_s.a
/usr/bin/ld: mozilla-xremote-client: hidden symbol `__gcov_merge_add' in
/usr/lib/gcc/i486-linux-gnu/4.2.3/libgcov.a(_gcov_merge_add.o) is
referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[4]: *** [mozilla-xremote-client] Error 1
make[4]: Leaving directory

`/home/mozilla/mozcentral/mozcentral-dbg/widget/src/xremoteclient'


make[3]: *** [libs_tier_toolkit] Error 2

make[3]: Leaving directory `/home/mozilla/mozcentral/mozcentral-dbg'


make[2]: *** [tier_toolkit] Error 2

make[2]: Leaving directory `/home/mozilla/mozcentral/mozcentral-dbg'


make[1]: *** [default] Error 2

make[1]: Leaving directory `/home/mozilla/mozcentral/mozcentral-dbg'


make: *** [build] Error 2


Here is the mozconfig:

. $topsrcdir/browser/config/mozconfig

export CFLAGS="-fprofile-arcs -ftest-coverage"
export CXXFLAGS="-fprofile-arcs -ftest-coverage"

export LDFLAGS="-lgcov -static-libgcc"

mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --enable-places
ac_add_options --enable-application=browser
ac_add_options --enable-airbag
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../mozcentral-dbg
mk_add_options
MOZ_CO_MODULE=mozilla/js/tests,mozilla/tools/tinderbox-configs

ac_add_options --disable-tests
ac_add_options --enable-mochitest

ac_add_options --enable-extensions=default,inspector,layout-debug
# ac_add_options --disable-javaxpcom

ac_add_options --enable-debug
ac_add_options --disable-static
ac_add_options --enable-shared
ac_add_options --disable-optimize
ac_add_options --disable-composer
ac_add_options --disable-mailnews
ac_add_options --disable-crashreporter
ac_add_options --disable-install
ac_add_options --enable-libxul

#ac_add_options --with-macos-sdk="/Developer/SDKs/MacOSX10.4u.sdk"

mk_add_options MOZ_MAKE_FLAGS="-j3"

mk_add_options AUTOCONF=autoconf2.13

Thanks for any help or other ideas folks have. I'm getting a VM set up
with Ubuntu 7.10 to try it there.

Clint

Benjamin Smedberg

non lue,
4 juil. 2008, 00:49:5304/07/2008
à
Clint Talbert wrote:

> c++ -o mozilla-xremote-client -fno-rtti -fno-exceptions -Wall
> -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth
> -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-long-long
> -pedantic -fprofile-arcs -ftest-coverage -fno-strict-aliasing
> -fshort-wchar -pthread -pipe -DDEBUG -D_DEBUG -DDEBUG_mozilla -DTRACING
> -g -fno-inline mozilla-xremote-client.o XRemoteClient_standalone.o
> -lpthread -lgcov -static-libgcc -Wl,-rpath-link,../../../dist/bin
> -L../../../dist/bin -L../../../dist/lib -L../../../dist/lib -lplds4
> -lplc4 -lnspr4 -lpthread -ldl -lX11 -ldl -lm
> ranlib libxremote_client_s.a
> /usr/bin/ld: mozilla-xremote-client: hidden symbol `__gcov_merge_add' in
> /usr/lib/gcc/i486-linux-gnu/4.2.3/libgcov.a(_gcov_merge_add.o) is
> referenced by DSO

This isn't very helpful, because it doesn't say *which* DSO is referencing
that symbol. Can you run `nm` on the various sharedlib (libnspr4.so?) to
find which one is referencing that symbol (and for kicks, figure out why
that sharedlib isn't being linked against -lgcov).

--BDS

Clint Talbert

non lue,
10 juil. 2008, 14:19:4310/07/2008
à
Benjamin Smedberg wrote:

> Clint Talbert wrote:
>
> This isn't very helpful, because it doesn't say *which* DSO is
> referencing that symbol. Can you run `nm` on the various sharedlib
> (libnspr4.so?) to find which one is referencing that symbol (and for
> kicks, figure out why that sharedlib isn't being linked against -lgcov).
>
Thanks for the comment Benjamin. Running nm on the libnspr4.so I can
see that these symbols are indeed undefined:
0007b110 r __PRETTY_FUNCTION__.2718
U __assert_fail@@GLIBC_2.0
00082054 A __bss_start
U __ctype_b_loc@@GLIBC_2.3
w __cxa_finalize@@GLIBC_2.1.3
00076130 t __divdi3
00076870 t __do_global_ctors_aux
0000a480 t __do_global_dtors_aux
00080b40 d __dso_handle
U __environ@@GLIBC_2.0
U __errno_location@@GLIBC_2.0
00076790 t __fstat
U __fxstat64@@GLIBC_2.2
U __fxstat@@GLIBC_2.0
U __gcov_execv
U __gcov_execve
U __gcov_fork
U __gcov_init
U __gcov_merge_add
w __gmon_start__
U __h_errno_location@@GLIBC_2.0
0000a517 t __i686.get_pc_thunk.bx
000762b0 t __moddi3
U __stack_chk_fail@@GLIBC_2.4
00076850 t __stack_chk_fail_local

One other thing that catches my eye here is that it appears that several
versions of GLIBC_2.x are being referenced. Is that normal?

I'm going to try to figure out why libnspr4.so isn't being linked
against -lgcov next, I'm going to respin the build and I'll update here
once I have something useful to report.

0 nouveau message