cygwin64 mingw64 VM gcov does not generate gcda file

97 Views Asked by At

The machine I am using is a Mac (M1 chip). And everything works fine there. But I want to make sure it can also build on Windows. Where it is not working.

I have built a VM and installed a very basic Windows.11.
I install the SSH-Server component manually (via the normal GUI) then I ssh into the machine and continue working in the shell.

  1. Download https://cygwin.com/setup-x86_64.exe
  2. Run the basic cygwin setup
    $exePath -qnNdO -R C:/cygwin64 -s http://cygwin.mirror.constant.com -l C:/cygwin64/var/cache/setup
  3. Switch into bash:
  4. Install the build tools:
  • alias setup="/cygdrive/c/cygwin64/setup-x86_64.exe -qnNdO -R C:/cygwin64 -s http://cygwin.mirror.constant.com -l C:/cygwin64/var/cache/"
  • setup -P autoconf -P automake -P make -P git -P gperf -P gcovr -P coreutils -P mingw64-x86_64-gcc-g++ -P mingw64-x86_64-yaml -P mingw64-x86_64-boost -P mingw64-x86_64-dlfcn"
  • ln -s /cygdrive/c/cygwin64/bin/x86_64-w64-mingw32-g++.exe /cygdrive/c/cygwin64/bin/g++"
  • ln -s /cygdrive/c/cygwin64/usr/x86_64-w64-mingw32/bin/ar.exe /cygdrive/c/cygwin64/bin/ar.exe"

Then my test is build like this:

> cat test.cpp
#include <iostream>


int main(int argc, char* argv[])
{

        if (argc % 2 == 0) {
                std::cerr << "We have a 0\n";
        }
        else {
                std::cerr << "We have a 1\n";
        }
}
> $ ls -la
total 378
drwxrwxrwx+ 1 Loki   None        0 May 16 16:23 .
drwxrwx---+ 1 SYSTEM SYSTEM      0 May 16 15:39 ..
-rw-r--r--+ 1 Loki   None      161 May 16 15:38 test.cpp
>
> g++ -c test.cpp -g -fprofile-arcs -ftest-coverage -coverage
> g++ -o done test.o -g -fprofile-arcs -ftest-coverage -coverage -lgcov
> PATH=/cygdrive/c/cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/bin/ ./done.exe 1
We have a 0
libgcov profiling error:/cygdrive/c/Users/Loki/G/test.gcda:overwriting an existing profile data with a different timestamp
> ls -la 
total 378
drwxrwxrwx+ 1 Loki   None        0 May 16 16:23 .
drwxrwx---+ 1 SYSTEM SYSTEM      0 May 16 15:39 ..
-rwxr-xr-x+ 1 Loki   None   338149 May 16 16:23 done.exe
-rw-r--r--+ 1 Loki   None      161 May 16 15:38 test.cpp
-rw-r--r--+ 1 Loki   None     1692 May 16 16:23 test.gcno
-rw-r--r--+ 1 Loki   None    19596 May 16 16:23 test.o
> $ PATH=/cygdrive/c/cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/bin/ ./done.exe 1
We have a 0
> ls -la 
total 378
drwxrwxrwx+ 1 Loki   None        0 May 16 16:23 .
drwxrwx---+ 1 SYSTEM SYSTEM      0 May 16 15:39 ..
-rwxr-xr-x+ 1 Loki   None   338149 May 16 16:23 done.exe
-rw-r--r--+ 1 Loki   None      161 May 16 15:38 test.cpp
-rw-r--r--+ 1 Loki   None     1692 May 16 16:23 test.gcno
-rw-r--r--+ 1 Loki   None    19596 May 16 16:23 test.o

Notice that when I run the executable the first I get: libgcov profiling error:/cygdrive/c/Users/Loki/G/test.gcda:overwriting an existing profile data with a different timestamp, but no such warning when I run the second time.

But the main issue is that I am expecting the file test.gcda to be generated and it is not created.

Not sure what I am doing wrong.

0

There are 0 best solutions below