Unable to link jemalloc to rust

I’m trying to make bytehound memory profiler a nix package. The issue I have problem comes from a tikv-jemalloc-sys. I saw that jemalloc is compiled within the build.rs script, this causes problems and so I compiled jemalloc manually from the package(correct version) and then override a variable that allows you to point to the linker object (JEMALLOC_OVERRIDE).

I however get errors such as this “undefined reference to `_rjem_mp_malloc’” reproducable:

When building this project outside of nix I seem to be able to find the symbols and am unaware why the symbols can’t be found within nix.

https://github.com/ewan15/nixpkgs/blob/4a1d74123d705effb51b8b1573f3b3f7e5f397eb/pkgs/development/tools/bytehound/default.nix (edited)

This error was caused by a cyclic dependency in porting the bytehound project.