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 )