CCF icon indicating copy to clipboard operation
CCF copied to clipboard

Link against snmalloc target, rather than including override sources

Open eddyashton opened this issue 10 months ago • 2 comments

Originally posted by @achamayou in https://github.com/microsoft/CCF/pull/6746#discussion_r1913032022

eddyashton avatar Jan 13 '25 11:01 eddyashton

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.

achamayou avatar Jan 27 '25 14:01 achamayou

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, ...

mjp41 avatar Jan 27 '25 14:01 mjp41