From 0d58595241620ce3ddcce64a7c07b6cd0781bcad Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Fri, 6 Oct 2023 09:51:37 +0200 Subject: [PATCH] Link jemalloc only to binaries Baking a custom malloc into a library can cause problems because client binaries can easily end up with multiple malloc implementations. Quoting jemalloc dev David Goldblatt from their chat channel: > I sort of think that dynamic libraries have no business defining > their own malloc independent of the process malloc https://app.element.io/#/room/#jemalloc_jemalloc:gitter.im/$LubsysDtwVeAfQgOkJDfdkUP4E9O554PX5rH-qq1VRQ --- CMakeLists.txt | 1 - include/fluent-bit/flb_mem.h | 4 ---- src/CMakeLists.txt | 10 ---------- 3 files changed, 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99109309405..bde1efbdae6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -915,7 +915,6 @@ endif() # Memory Allocator # ================ if(FLB_JEMALLOC AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux") - FLB_DEFINITION(FLB_HAVE_JEMALLOC) FLB_DEFINITION(JEMALLOC_MANGLE) # Add support for options like page size, if empty we default it diff --git a/include/fluent-bit/flb_mem.h b/include/fluent-bit/flb_mem.h index 04d7bc55686..9cad4bc64de 100644 --- a/include/fluent-bit/flb_mem.h +++ b/include/fluent-bit/flb_mem.h @@ -27,10 +27,6 @@ #include #include -#ifdef FLB_HAVE_JEMALLOC -#include -#endif - #include /* diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b6233d9f721..4928f289ee0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -202,12 +202,6 @@ set(extra_libs ${extra_libs} "rbtree") -if(FLB_JEMALLOC) - set(extra_libs - ${extra_libs} - "libjemalloc") -endif() - if(FLB_REGEX) set(FLB_DEPS ${FLB_DEPSS} @@ -467,10 +461,6 @@ else() set_target_properties(fluent-bit-static PROPERTIES OUTPUT_NAME fluent-bit) endif(MSVC) -if(FLB_JEMALLOC) - target_link_libraries(fluent-bit-static libjemalloc) -endif() - # Binary / Executable if(FLB_BINARY) find_package (Threads)