CCF
CCF copied to clipboard
Link against snmalloc target, rather than including override sources
Originally posted by @achamayou in https://github.com/microsoft/CCF/pull/6746#discussion_r1913032022
It does look like we should be able to use something like:
set(SNMALLOC_ENABLE_DYNAMIC_LOADING ON)
set_property(TARGET snmalloc-new-override PROPERTY POSITION_INDEPENDENT_CODE ON)
...
build snmalloc
target_link_libraries($OUR_LIB INTERFACE snmalloc-new-override)
The first half is only needed for the .so, and can perhaps be removed when we switch to monolithic binaries.
That should work. It won't override malloc/free, but will do new/delete.
The snmallocshim-static target will provide a malloc and free. You also need to set:
SNMALLOC_STATIC_LIBRARY_PREFIX=""
As it defaults to SNMALLOC_STATIC_LIBRARY_PREFIX="sn_", and this defining sn_malloc, sn_free, ...