I have a project that has a lot of source files. They are then compiled to .o
objects and in the end, linked with main.o
to make main.exe
. I'm compiling all files (source1.c
, source2.c
, main.c
) with --coverage -O0
using gcc, generating .o
and .gcno
for each file. Then, I link everything together and call main.exe
, generating .gcda
files, again, for each object file.
When I run gcov source1.o source2.o main.o
I get a warning? error? for every function twice:
./tests/source1.gcno:'build' has arcs to entry block
./tests/source1.gcno:'build' has arcs from exit block
The problem is that this fills the terminal with these messages and takes a long time to finish. All I could find in SO was this, so I checked the version for both gcc and gcov:
$ gcc --version
gcc.exe (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gcov --version
gcov (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
And yet, that question didn't help me so much. I'm using the MinGW-w64 installed with chocolatey. I also couldn't find any examples on the internet using gcov
with multiple source files, hence the title.
I don't know exactly what is wrong, since I've been stuck with this problem for a week now. My project does run and produces code coverage, but these thousands and thousands of warnings are making my CI messages unnecessarily long.
Also, I would appreciate if anyone could explain better what the warning message means.
Edit:
Example of the flags that I'm using to compile main.c
:
gcc -Wall -Werror --coverage -O0 -lgcov -I ./tests/include -I ./src -c ./tests/main.c -o ./tests/build/main.o