[libc-commits] [libc] 09bc1e8 - [libc][stdlib] Only use freelist_malloc for baremetal targets. (#96355)

via libc-commits libc-commits at lists.llvm.org
Fri Jun 21 13:38:28 PDT 2024


Author: lntue
Date: 2024-06-21T16:38:25-04:00
New Revision: 09bc1e825068f314db71ee7eb32d9f93c5ac87a0

URL: https://github.com/llvm/llvm-project/commit/09bc1e825068f314db71ee7eb32d9f93c5ac87a0
DIFF: https://github.com/llvm/llvm-project/commit/09bc1e825068f314db71ee7eb32d9f93c5ac87a0.diff

LOG: [libc][stdlib] Only use freelist_malloc for baremetal targets. (#96355)

Added: 
    

Modified: 
    libc/src/stdlib/CMakeLists.txt
    libc/test/src/__support/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 51d53e0d02ea2..7d99fdf38141a 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -380,18 +380,24 @@ elseif(LIBC_TARGET_OS_IS_GPU)
     aligned_alloc
   )
 else()
-  # Only add malloc in full build mode.  Use the system malloc in overlay mode.
-  if(LLVM_LIBC_FULL_BUILD)
+  # Only use freelist malloc for baremetal targets.
+  add_entrypoint_object(
+    freelist_malloc
+    SRCS
+      freelist_malloc.cpp
+    HDRS
+      malloc.h
+    DEPENDS
+      libc.src.__support.freelist_heap
+    COMPILE_OPTIONS
+      -DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
+  )
+  if(LIBC_TARGET_OS_IS_BAREMETAL)
     add_entrypoint_object(
       malloc
-      SRCS
-        freelist_malloc.cpp
-      HDRS
-        malloc.h
+      ALIAS
       DEPENDS
-        libc.src.__support.freelist_heap
-      COMPILE_OPTIONS
-        -DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
+        .freelist_malloc
     )
   else()
     add_entrypoint_external(

diff  --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index 082a002959c95..e224e82c922f0 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -36,7 +36,7 @@ if(LLVM_LIBC_FULL_BUILD)
     DEPENDS
       libc.src.__support.CPP.span
       libc.src.__support.freelist_heap
-      libc.src.stdlib.malloc
+      libc.src.stdlib.freelist_malloc
       libc.src.string.memcmp
       libc.src.string.memcpy
   )


        


More information about the libc-commits mailing list