Skip to content

Commit af14cc4

Browse files
committed
Fixes
1 parent ad04ace commit af14cc4

File tree

1 file changed

+83
-81
lines changed

1 file changed

+83
-81
lines changed

libc/src/stdlib/CMakeLists.txt

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -323,89 +323,91 @@ add_entrypoint_object(
323323
.rand_util
324324
)
325325

326-
if(LLVM_LIBC_INCLUDE_SCUDO)
327-
set(SCUDO_DEPS "")
328-
329-
include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
330-
331-
# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
332-
# set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
333-
if (LIBC_TARGET_OS_IS_DARWIN AND (LIBC_TARGET_ARCHITECTURE STREQUAL "arm"))
334-
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO arm64)
326+
if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
327+
if(LLVM_LIBC_INCLUDE_SCUDO)
328+
set(SCUDO_DEPS "")
329+
330+
include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
331+
332+
# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
333+
# set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
334+
if (LIBC_TARGET_OS_IS_DARWIN AND (LIBC_TARGET_ARCHITECTURE STREQUAL "arm"))
335+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO arm64)
336+
else()
337+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
338+
endif()
339+
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
340+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
341+
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
342+
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
343+
endif()
344+
345+
if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
346+
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
347+
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
348+
endif()
349+
350+
list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
351+
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
352+
353+
if (COMPILER_RT_BUILD_GWP_ASAN)
354+
list(APPEND SCUDO_DEPS
355+
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
356+
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
357+
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
358+
)
359+
endif()
360+
361+
add_entrypoint_external(
362+
malloc
363+
DEPENDS
364+
${SCUDO_DEPS}
365+
)
366+
add_entrypoint_external(
367+
calloc
368+
DEPENDS
369+
${SCUDO_DEPS}
370+
)
371+
add_entrypoint_external(
372+
realloc
373+
DEPENDS
374+
${SCUDO_DEPS}
375+
)
376+
add_entrypoint_external(
377+
aligned_alloc
378+
DEPENDS
379+
${SCUDO_DEPS}
380+
)
381+
add_entrypoint_external(
382+
free
383+
DEPENDS
384+
${SCUDO_DEPS}
385+
)
386+
add_entrypoint_external(
387+
mallopt
388+
DEPENDS
389+
${SCUDO_DEPS}
390+
)
335391
else()
336-
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
337-
endif()
338-
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
339-
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
340-
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
341-
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
342-
endif()
343-
344-
if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
345-
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
346-
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
392+
add_entrypoint_external(
393+
malloc
394+
)
395+
add_entrypoint_external(
396+
calloc
397+
)
398+
add_entrypoint_external(
399+
realloc
400+
)
401+
add_entrypoint_external(
402+
aligned_alloc
403+
)
404+
add_entrypoint_external(
405+
free
406+
)
407+
add_entrypoint_external(
408+
mallopt
409+
)
347410
endif()
348-
349-
list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
350-
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
351-
352-
if (COMPILER_RT_BUILD_GWP_ASAN)
353-
list(APPEND SCUDO_DEPS
354-
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
355-
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
356-
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
357-
)
358-
endif()
359-
360-
add_entrypoint_external(
361-
malloc
362-
DEPENDS
363-
${SCUDO_DEPS}
364-
)
365-
add_entrypoint_external(
366-
calloc
367-
DEPENDS
368-
${SCUDO_DEPS}
369-
)
370-
add_entrypoint_external(
371-
realloc
372-
DEPENDS
373-
${SCUDO_DEPS}
374-
)
375-
add_entrypoint_external(
376-
aligned_alloc
377-
DEPENDS
378-
${SCUDO_DEPS}
379-
)
380-
add_entrypoint_external(
381-
free
382-
DEPENDS
383-
${SCUDO_DEPS}
384-
)
385-
add_entrypoint_external(
386-
mallopt
387-
DEPENDS
388-
${SCUDO_DEPS}
389-
)
390-
elseif(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
391-
add_entrypoint_external(
392-
malloc
393-
)
394-
add_entrypoint_external(
395-
calloc
396-
)
397-
add_entrypoint_external(
398-
realloc
399-
)
400-
add_entrypoint_external(
401-
aligned_alloc
402-
)
403-
add_entrypoint_external(
404-
free
405-
)
406-
add_entrypoint_external(
407-
mallopt
408-
)
409411
endif()
410412

411413
if(NOT LLVM_LIBC_FULL_BUILD)

0 commit comments

Comments
 (0)