[libc-commits] [libc] [libc][stdlib] Only add internal malloc in full build mode. Use the system malloc in overlay mode. (PR #95845)

via libc-commits libc-commits at lists.llvm.org
Mon Jun 17 13:49:34 PDT 2024


https://github.com/lntue created https://github.com/llvm/llvm-project/pull/95845

This causes an issue in overlay mode: https://github.com/llvm/llvm-project/pull/95736#issuecomment-2172739705


>From ffebdd0c41bde2b68517a7d2c5e4c7cb1f5bf28a Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Mon, 17 Jun 2024 20:43:49 +0000
Subject: [PATCH] [libc][stdlib] Only add internal malloc in full build mode. 
 Use the system malloc in overlay mode.

---
 libc/src/stdlib/CMakeLists.txt | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index e26c19f03f5ab..fdbf7b75e72f4 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -418,15 +418,23 @@ else()
       libc.src.string.memory_utils.inline_memcpy
       libc.src.string.memory_utils.inline_memset
   )
-  add_entrypoint_object(
-    malloc
-    SRCS
-      freelist_malloc.cpp
-    HDRS
-      malloc.h
-    DEPENDS
-      .freelist_heap
-  )
+  # Only add malloc in full build mode.  Use the system malloc in overlay mode.
+  if(LLVM_LIBC_FULL_BUILD)
+    add_entrypoint_object(
+      malloc
+      SRCS
+        freelist_malloc.cpp
+      HDRS
+        malloc.h
+      DEPENDS
+        .freelist_heap
+    )
+  else()
+    add_entrypoint_external(
+      malloc
+    )
+  endif()
+
   add_entrypoint_external(
     free
   )



More information about the libc-commits mailing list