xref: /minix3/share/mk/minix.gcov.mk (revision 3ac58492b3d3709bad0ae9c60a137f63a90960b7)
106617e7fSArun ThomasLCOV=lcov.$(PROG)
206617e7fSArun ThomasCLEANFILES+= *.gcno *.gcda $(LCOV)
306617e7fSArun Thomas
4*3ac58492SDavid van Moolenbroek# Right now we support obtaining coverage information for system services only,
5*3ac58492SDavid van Moolenbroek# and for their main program code (not including their libraries) only.
6*3ac58492SDavid van Moolenbroek#
7*3ac58492SDavid van Moolenbroek# Why not userland as well: because we do not care as much, and it should be
8*3ac58492SDavid van Moolenbroek# possible to produce coverage information for system services without
9*3ac58492SDavid van Moolenbroek# recompiling the entire system with coverage support.  Moreover, as of writing
10*3ac58492SDavid van Moolenbroek# we do not have libprofile_rt, making it impossible to compile regular
11*3ac58492SDavid van Moolenbroek# programs with coverage support altogether.
12*3ac58492SDavid van Moolenbroek#
13*3ac58492SDavid van Moolenbroek# Why not system service libraries (eg libsys) as well: practical concerns..
14*3ac58492SDavid van Moolenbroek# 1) As of writing, even for such libraries we make a regular and a PIC
15*3ac58492SDavid van Moolenbroek#    version, both producing a .gcno file for each object.  The PIC version is
16*3ac58492SDavid van Moolenbroek#    compiled last, while the regular version is used for the library archive.
17*3ac58492SDavid van Moolenbroek#    The result is a potential mismatch between the compile-time coverage
18*3ac58492SDavid van Moolenbroek#    metadata and the run-time coverage counts.
19*3ac58492SDavid van Moolenbroek# 2) The kernel has no coverage support, and with its self-relocation it would
20*3ac58492SDavid van Moolenbroek#    be tricky to add support for it.  As a result, libraries used by the
21*3ac58492SDavid van Moolenbroek#    kernel would have to be excluded from being compiled with coverage support
22*3ac58492SDavid van Moolenbroek#    so as not to create problems.  One could argue that that is a good thing
23*3ac58492SDavid van Moolenbroek#    because eg libminc and libsys create too many small result units (see also
24*3ac58492SDavid van Moolenbroek#    the current hardcoded limit in libsys/llvm_gcov.c).
25*3ac58492SDavid van Moolenbroek# 3) gcov-pull(8) strips paths, which results in lots of manual work to figure
26*3ac58492SDavid van Moolenbroek#    out what file belongs to which library, even ignoring object name
27*3ac58492SDavid van Moolenbroek#    conflicts, for example between libraries.
28*3ac58492SDavid van Moolenbroek# 4) In order to produce practically useful results ("how much of libsockevent
29*3ac58492SDavid van Moolenbroek#    is covered by the combination of LWIP and UDS" etc), gcov-pull(8) would
30*3ac58492SDavid van Moolenbroek#    have to be extended with support for merging .gcda files.  The standard
31*3ac58492SDavid van Moolenbroek#    LLVM libprofile_rt implementation supports this, but we do not.
32*3ac58492SDavid van Moolenbroek# All of these issues are solvable, but for now anyone interested in coverage
33*3ac58492SDavid van Moolenbroek# for a particular system service library will have to mess with individual
34*3ac58492SDavid van Moolenbroek# makefiles themselves.
35*3ac58492SDavid van Moolenbroek
36*3ac58492SDavid van Moolenbroek.if ${MKCOVERAGE:Uno} == "yes"
37*3ac58492SDavid van Moolenbroek.if ${ACTIVE_CC} == "gcc"
38*3ac58492SDavid van Moolenbroek# Leftovers for GCC.  It is not clear whether these still work at all.
39*3ac58492SDavid van MoolenbroekCOVCPPFLAGS?= -fno-builtin -fprofile-arcs -ftest-coverage
40*3ac58492SDavid van MoolenbroekCOVLDADD?= -lgcov
41*3ac58492SDavid van Moolenbroek.else # ${ACTIVE_CC} != "gcc"
42*3ac58492SDavid van Moolenbroek# We assume LLVM/clang here.  For other compilers this will likely break the
43*3ac58492SDavid van Moolenbroek# MKCOVERAGE compilation, which is a good indication that support for them
44*3ac58492SDavid van Moolenbroek# should be added here.
45*3ac58492SDavid van MoolenbroekCOVCPPFLAGS?= --coverage -g -O0
46*3ac58492SDavid van MoolenbroekCOVLDADD?=
47*3ac58492SDavid van Moolenbroek.endif # ${ACTIVE_CC} != "gcc"
48*3ac58492SDavid van Moolenbroek.endif # ${MKCOVERAGE:Uno} == "yes"
4906617e7fSArun Thomas
5006617e7fSArun Thomaslcov:
5106617e7fSArun Thomas	lcov -c -d . >$(LCOV)
52