Skip to content

Commit 09bc1e8

Browse files
authored
[libc][stdlib] Only use freelist_malloc for baremetal targets. (llvm#96355)
1 parent e52016a commit 09bc1e8

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

libc/src/stdlib/CMakeLists.txt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,18 +380,24 @@ elseif(LIBC_TARGET_OS_IS_GPU)
380380
aligned_alloc
381381
)
382382
else()
383-
# Only add malloc in full build mode. Use the system malloc in overlay mode.
384-
if(LLVM_LIBC_FULL_BUILD)
383+
# Only use freelist malloc for baremetal targets.
384+
add_entrypoint_object(
385+
freelist_malloc
386+
SRCS
387+
freelist_malloc.cpp
388+
HDRS
389+
malloc.h
390+
DEPENDS
391+
libc.src.__support.freelist_heap
392+
COMPILE_OPTIONS
393+
-DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
394+
)
395+
if(LIBC_TARGET_OS_IS_BAREMETAL)
385396
add_entrypoint_object(
386397
malloc
387-
SRCS
388-
freelist_malloc.cpp
389-
HDRS
390-
malloc.h
398+
ALIAS
391399
DEPENDS
392-
libc.src.__support.freelist_heap
393-
COMPILE_OPTIONS
394-
-DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
400+
.freelist_malloc
395401
)
396402
else()
397403
add_entrypoint_external(

libc/test/src/__support/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if(LLVM_LIBC_FULL_BUILD)
3636
DEPENDS
3737
libc.src.__support.CPP.span
3838
libc.src.__support.freelist_heap
39-
libc.src.stdlib.malloc
39+
libc.src.stdlib.freelist_malloc
4040
libc.src.string.memcmp
4141
libc.src.string.memcpy
4242
)

0 commit comments

Comments
 (0)