Compiling LO for lcov/gcov code coverage fails (gb_GCOV=YES)
mst at libreoffice.org
Tue May 17 09:42:11 UTC 2022
On 13.05.22 16:42, Maarten Hoes wrote:
> So to sum it up, with only gcc installed, the gcov build works if I modify :
> and add :
> CFLAGS += -fprofile-arcs -ftest-coverage
> CXXFLAGS += -fprofile-arcs -ftest-coverage
> LDFLAGS += -fprofile-arcs -lgcov
> to the top of them. Of course, that does not seem to be a proper
> permanent solution to the issue: the question remains why these *FLAGS
> don't end up in these 2 files when you specify 'gb_GCOV=YES make'.
also, there is another problem: setting global variables like this will
affect *all* makefiles, which may or may not be what you intend - it's
certainly bad style to do it from a local makefile.
> Pointers to where I should start looking in the build system in an
> attempt to troubleshoot things are appreciated. I found the point where
> the flags are supposed to be set conditionally in lines 112-117 in
> 'solenv/gbuild/platform/com_GCC_defs.mk' , but don't really know how to
> proceed from there. Perhaps the variables
> "gb_CFLAGS_COMMON/gb_CXXFLAGS_COMMON/gb_LinkTarget_LDFLAGS" are not used
> in the right places, or overwritten with something else ?
the global *FLAGS variables should be in config_host.mk, set from
often the best way to set *FLAGS locally is to pass them to the
configure invocation in an ExternalProject*.mk, taking care not to mess
up make's terrible syntax (like \ EOL escaping).
but the ExternalProject_expat.mk doesn't set *FLAGS variables - so the
ones from config_host.mk should be in effect - and the
ExternalProject_liborcus.mk sets them by "liborcus_CXXFLAGS=$(CXXFLAGS)
..." so effectively appending.
ah, in LinkTarget.mk in the gb_GCOV case no CXXFLAGS are set, only
gb_CXXFLAGS_COMMON etc - that explains the problems you see, these are
only used for gbuild's native LinkTargets.
if you want coverage in externals, it might make sense to pass properly
set *FLAGS variables to LO's configure - this will then override
gbuild's optimization and debugging flags, so include "-g" in case it's
needed for the converage (i don't know how that works).
More information about the LibreOffice