mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
Use mimalloc for Ladybird-owned allocations without overriding malloc(). Route kmalloc(), kcalloc(), krealloc(), and kfree() through mimalloc, and put the embedded Rust crates on the same allocator via a shared shim in AK/kmalloc.cpp. This also lets us drop kfree_sized(), since it no longer used its size argument. StringData, Utf16StringData, JS object storage, Rust error strings, and the CoreAudio playback helpers can all free their AK-backed storage with plain kfree(). Sanitizer builds still use the system allocator. LeakSanitizer does not reliably trace references stored in mimalloc-managed AK containers, so static caches and other long-lived roots can look leaked. Pass the old size into the Rust realloc shim so aligned fallback reallocations can move posix_memalign-backed blocks safely. Static builds still need a little linker help. macOS app binaries need the Rust allocator entry points forced in from liblagom-ak.a, while static ELF links can pull in identical allocator shim definitions from multiple Rust staticlibs. Keep the Apple -u flags and allow those duplicate shim symbols for LibJS and LibRegex links on Linux and BSD.
14 lines
443 B
CMake
14 lines
443 B
CMake
set(SOURCES
|
|
ECMAScriptRegex.cpp
|
|
RustRegex.cpp
|
|
)
|
|
|
|
ladybird_lib(LibRegex regex EXPLICIT_SYMBOL_EXPORT)
|
|
target_link_libraries(LibRegex PRIVATE LibUnicode)
|
|
|
|
import_rust_crate(MANIFEST_PATH Rust/Cargo.toml CRATE_NAME libregex_rust FFI_HEADER RustFFI.h)
|
|
target_link_libraries(LibRegex PRIVATE libregex_rust)
|
|
if ((LINUX OR BSD) AND NOT BUILD_SHARED_LIBS)
|
|
target_link_options(LibRegex INTERFACE LINKER:--allow-multiple-definition)
|
|
endif()
|