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

Calling tcmalloc using Rust FFI #66

Open
paigereeves opened this issue Jan 11, 2021 · 2 comments
Open

Calling tcmalloc using Rust FFI #66

paigereeves opened this issue Jan 11, 2021 · 2 comments

Comments

@paigereeves
Copy link

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 <executable> 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 <executable> 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

@ckennelly
Copy link
Collaborator

_ZN8tcmalloc17tcmalloc_internal10Parameters23per_cpu_caches_enabled_E is defined in the //tcmalloc:common target. _ZN4absl19str_format_internal13FormatArgImpl8DispatchINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEbNS1_4DataENS0_24FormatConversionSpecImplEPv is defined by one of the libraries provided by Abseil.

I think the issue here is that the build isn't linking against all of the dependencies.

@caizixian
Copy link

@ckennelly Thanks for the reply! Do you have any recommendation on how we can go about producing a standalone library for our use case (presumably by changing the BUILD file)? Sorry, I'm not familiar enough with Bazel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants