- Define a set of symbols (
rust_free, etc) which correspond to the APIs specified in
liballoclibrary will call these symbols directly. Note that this means that each of the symbols take information like the size of allocations and such.
- Create two shim libraries which implement these
rust_fooallocation-related functions. Each shim is shipped with the compiler in the form of a static library. One shim will redirect to libc, the other shim will bundle an unprefixed jemalloc build along with shims to redirect to jemalloc.
- Intermediate artifacts (rlibs) do not resolve this dependency, they're just left dangling.
- When producing a "final artifact", rustc by default links in one of two shims:
- If we're producing a staticlib or a dylib, link the libc malloc shim.
- If we're producing an exe and one or more dependencies are rust dylibs, link the libc malloc shim
- If we're producing an exe and all dependencies are rlibs link the jemalloc shim.
The final link step will be optional, and one could link in any compliant allocator at that time if so desired.