So from my understanding, f2py creates a c wrapper, and a F90 wrapper to handle inputs/outputs for F77 code. It stores everything in a shared dll and links that to a pyd file. Is there any way to get gcov to work with this setup? To be clear, I want coverage reporting for the F77 code - not the wrappers. So far, I have tried to manually go through the steps and adding in the necessary flags, but I don't see any gcda files generated. When compiling the source .f files, I use -fprofile-arcs -ftest-coverage and for the linker flags I use -lgcov after the output option:
gfortran -Wall -g -shared -fprofile-arcs -ftest-coverage [object files] -L$(PYTHON_DIR)/libs - L$(PYTHON_DIR)/PCbuild/amd64 -o $(TEST_DIR)/libREDACTED.gfortran-win_amd64.dll -Wl,--allow-multiple-definition -Wl,--output-def,$(DEF_FILE) -Wl,--export-all-symbols -Wl,--enable-auto-import -static -mlong-double-64 -lgcov
This also creates the .def file used to create a .lib file in the following command:
lib.exe /def:"$ROOT\test\libREDACTED.gfortran-win_amd64.def" /OUT:"$ROOT\test\libREDACTED.gfortran-win_amd64.lib" /MACHINE:X64
We then compile the C wrapper with the following:
cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD
-I"$ROOT\test\fortranobject"
-I"C:\Python3\Anaconda3.8_x64\lib\site-packages\numpy\core\include"
-I"C:\Python3\Anaconda3.8_x64\include"
-I"C:\Python3\Anaconda3.8_x64\include"
-I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\include"
-I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include"
-I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um"
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt"
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared"
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um"
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt"
-I"C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt"
/Tc"$ROOT\test\REDACTED_fmodule.c"
/Fo"$ROOT\test\REDACTED_fmodule.obj"
Everything is then linked together using this command:
link.exe /DEBUG /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO
/LIBPATH:"C:\cygwin64\lib\gcc\x86_64-pc-cygwin\4.9.2"
/LIBPATH:"C:\Python3\Anaconda3.8_x64\libs"
/LIBPATH:"C:\Python3\Anaconda3.8_x64\PCbuild\amd64"
/LIBPATH:"C:\Python3\Anaconda3.8_x64\libs"
/LIBPATH:"C:\Python3\Anaconda3.8_x64\PCbuild\amd64"
/LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\ATLMFC\lib\x64"
/LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\lib\x64"
/LIBPATH:"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64"
/LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64"
/LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64"
/EXPORT:PyInit_REDACTED_f
"$ROOT\test\REDACTED_fmodule.obj"
"$ROOT\test\fortranobject\fortranobject.obj"
"$ROOT\test\libREDACTED.gfortran-win_amd64.lib"
/OUT:"$ROOT\test\REDACTED_f.cp38-win_amd64.pyd"
/IMPLIB:"$ROOT\test\REDACTED_f.cp38-win_amd64.lib"
fortranobject is just a resource that f2py uses and isn't specific to my code. Now all of this links without issue, and I can import the module into Python, but I don't see any gcda files generated anywhere. Am I missing something or over-simplifying this somehow?