Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker Error while compiling SOFA with LLVM 16 #4402

Open
sandeep-amd opened this issue Dec 21, 2023 · 2 comments
Open

Linker Error while compiling SOFA with LLVM 16 #4402

sandeep-amd opened this issue Dec 21, 2023 · 2 comments
Labels
issue: bug (minor) Bug affecting only some users or with no major impact on the framework

Comments

@sandeep-amd
Copy link

Hi,

While trying to compile SOFA(https://github.com/sofa-framework/sofa => branch "v23.06") with LLVM 16 , we are getting linker errors as below,

ld.lld: error: undefined symbol: vtable for sofa::linearalgebra::FullVector

referenced by ld-temp.o
lto.tmp:(sofa::component::odesolver::testing::getVector(boost::intrusive_ptrsofa::simulation::Node, sofa::core::TVecId<(sofa::core::
VecType)0, (sofa::core::VecAccess)0>, bool))
did you mean: typeinfo for sofa::linearalgebra::FullVector
defined in: ../../../../../lib/libSofa.LinearAlgebra.so.23.06.00
the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Sofa/Component/ODESolver/Backward/tests/CMakeFiles/Sofa.Component.ODESolver.Backward_test.dir/build.make:212: bin/Sofa.Component.ODESolver
.Backward_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:5981: Sofa/Component/ODESolver/Backward/tests/CMakeFiles/Sofa.Component.ODESolver.Backward_test.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs...

To Resolve this, we have included definition of key function of FullVector calss in FullVector.cpp. The key function seems to be resize() - i.e the first non-pure, non-linear and virtual function in a polymorphic class. The actual definition of resize() is present in FullVector.inl file and we have commented it out.

Please let us know if the changes are good.

Thanks,
Sandeep.

@sandeep-amd sandeep-amd added the issue: bug (minor) Bug affecting only some users or with no major impact on the framework label Dec 21, 2023
@alxbilger
Copy link
Contributor

Hi,

thanks for reporting a build problem. I have not had the chance to play with LLVM 16 yet.

I agree that the key function of FullVector is resize. However, it is defined in the inl file. The template is explicitly instantiated in the cpp file, and it corresponds to the template parameter used in getVector (function from EigenTestUtilities.h). The cpp file includes the inl file. Therefore, I don't understand that the linker emit an error suggesting that it is not defined...

Was it the only problem in the whole build?

@sandeep-amd
Copy link
Author

Yes, that is the only problem we have encountered. Having the definition in the cpp file seems to fix the issue.

Also, it seems like without a key function definition in the cpp file for which obj needs to be created , there is no vtable reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug (minor) Bug affecting only some users or with no major impact on the framework
Projects
None yet
Development

No branches or pull requests

2 participants