I am looking into dynamic memory of rust and I see that they eventually go to
__rust_alloc and friends. but the LLVM code simply leaves them declared. how are these function implemented?
__rust_* functions are defined in https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/allocator.rs. They dispatch to either
__rg_alloc depending on if
#[global_allocator] is used or the default libstd implementation.
__rg_alloc methods are expanded from
#[global_allocator] by https://github.com/rust-lang/rust/blob/8534be72fc3b9c5f2f2dc4e4ee7b651a008e9a3e/src/librustc_builtin_macros/global_allocator.rs
thx for the pointer. then it seems to go to
GlobalAlloc::alloc but it's just a trait. how this function gets injected then?
System.alloc() is called. In the
.alloc() is called on the static that has the
For system allocators, on Unix, it is listed here: https://github.com/rust-lang/rust/blob/900869371e13cead086f4f9809419daa6a63cfaf/src/libstd/sys/unix/alloc.rs#L6-L24
thx, that's really cool