ginkgo-project / ginkgo

Numerical linear algebra software package
https://ginkgo-project.github.io/
BSD 3-Clause "New" or "Revised" License
414 stars 88 forks source link

Fix dynamic cast leads the undefined symbol in clang/msys2/windows #1724

Closed yhmtsai closed 1 week ago

yhmtsai commented 2 weeks ago

It is reported in #1654 . We have some undefined symbol when building the shared library (libginkgo_reference) by the clang-18 from msys2 in windows.

In clang 18 (at least), the compiler include convert_to/move_to/... virtual function as undefined symbols when we use dynamic_cast. These symbols are from ConvertibleTo<..>, which contain general function like convert_to calling virtual functions, such that these functions are considered in the library. It can be observed with clang-18 on linux, too. However, there are different behaviors between systems.

The older compiler or gcc compiler put these function as weak symbol, so it does not complain undefined symbols.

This PR moves the matrix/preconditioner dispatch from the kernels to core such that there are no dynamic_cast in the codes.

It also needs to add -fno-assume-unique-vtables to clang/msys2/windowns to make the dynamic_cast to the class marked by final work. https://reviews.llvm.org/D154658 should be relevant

TODO:

sonarcloud[bot] commented 1 week ago

Quality Gate Failed Quality Gate failed

Failed conditions
20.7% Duplication on New Code (required ≤ 20%)

See analysis details on SonarQube Cloud

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 84.84848% with 5 lines in your changes missing coverage. Please review.

Project coverage is 91.63%. Comparing base (75434f7) to head (1bff73b). Report is 11 commits behind head on develop.

Files with missing lines Patch % Lines
test/preconditioner/batch_jacobi_kernels.cpp 0.00% 3 Missing :warning:
core/device_hooks/common_kernels.inc.cpp 0.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1724 +/- ## =========================================== + Coverage 89.94% 91.63% +1.68% =========================================== Files 782 782 Lines 63456 63243 -213 =========================================== + Hits 57078 57952 +874 + Misses 6378 5291 -1087 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: