如何解决来自 lcov 的 Perl_xs_handshake 符号查找错误。

huangapple go评论85阅读模式
英文:

How to resolve symbol lookup error Perl_xs_handshake from lcov

问题

我正在使用CMake编译一个大型程序。文件结构如下:

结构 pt1
结构 pt2

我的目标是创建一个lcov覆盖率报告,告诉我测试中运行了代码的哪一部分,位于/meshFieldsDev/meshFields/test/中。

我正在使用这个模块:https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake

这是我的CMakeLists.txt中运行该模块的相关代码:
相关代码

要运行代码,我首先执行以下命令:

rm -rf build-meshFields-cuda/

meshFieldsDev 中删除构建目录,确保我有一个新的构建目录。

然后我运行

cmake -S meshFields -B build-meshFields-cuda -D meshFields_ENABLE_COVERAGE_BUILD=ON -DCMAKE_BUILD_TYPE=Debug

以进行调试构建/创建新的构建目录。

接下来,我进入构建目录,build-meshFields-cuda,然后运行 makemake coverage

"Make coverage" 导致错误:

/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

我相当肯定我无法访问工作区外的文件,即,我不能更新或安装新模块。这是我们加载的内容:

已加载模块

根据Stack Overflow上类似的帖子,这个错误是由于在模块/编译中使用了两个不同版本的perl引起的。我相信lcov默认使用usr/bin/perl,而我们想要使用的perl版本的路径是/opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/perl-5.30.3-tmxduzj6hwvxe6ccra6jg3ec65ltesis/bin/perl

我们尝试重新安装了很多东西,包括lcov、gcc、perl及其模块,希望这可以解决问题/将它们放在同一个目录中。但这并没有帮助,因为虽然我们已经在/opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/lcov-1.16-5lw4jlj5ignaucfzy4ruons4khzkmzdz/bin/lcov中安装了lcov,它仍然默认使用usr/bin/perl

我尝试过这个:
https://github.com/linux-test-project/lcov/commit/74bae96e8ef724eb9dbdf126adad17505375e149
以便lcov使用正确版本的perl,但遇到了这个错误:

我得到的错误

我认为这可能是因为我无法访问文件系统中的更高级别,所以无法安装或更改任何内容。我不知道是否有其他方法来强制它不使用默认设置。

我还尝试在make之后运行以下命令(有人告诉我它将使用perl-5.30.3版本):

$ perl -S  lcov -c -d . -o main_coverage.info

但结果仍然是相同的错误。

英文:

I am using CMake to compile a large program. The file structures is seen here:

Structure pt1
Structure pt2

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:

Loaded modules

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:

Error I got

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.

答案1

得分: 0

事实证明,lcov.perlgeninfo.perlgenhtml.perl 中的 shebang 在安装时设置为默认路径,对我来说是 usr/bin/perl。这不是我想要使用的perl版本的路径,所以我只需将shebang更改为正确的路径,即 /opt/scorec/spack/v0154_2/install/linux-rhel7-x86_64/gcc-10.1.0/perl-5.30.3-tmxduzj6hwvxe6ccra6jg3ec65ltesis/bin/perl

如果将来更新了硬编码路径中的perl,这将导致问题,但是我没有权限更改 usr/bin/perl

英文:

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.

huangapple
  • 本文由 发表于 2023年7月11日 00:16:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76655581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定