You are not logged in.
Pages: 1
I tried using gcov in a similar way to what is described here:
http://www.chennainerd.in/blog/2014/06/ … ting-tool/
coverage.c:
#include <stdio.h>
int main(int argc, char* argv[])
{
printf("Hello World");
return 0;
}
Makefile:
CC = x86_64-w64-mingw32-gcc -v
CFLAGS=-fprofile-arcs -ftest-coverage
LDFLAGS=-fprofile-arcs -ftest-coverageclean:
@rm -rf coverage.exe coverage coverage.o
When I use the native compiler "make coverage CC=gcc" everything works as expected. When I try to use the mingw-w64 cross-compiler "make coverage" I run into the following linker error
/tmp/ccmLDFQC.o:coverage.c:(.text+0x75): undefined reference to `__gcov_exit'
I tried a couple of suggestion found on the internet, e.g. invoking -lgcov directly but ended up with the same error. Does anybody understand why this works with the native compiler but fails with mingw-w64.
Kind regards
Here is the complete log:
make coverage
x86_64-w64-mingw32-gcc -v -fprofile-arcs -ftest-coverage -fprofile-arcs -ftest-coverage -lgcov --coverage coverage.c -o coverage
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: /build/mingw-w64-gcc/src/gcc/configure --prefix=/usr --libexecdir=/usr/lib --target=x86_64-w64-mingw32 --enable-languages=c,lto,c++,objc,obj-c++,fortran,ada --enable-shared --enable-static --enable-threads=posix --enable-fully-dynamic-string --enable-libstdcxx-time=yes --with-system-zlib --enable-cloog-backend=isl --enable-lto --disable-dw2-exceptions --enable-libgomp --disable-multilib --enable-checking=release
Thread model: posix
gcc version 7.1.1 20170516 (GCC)
COLLECT_GCC_OPTIONS='-v' '-fprofile-arcs' '-ftest-coverage' '-coverage' '-o' 'coverage' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/cc1 -quiet -v -D_REENTRANT coverage.c -quiet -dumpbase coverage.c -mtune=generic -march=x86-64 -auxbase coverage -version -fprofile-arcs -ftest-coverage -fprofile-arcs -ftest-coverage -o /tmp/cca0Pqt0.s
GNU C11 (GCC) version 7.1.1 20170516 (x86_64-w64-mingw32)
compiled by GNU C version 7.1.1 20170516, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/sys-include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/include
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/include-fixed
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C11 (GCC) version 7.1.1 20170516 (x86_64-w64-mingw32)
compiled by GNU C version 7.1.1 20170516, GMP version 6.1.2, MPFR version 3.1.5-p2, MPC version 1.0.3, isl version isl-0.18-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7b5a8226b0826ba933266dfcffbbc68a
COLLECT_GCC_OPTIONS='-v' '-fprofile-arcs' '-ftest-coverage' '-coverage' '-o' 'coverage' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/bin/as -v -o /tmp/ccgayDjK.o /tmp/cca0Pqt0.s
GNU assembler version 2.28 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.28
COMPILER_PATH=/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/:/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/:/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/lib/
COLLECT_GCC_OPTIONS='-v' '-fprofile-arcs' '-ftest-coverage' '-coverage' '-o' 'coverage' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/collect2 -plugin /usr/lib/gcc/x86_64-w64-mingw32/7.1.1/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/lto-wrapper -plugin-opt=-fresolution=/tmp/cc7EJnau.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic -o coverage /usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o /usr/lib/gcc/x86_64-w64-mingw32/7.1.1/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/7.1.1 -L/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/lib/../lib -L/usr/lib/gcc/x86_64-w64-mingw32/7.1.1/../../../../x86_64-w64-mingw32/lib -lgcov /tmp/ccgayDjK.o -lgcov -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt /usr/lib/gcc/x86_64-w64-mingw32/7.1.1/crtend.o
/tmp/ccgayDjK.o:coverage.c:(.text+0x75): undefined reference to `__gcov_exit'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: coverage] Error 1Offline
Pages: 1