junrushao commented on issue #307:
URL: https://github.com/apache/tvm-ffi/issues/307#issuecomment-3613877612
@oraluben and I did some digging, and let me debrief what’s going on under
the hood.
**Observation**. Missing symbol `__cxa_call_terminate` raises from libtvm.so
(libtvm.so is part of TileLang distro), when built against certain tvm-ffi
versions. Specifically,
* ✅ apache-tvm-ffi 0.1.0
* ❌ apache-tvm-ffi 0.1.4
* ✅ apache-tvm-ffi 0.1.5-rc*
**What does `_cxa_call_terminate` do**. This symbol is part of higher
version of libstdc++ runtime, specifically, it's introduced in CXXABI_1.3.15 in
libstdc++ when the library SONAME was bumped to libstdc++.so.6.0.33.
GCC >= 14 generates call into libstdc++’s symbol `_cxa_call_terminate` when
exceptions are raised inside a noexcept method, which essentially calls
`std::terminate`. tvm-ffi wheels are always built in manylinux_2_28 using GCC
14.
**Does libtvm_ffi.so require this symbol**? No in principle. However, in
reality, before #240, it is needed as the noexcept method `what()` uses
`std::string`, which could throw and leads GCC 14 to generate calling to this
symbol. #240 fixes this issue as part of 0.1.4 release.
Did a little digging into libtvm_ffi.so, and it shows:
- v0.1.0 contains `_cxa_call_terminate` in its text section ("T")
- v0.1.4 doesn't have `_cxa_call_terminate`
**Why is `_cxa_call_terminate` in text section?** Toolchain gcc-toolset-14
in manylinux_2_28 provides libstdc++.so as a ld script:
```
>>> cat
/opt/rh/gcc-toolset-14/root/usr/lib/gcc/x86_64-redhat-linux/14/libstdc++.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-x86-64)
INPUT ( /usr/lib64/libstdc++.so.6 -lstdc++_nonshared AS_NEEDED
(/usr/lib64/libstdc++.so.6) )
```
which, will bring in symbols from
`/opt/rh/gcc-toolset-14/root/usr/lib/gcc/x86_64-redhat-linux/14/libstdc++_nonshared.a`
upon symbol missing.
In this case, the symbol `_cxa_call_terminate` is indeed missing from
`/usr/lib64/libstdc++.so.6`, and the linker brings it into `libtvm_ffi.so` per
request. That explains why v0.1.0 has this symbol in its text section.
**Does libtvm.so needs this symbol**? It's unclear to me. This symbol is
needed if one throws in a noexcept method, which is extremely rare in TVM
codebase AFAICT. If it does have such behaviors and the behavior is intended,
one will need a higher version of libstdc++.so which has this symbol.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]