Calling tcmalloc using Rust FFI
- Dominant language
- C++
- Stars
- 5.3k
- Forks
- 570
- Avg merge
- 23h 43m
- Merged PRs (30d)
- 172
Description
To provide some context, we are building a memory management framework written in Rust. We are experimenting with different malloc/free implementations.
We tried the following two approaches of linking with tcmalloc.
First, we tried to statically link with tcmalloc. We use the `libtcmalloc.lo` produced by `bazel build tcmalloc`.
We got the following error.
```
Error: failed because /path/to/OurLibrary.so: undefined symbol: _ZN8tcmalloc17tcmalloc_internal10Parameters23per_cpu_caches_enabled_E
```
Second, we tried to dynamically link with tcmalloc. Specifically, we deleted `linkstatic=1` (https://github.com/google/tcmalloc/blob/f4a573f/tcmalloc/BUILD#L91) and used `libtcmalloc.so` produced by Bazel.
We got the following error when run our executable linked with tcmalloc.
```
Error: failed because /path/to/libtcmalloc.so: undefined symbol: _ZN4absl19str_format_internal13FormatArgImpl8DispatchINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbNS1_4DataENS0_24FormatConversionSpecImplEPv
```
We are just wondering what the best practice of using tcmalloc standalone is (ODR is not a big issue for us as the project is in Rust #16 #48).
cc @caizixian
Contributor guide
Assessment
This issue has not been assessed yet.