I am using CMake to compile a large program. The file structures is seen here:
My goal is to create an lcov coverage report that tells me what portion of the code is run by the tests in /meshFieldsDev/meshFields/test/
I am using this module: https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake
This is the relevant code in my CMakeLists.txt that runs the module: Relevant code
To run the code I start by running
rm -rf build-meshFields-cuda/
from meshFieldsDev
to blow away the build directory and ensure I have a fresh build directory.
I then run
cmake -S meshFields -B build-meshFields-cuda -D meshFields_ENABLE_COVERAGE_BUILD=ON -DCMAKE_BUILD_TYPE=Debug
to make a debug build / create the fresh build directory.
Next I cd
into the build directory, build-meshFields-cuda and run make
and make coverage
.
"Make coverage" results in the error:
/usr/bin/perl: symbol lookup error: /opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/perl-compress-raw-zlib-2.081-woruhujhcqpsvppu7ox7keagflycc4c7/lib/perl5/x86_64-linux-thread-multi/auto/Compress/Raw/Zlib/Zlib.so: undefined symbol: Perl_xs_handshake
I am fairly certain I don't have access to files outside my workspace, i.e., I cannot update or install new modules. Here is what we have loaded:
According to similar posts on Stack Overflow, the error results from two different versions of perl being used across modules / compilation. I believe that lcov compiles with usr/bin/perl
by default and the path for the version of perl we want to use is /opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/perl-5.30.3-tmxduzj6hwvxe6ccra6jg3ec65ltesis/bin/perl
.
We tried reinstalling a bunch of stuff, lcov, gcc, perl and it's modules in hopes that would fix the issue / put them in the same directory. This did not help since while we have lcov installed in /opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/lcov-1.16-5lw4jlj5ignaucfzy4ruons4khzkmzdz/bin/lcov along side perl-5.30.3
it's default is still grabbing from usr/bin/perl
.
I tried this: https://github.com/linux-test-project/lcov/commit/74bae96e8ef724eb9dbdf126adad17505375e149 to have lcov use the proper version of perl and was met with this error:
I think that this is likely because I don't have access to the higher level in the file system so I can't install or change anything up there. I do not know if there is another way to force it to not use the default.
I also tried running this command after the make (I was told it would use the 5.30.3 version of perl)
$ perl -S lcov -c -d . -o main_coverage.info
However it resulted in the same error.
Turns out, the shebangs in lcov.perl
, geninfo.perl
, and genhtml.perl
are set at install time to the default path, in my case usr/bin/perl
. This was not the path for the version of perl I wanted to use so I simply changed the shebangs to be the correct path, /opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/perl-5.30.3-tmxduzj6hwvxe6ccra6jg3ec65ltesis/bin/perl
.
This will cause issues in the future if I update the perl in this hardcoded path but I am not permitted to change usr/bin/perl
.