721 lines · plain
1add_entrypoint_object(2 atoi3 SRCS4 atoi.cpp5 HDRS6 atoi.h7 DEPENDS8 libc.src.errno.errno9 libc.src.__support.str_to_integer10)11 12add_entrypoint_object(13 atof14 SRCS15 atof.cpp16 HDRS17 atof.h18 DEPENDS19 libc.src.errno.errno20 libc.src.__support.str_to_float21)22 23add_entrypoint_object(24 atol25 SRCS26 atol.cpp27 HDRS28 atol.h29 DEPENDS30 libc.src.errno.errno31 libc.src.__support.str_to_integer32)33 34add_entrypoint_object(35 atoll36 SRCS37 atoll.cpp38 HDRS39 atoll.h40 DEPENDS41 libc.src.errno.errno42 libc.src.__support.str_to_integer43)44 45add_entrypoint_object(46 quick_exit47 SRCS48 quick_exit.cpp49 HDRS50 quick_exit.h51 DEPENDS52 libc.src.__support.OSUtil.osutil53 .exit_handler54 .at_quick_exit55 .atexit56)57 58add_entrypoint_object(59 getenv60 SRCS61 getenv.cpp62 HDRS63 getenv.h64 DEPENDS65 libc.config.app_h66)67 68add_entrypoint_object(69 strfromf70 SRCS71 strfromf.cpp72 HDRS73 strfromf.h74 DEPENDS75 .str_from_util76 libc.src.__support.CPP.limits77 libc.src.stdio.printf_core.error_mapper78)79 80add_entrypoint_object(81 strfromd82 SRCS83 strfromd.cpp84 HDRS85 strfromd.h86 DEPENDS87 .str_from_util88 libc.src.__support.CPP.limits89 libc.src.stdio.printf_core.error_mapper90)91 92add_entrypoint_object(93 strfroml94 SRCS95 strfroml.cpp96 HDRS97 strfroml.h98 DEPENDS99 .str_from_util100 libc.src.__support.CPP.limits101 libc.src.stdio.printf_core.error_mapper102)103 104add_header_library(105 str_from_util106 HDRS107 str_from_util.h108 DEPENDS109 libc.src.stdio.printf_core.converter110 libc.src.stdio.printf_core.core_structs111 libc.src.stdio.printf_core.writer112 libc.src.__support.str_to_integer113 libc.src.__support.CPP.type_traits114)115 116add_entrypoint_object(117 strtof118 SRCS119 strtof.cpp120 HDRS121 strtof.h122 DEPENDS123 libc.src.errno.errno124 libc.src.__support.str_to_float125)126 127add_entrypoint_object(128 strtod129 SRCS130 strtod.cpp131 HDRS132 strtod.h133 DEPENDS134 libc.src.errno.errno135 libc.src.__support.str_to_float136)137 138add_entrypoint_object(139 strtold140 SRCS141 strtold.cpp142 HDRS143 strtold.h144 DEPENDS145 libc.src.errno.errno146 libc.src.__support.str_to_float147)148 149add_entrypoint_object(150 strtol151 SRCS152 strtol.cpp153 HDRS154 strtol.h155 DEPENDS156 libc.src.errno.errno157 libc.src.__support.str_to_integer158)159 160add_entrypoint_object(161 strtoll162 SRCS163 strtoll.cpp164 HDRS165 strtoll.h166 DEPENDS167 libc.src.errno.errno168 libc.src.__support.str_to_integer169)170 171add_entrypoint_object(172 strtoul173 SRCS174 strtoul.cpp175 HDRS176 strtoul.h177 DEPENDS178 libc.src.errno.errno179 libc.src.__support.str_to_integer180)181 182add_entrypoint_object(183 strtoull184 SRCS185 strtoull.cpp186 HDRS187 strtoull.h188 DEPENDS189 libc.src.errno.errno190 libc.src.__support.str_to_integer191)192 193add_entrypoint_object(194 a64l195 SRCS196 a64l.cpp197 HDRS198 a64l.h199 DEPENDS200 libc.hdr.stdint_proxy201 libc.hdr.types.size_t202 libc.src.__support.ctype_utils203)204 205add_entrypoint_object(206 l64a207 SRCS208 l64a.cpp209 HDRS210 l64a.h211 DEPENDS212 libc.hdr.stdint_proxy213 libc.hdr.types.size_t214 libc.src.__support.ctype_utils215)216 217add_entrypoint_object(218 abs219 SRCS220 abs.cpp221 HDRS222 abs.h223 DEPENDS224 libc.src.__support.integer_operations225)226 227add_entrypoint_object(228 labs229 SRCS230 labs.cpp231 HDRS232 labs.h233 DEPENDS234 libc.src.__support.integer_operations235)236 237add_entrypoint_object(238 llabs239 SRCS240 llabs.cpp241 HDRS242 llabs.h243 DEPENDS244 libc.src.__support.integer_operations245)246 247add_entrypoint_object(248 div249 SRCS250 div.cpp251 HDRS252 div.h253 DEPENDS254 libc.hdr.types.div_t255 libc.src.__support.integer_operations256)257 258add_entrypoint_object(259 ldiv260 SRCS261 ldiv.cpp262 HDRS263 ldiv.h264 DEPENDS265 libc.hdr.types.ldiv_t266 libc.src.__support.integer_operations267)268 269add_entrypoint_object(270 lldiv271 SRCS272 lldiv.cpp273 HDRS274 lldiv.h275 DEPENDS276 libc.hdr.types.lldiv_t277 libc.src.__support.integer_operations278)279 280add_entrypoint_object(281 bsearch282 SRCS283 bsearch.cpp284 HDRS285 bsearch.h286 DEPENDS287 libc.include.stdlib288)289 290add_header_library(291 qsort_util292 HDRS293 qsort_data.h294 qsort_util.h295 heap_sort.h296 quick_sort.h297 DEPENDS298 libc.hdr.stdint_proxy299 libc.include.stdlib300 libc.src.__support.CPP.cstddef301 libc.src.string.memory_utils.inline_memcpy 302)303 304add_entrypoint_object(305 qsort306 SRCS307 qsort.cpp308 HDRS309 qsort.h310 DEPENDS311 .qsort_util312 libc.hdr.stdint_proxy313 libc.hdr.types.size_t314)315 316add_entrypoint_object(317 qsort_r318 SRCS319 qsort_r.cpp320 HDRS321 qsort_r.h322 DEPENDS323 .qsort_util324 libc.hdr.stdint_proxy325 libc.hdr.types.size_t326)327 328add_object_library(329 rand_util330 SRCS331 rand_util.cpp332 HDRS333 rand_util.h334 DEPENDS335 libc.src.__support.common336)337 338add_entrypoint_object(339 rand340 SRCS341 rand.cpp342 HDRS343 rand.h344 DEPENDS345 .rand_util346 libc.hdr.stdlib_macros347 libc.src.__support.threads.sleep348)349 350add_entrypoint_object(351 srand352 SRCS353 srand.cpp354 HDRS355 srand.h356 DEPENDS357 .rand_util358)359 360add_entrypoint_object(361 memalignment362 SRCS363 memalignment.cpp364 HDRS365 memalignment.h366 DEPENDS367 libc.src.__support.common368 libc.hdr.types.size_t369)370 371add_entrypoint_object(372 mbtowc373 SRCS374 mbtowc.cpp375 HDRS376 mbtowc.h377 DEPENDS378 libc.hdr.types.size_t379 libc.hdr.types.wchar_t380 libc.src.__support.common381 libc.src.__support.macros.config382 libc.src.__support.libc_errno383 libc.src.__support.wchar.mbrtowc384 libc.src.__support.wchar.mbstate385)386 387add_entrypoint_object(388 mbstowcs389 SRCS390 mbstowcs.cpp391 HDRS392 mbstowcs.h393 DEPENDS394 libc.hdr.types.size_t395 libc.hdr.types.wchar_t396 libc.src.__support.common397 libc.src.__support.macros.config398 libc.src.__support.macros.null_check399 libc.src.__support.libc_errno400 libc.src.__support.wchar.mbstate401 libc.src.__support.wchar.mbsnrtowcs402)403 404add_entrypoint_object(405 wctomb406 SRCS407 wctomb.cpp408 HDRS409 wctomb.h410 DEPENDS411 libc.hdr.types.wchar_t412 libc.src.__support.wchar.wcrtomb413 libc.src.__support.wchar.mbstate414 libc.src.__support.libc_errno415)416 417add_entrypoint_object(418 wcstombs419 SRCS420 wcstombs.cpp421 HDRS422 wcstombs.h423 DEPENDS424 libc.hdr.types.wchar_t425 libc.src.__support.wchar.mbstate426 libc.src.__support.wchar.wcsnrtombs427 libc.src.__support.libc_errno428)429 430if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)431 if(LLVM_LIBC_INCLUDE_SCUDO)432 set(SCUDO_DEPS "")433 434 include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)435 436 # scudo distinguishes riscv32 and riscv64, so we need to translate the architecture437 # set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})438 if (LIBC_TARGET_OS_IS_DARWIN AND (LIBC_TARGET_ARCHITECTURE STREQUAL "arm"))439 set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO arm64)440 else()441 set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})442 endif()443 if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)444 set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)445 elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)446 set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)447 endif()448 449 if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))450 message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.451 Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")452 endif()453 454 list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}455 RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})456 457 if (COMPILER_RT_BUILD_GWP_ASAN)458 list(APPEND SCUDO_DEPS459 RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}460 RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}461 RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}462 )463 endif()464 465 add_entrypoint_external(466 malloc467 DEPENDS468 ${SCUDO_DEPS}469 )470 add_entrypoint_external(471 calloc472 DEPENDS473 ${SCUDO_DEPS}474 )475 add_entrypoint_external(476 realloc477 DEPENDS478 ${SCUDO_DEPS}479 )480 add_entrypoint_external(481 aligned_alloc482 DEPENDS483 ${SCUDO_DEPS}484 )485 add_entrypoint_external(486 free487 DEPENDS488 ${SCUDO_DEPS}489 )490 add_entrypoint_external(491 mallopt492 DEPENDS493 ${SCUDO_DEPS}494 )495 else()496 add_entrypoint_external(497 malloc498 )499 add_entrypoint_external(500 calloc501 )502 add_entrypoint_external(503 realloc504 )505 add_entrypoint_external(506 aligned_alloc507 )508 add_entrypoint_external(509 free510 )511 add_entrypoint_external(512 mallopt513 )514 endif()515endif()516 517if(NOT LLVM_LIBC_FULL_BUILD)518 return()519endif()520 521add_entrypoint_object(522 strtof_l523 SRCS524 strtof_l.cpp525 HDRS526 strtof_l.h527 DEPENDS528 libc.src.errno.errno529 libc.src.__support.str_to_float530)531 532add_entrypoint_object(533 strtod_l534 SRCS535 strtod_l.cpp536 HDRS537 strtod_l.h538 DEPENDS539 libc.src.errno.errno540 libc.src.__support.str_to_float541)542 543add_entrypoint_object(544 strtold_l545 SRCS546 strtold_l.cpp547 HDRS548 strtold_l.h549 DEPENDS550 libc.src.errno.errno551 libc.src.__support.str_to_float552)553 554add_entrypoint_object(555 strtol_l556 SRCS557 strtol_l.cpp558 HDRS559 strtol_l.h560 DEPENDS561 libc.src.errno.errno562 libc.src.__support.str_to_integer563)564 565add_entrypoint_object(566 strtoll_l567 SRCS568 strtoll_l.cpp569 HDRS570 strtoll_l.h571 DEPENDS572 libc.src.errno.errno573 libc.src.__support.str_to_integer574)575 576add_entrypoint_object(577 strtoul_l578 SRCS579 strtoul_l.cpp580 HDRS581 strtoul_l.h582 DEPENDS583 libc.src.errno.errno584 libc.src.__support.str_to_integer585)586 587add_entrypoint_object(588 strtoull_l589 SRCS590 strtoull_l.cpp591 HDRS592 strtoull_l.h593 DEPENDS594 libc.src.errno.errno595 libc.src.__support.str_to_integer596)597 598if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})599 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})600endif()601 602if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU)603 add_entrypoint_object(604 malloc605 ALIAS606 DEPENDS607 .${LIBC_TARGET_OS}.malloc608 )609 add_entrypoint_object(610 free611 ALIAS612 DEPENDS613 .${LIBC_TARGET_OS}.free614 )615 add_entrypoint_object(616 realloc617 ALIAS618 DEPENDS619 .${LIBC_TARGET_OS}.realloc620 )621 add_entrypoint_object(622 calloc623 ALIAS624 DEPENDS625 .${LIBC_TARGET_OS}.calloc626 )627 add_entrypoint_object(628 aligned_alloc629 ALIAS630 DEPENDS631 .${LIBC_TARGET_OS}.aligned_alloc632 )633endif()634 635add_entrypoint_object(636 _Exit637 SRCS638 _Exit.cpp639 HDRS640 _Exit.h641 DEPENDS642 libc.include.stdlib643 libc.src.__support.OSUtil.osutil644)645 646# TODO: Move all exit functions to linux specific647 648if(TARGET libc.src.__support.threads.mutex)649add_header_library(650 exit_handler651 HDRS652 exit_handler.h653 DEPENDS654 libc.src.__support.CPP.mutex655 libc.src.__support.CPP.new656 libc.src.__support.OSUtil.osutil657 libc.src.__support.blockstore658 libc.src.__support.fixedvector659 libc.src.__support.threads.mutex660)661endif()662 663add_entrypoint_object(664 atexit665 SRCS666 atexit.cpp667 HDRS668 atexit.h669 CXX_STANDARD670 20 # For constinit671 DEPENDS672 .exit_handler673)674 675add_entrypoint_object(676 at_quick_exit677 SRCS678 at_quick_exit.cpp679 HDRS680 at_quick_exit.h681 CXX_STANDARD682 20 # For constinit683 DEPENDS684 .exit_handler685 .atexit686)687 688list(APPEND exit_deps689 libc.src.__support.OSUtil.osutil690 ._Exit691)692if (NOT LIBC_TARGET_OS_IS_BAREMETAL)693 list(APPEND exit_deps694 .atexit695 )696endif()697 698add_entrypoint_object(699 exit700 SRCS701 exit.cpp702 HDRS703 exit.h704 DEPENDS705 ${exit_deps}706)707 708add_entrypoint_object(709 abort710 ALIAS711 DEPENDS712 .${LIBC_TARGET_OS}.abort713)714 715add_entrypoint_object(716 system717 ALIAS718 DEPENDS719 .${LIBC_TARGET_OS}.system720)721