Skip to content

Commit 379cc44

Browse files
authored
Revert "[libc] Breakup freelist_malloc into separate files" (llvm#119749)
Reverts llvm#98784 which broke libc builders.
1 parent 88bcf72 commit 379cc44

File tree

15 files changed

+110
-173
lines changed

15 files changed

+110
-173
lines changed

libc/config/baremetal/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ set(TARGET_LIBC_ENTRYPOINTS
184184
libc.src.stdlib.div
185185
libc.src.stdlib.exit
186186
libc.src.stdlib.free
187+
libc.src.stdlib.freelist_malloc
187188
libc.src.stdlib.labs
188189
libc.src.stdlib.ldiv
189190
libc.src.stdlib.llabs

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ set(TARGET_LIBC_ENTRYPOINTS
184184
libc.src.stdlib.div
185185
libc.src.stdlib.exit
186186
libc.src.stdlib.free
187+
libc.src.stdlib.freelist_malloc
187188
libc.src.stdlib.labs
188189
libc.src.stdlib.ldiv
189190
libc.src.stdlib.llabs

libc/config/baremetal/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ set(TARGET_LIBC_ENTRYPOINTS
180180
libc.src.stdlib.div
181181
libc.src.stdlib.exit
182182
libc.src.stdlib.free
183+
libc.src.stdlib.freelist_malloc
183184
libc.src.stdlib.labs
184185
libc.src.stdlib.ldiv
185186
libc.src.stdlib.llabs

libc/src/__support/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,13 @@ add_header_library(
4848
.freetrie
4949
)
5050

51-
add_object_library(
51+
add_header_library(
5252
freelist_heap
53-
SRCS
54-
freelist_heap.cpp
5553
HDRS
5654
freelist_heap.h
57-
COMPILE_OPTIONS
58-
-DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
5955
DEPENDS
6056
.block
61-
.freelist
6257
.freestore
63-
.freetrie
6458
libc.src.__support.CPP.cstddef
6559
libc.src.__support.CPP.array
6660
libc.src.__support.CPP.optional

libc/src/__support/freelist_heap.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

libc/src/stdlib/CMakeLists.txt

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ add_entrypoint_object(
323323
.rand_util
324324
)
325325

326-
if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
326+
if(NOT LIBC_TARGET_OS_IS_GPU)
327327
if(LLVM_LIBC_INCLUDE_SCUDO)
328328
set(SCUDO_DEPS "")
329329

@@ -349,7 +349,7 @@ if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
349349

350350
list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
351351
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
352-
352+
353353
if (COMPILER_RT_BUILD_GWP_ASAN)
354354
list(APPEND SCUDO_DEPS
355355
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
@@ -389,8 +389,32 @@ if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
389389
${SCUDO_DEPS}
390390
)
391391
else()
392+
# Only use freelist malloc for baremetal targets.
393+
add_entrypoint_object(
394+
freelist_malloc
395+
SRCS
396+
freelist_malloc.cpp
397+
HDRS
398+
malloc.h
399+
DEPENDS
400+
libc.src.__support.freelist_heap
401+
)
402+
get_target_property(freelist_malloc_is_skipped libc.src.stdlib.freelist_malloc "SKIPPED")
403+
if(LIBC_TARGET_OS_IS_BAREMETAL AND NOT freelist_malloc_is_skipped)
404+
add_entrypoint_object(
405+
malloc
406+
ALIAS
407+
DEPENDS
408+
.freelist_malloc
409+
)
410+
else()
411+
add_entrypoint_external(
412+
malloc
413+
)
414+
endif()
415+
392416
add_entrypoint_external(
393-
malloc
417+
free
394418
)
395419
add_entrypoint_external(
396420
calloc
@@ -401,12 +425,6 @@ if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
401425
add_entrypoint_external(
402426
aligned_alloc
403427
)
404-
add_entrypoint_external(
405-
free
406-
)
407-
add_entrypoint_external(
408-
mallopt
409-
)
410428
endif()
411429
endif()
412430

@@ -495,7 +513,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
495513
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
496514
endif()
497515

498-
if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU)
516+
if(LIBC_TARGET_OS_IS_GPU)
499517
add_entrypoint_object(
500518
malloc
501519
ALIAS

libc/src/stdlib/baremetal/CMakeLists.txt

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,3 @@ add_entrypoint_object(
55
HDRS
66
../abort.h
77
)
8-
9-
add_entrypoint_object(
10-
malloc
11-
SRCS
12-
malloc.cpp
13-
HDRS
14-
../malloc.h
15-
DEPENDS
16-
libc.src.__support.freelist_heap
17-
)
18-
19-
add_entrypoint_object(
20-
free
21-
SRCS
22-
free.cpp
23-
HDRS
24-
../free.h
25-
DEPENDS
26-
libc.src.__support.freelist_heap
27-
)
28-
29-
add_entrypoint_object(
30-
calloc
31-
SRCS
32-
calloc.cpp
33-
HDRS
34-
../calloc.h
35-
DEPENDS
36-
libc.src.__support.freelist_heap
37-
)
38-
39-
add_entrypoint_object(
40-
realloc
41-
SRCS
42-
realloc.cpp
43-
HDRS
44-
../realloc.h
45-
DEPENDS
46-
libc.src.__support.freelist_heap
47-
)
48-
49-
add_entrypoint_object(
50-
aligned_alloc
51-
SRCS
52-
aligned_alloc.cpp
53-
HDRS
54-
../aligned_alloc.h
55-
DEPENDS
56-
libc.src.__support.freelist_heap
57-
)

libc/src/stdlib/baremetal/calloc.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

libc/src/stdlib/baremetal/free.cpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

libc/src/stdlib/baremetal/malloc.cpp

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)