mimalloc
mimalloc copied to clipboard
control over non-api symbol declarations
I'm currently evaluating using mimalloc as libc allocator in Chimera Linux (https://chimera-linux.org). Currently, we have LLVM's Scudo integrated into our libc but testing shows that mimalloc may be a better fit.
However, the API of mimalloc is extensive, while I only require to expose a handful of symbols. I'd like to make the other symbols local in order to avoid polluting the static libc.a (in shared libc.so, symbol visibility takes care of it already). In order to integrate the allocator I am using the object build (i.e. everything is a single translation unit) so I can easily mark every function (except my specific allocator entrypoints) static
and get what I want.
For public API symbols, handling this is easy; I just do #define mi_decl_export static
and that takes care of it. For internal symbols which do not have a tag this is harder; currently I have to patch every declaration the headers. Would it be possible to have a (by default empty) macro tagging these internal symbols so I get to reduce the amount of integration patching I have to do downstream? This should apply to any functions as well as extern
variables; e.g. my current mimalloc.o
has
q66@chimera: /home/q66/mimalloc/build$ nm mimalloc.o|grep ' [TBR] '
0000000000000760 T __libc_calloc
0000000000000800 T __libc_free
0000000000000960 T __libc_malloc_impl
00000000000009b0 T __libc_realloc
0000000000000220 T __malloc_atfork
0000000000000750 T __malloc_donate
0000000000000010 T __malloc_init
0000000000000210 T __malloc_thread_init
0000000000000230 T __malloc_tls_teardown
0000000000000ba0 T aligned_alloc
0000000000000c40 T malloc_usable_size
(all of which are my symbols that hook into the libc internally, except the last two which become libc public API)