On Tue, May 17, 2022 at 11:42 AM Michael Stahl <[email protected]> wrote:
> 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 : > > > > external/expat/ExternalProject_expat.mk > > external/liborcus/ExternalProject_liborcus.mk > > > > 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. > What basically is intended, is that all of LibreOffice gets compiled with gcov code coverage magic included, which I believe indeed translates to 'all' makefiles. But I already got the idea that the way I modified those makefiles was a terrible way to do things; it's just that this seemed the quickest/easiest way (from my point of view, considering my inexperience with makefiles) to test things out, without having to take the deep dive into the build system and the makefiles. > > > 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 > configure script. > > 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. > > Thanks for that bit. The fact that I still find it slightly difficult to follow only underscores my inability to read or modify makefiles (properly). > 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). > What I got from that, was that I need to do *both* of the following : set CFLAGS/CXXFLAGS/LDFLAGS for gcov on the ./autogen commandline : CFLAGS='-fprofile-arcs -ftest-coverage' CXXFLAGS='-fprofile-arcs -ftest-coverage' LDFLAGS='-fprofile-arcs -lgcov' ./autogen.sh and set gb_GCOV=YES on the make commandline : gb_GCOV=YES make which gives me a successful build (!) (without having to modify any makefiles). Thanks. - Maarten
