From a8d65102e9abe2280032c30c97f3b21c71ec6b93 Mon Sep 17 00:00:00 2001 From: siddiqui irshad Date: Thu, 29 Oct 2026 04:47:17 +0530 Subject: [PATCH] Fix FreeBSD build when jemalloc is disabled and include malloc_np.h in MallctlHelperTest On FreeBSD: 1. When FOLLY_USE_JEMALLOC is OFF, folly/portability/Malloc.h skipped including , resulting in missing declarations for mallocx, rallocx, mallctl, and related allocator symbols in downstream translation units. Include on FreeBSD in the fallback branch so standard non-standard allocator APIs remain available. 2. In MallctlHelperTest.cpp, FreeBSD uses instead of . Conditionally include on FreeBSD and safely guard JEMALLOC_VERSION_MAJOR. Fixes #2720 Fixes #2721 Fixes #1893 Signed-off-by: siddiqui irshad --- folly/memory/test/MallctlHelperTest.cpp | 6 +++++- folly/portability/Malloc.h | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/folly/memory/test/MallctlHelperTest.cpp b/folly/memory/test/MallctlHelperTest.cpp index df551abfe65..07a035eee13 100644 --- a/folly/memory/test/MallctlHelperTest.cpp +++ b/folly/memory/test/MallctlHelperTest.cpp @@ -19,11 +19,15 @@ #if defined(FOLLY_USE_JEMALLOC) && (!defined(FOLLY_SANITIZE) || !FOLLY_SANITIZE) #include +#if defined(__FreeBSD__) +#include +#else #include +#endif using namespace folly; -#if JEMALLOC_VERSION_MAJOR > 4 +#if defined(JEMALLOC_VERSION_MAJOR) && JEMALLOC_VERSION_MAJOR > 4 static constexpr char const* kDecayCmd = "arena.0.dirty_decay_ms"; #else static constexpr char const* kDecayCmd = "arena.0.decay_time"; diff --git a/folly/portability/Malloc.h b/folly/portability/Malloc.h index 8e785a9c728..2985c65b231 100644 --- a/folly/portability/Malloc.h +++ b/folly/portability/Malloc.h @@ -37,8 +37,9 @@ #define FOLLY_HAS_JEMALLOC_DEFS 1 #endif #else -#if !defined(__FreeBSD__) -#if __has_include() +#if defined(__FreeBSD__) +#include // @manual +#elif __has_include() #include #endif #define FOLLY_HAS_JEMALLOC_DEFS 0