1add_entrypoint_object( 2 atoi 3 SRCS 4 atoi.cpp 5 HDRS 6 atoi.h 7 DEPENDS 8 libc.src.errno.errno 9 libc.src.__support.str_to_integer 10) 11 12add_entrypoint_object( 13 atof 14 SRCS 15 atof.cpp 16 HDRS 17 atof.h 18 DEPENDS 19 libc.src.errno.errno 20 libc.src.__support.str_to_float 21) 22 23add_entrypoint_object( 24 atol 25 SRCS 26 atol.cpp 27 HDRS 28 atol.h 29 DEPENDS 30 libc.src.errno.errno 31 libc.src.__support.str_to_integer 32) 33 34add_entrypoint_object( 35 atoll 36 SRCS 37 atoll.cpp 38 HDRS 39 atoll.h 40 DEPENDS 41 libc.src.errno.errno 42 libc.src.__support.str_to_integer 43) 44 45add_entrypoint_object( 46 quick_exit 47 SRCS 48 quick_exit.cpp 49 HDRS 50 quick_exit.h 51 DEPENDS 52 libc.src.__support.OSUtil.osutil 53 .exit_handler 54 .at_quick_exit 55 .atexit 56) 57 58add_entrypoint_object( 59 getenv 60 SRCS 61 getenv.cpp 62 HDRS 63 getenv.h 64 DEPENDS 65 libc.config.app_h 66) 67 68add_entrypoint_object( 69 strfromf 70 SRCS 71 strfromf.cpp 72 HDRS 73 strfromf.h 74 DEPENDS 75 .str_from_util 76) 77 78add_entrypoint_object( 79 strfromd 80 SRCS 81 strfromd.cpp 82 HDRS 83 strfromd.h 84 DEPENDS 85 .str_from_util 86) 87 88add_entrypoint_object( 89 strfroml 90 SRCS 91 strfroml.cpp 92 HDRS 93 strfroml.h 94 DEPENDS 95 .str_from_util 96) 97 98add_header_library( 99 str_from_util 100 HDRS 101 str_from_util.h 102 DEPENDS 103 libc.src.stdio.printf_core.converter 104 libc.src.stdio.printf_core.core_structs 105 libc.src.stdio.printf_core.writer 106 libc.src.__support.str_to_integer 107 libc.src.__support.CPP.type_traits 108) 109 110add_entrypoint_object( 111 strtof 112 SRCS 113 strtof.cpp 114 HDRS 115 strtof.h 116 DEPENDS 117 libc.src.errno.errno 118 libc.src.__support.str_to_float 119) 120 121add_entrypoint_object( 122 strtod 123 SRCS 124 strtod.cpp 125 HDRS 126 strtod.h 127 DEPENDS 128 libc.src.errno.errno 129 libc.src.__support.str_to_float 130) 131 132add_entrypoint_object( 133 strtold 134 SRCS 135 strtold.cpp 136 HDRS 137 strtold.h 138 DEPENDS 139 libc.src.errno.errno 140 libc.src.__support.str_to_float 141) 142 143add_entrypoint_object( 144 strtol 145 SRCS 146 strtol.cpp 147 HDRS 148 strtol.h 149 DEPENDS 150 libc.src.errno.errno 151 libc.src.__support.str_to_integer 152) 153 154add_entrypoint_object( 155 strtoll 156 SRCS 157 strtoll.cpp 158 HDRS 159 strtoll.h 160 DEPENDS 161 libc.src.errno.errno 162 libc.src.__support.str_to_integer 163) 164 165add_entrypoint_object( 166 strtoul 167 SRCS 168 strtoul.cpp 169 HDRS 170 strtoul.h 171 DEPENDS 172 libc.src.errno.errno 173 libc.src.__support.str_to_integer 174) 175 176add_entrypoint_object( 177 strtoull 178 SRCS 179 strtoull.cpp 180 HDRS 181 strtoull.h 182 DEPENDS 183 libc.src.errno.errno 184 libc.src.__support.str_to_integer 185) 186 187add_entrypoint_object( 188 abs 189 SRCS 190 abs.cpp 191 HDRS 192 abs.h 193 DEPENDS 194 libc.src.__support.integer_operations 195) 196 197add_entrypoint_object( 198 labs 199 SRCS 200 labs.cpp 201 HDRS 202 labs.h 203 DEPENDS 204 libc.src.__support.integer_operations 205) 206 207add_entrypoint_object( 208 llabs 209 SRCS 210 llabs.cpp 211 HDRS 212 llabs.h 213 DEPENDS 214 libc.src.__support.integer_operations 215) 216 217add_entrypoint_object( 218 div 219 SRCS 220 div.cpp 221 HDRS 222 div.h 223 DEPENDS 224 libc.hdr.types.div_t 225 libc.src.__support.integer_operations 226) 227 228add_entrypoint_object( 229 ldiv 230 SRCS 231 ldiv.cpp 232 HDRS 233 ldiv.h 234 DEPENDS 235 libc.hdr.types.ldiv_t 236 libc.src.__support.integer_operations 237) 238 239add_entrypoint_object( 240 lldiv 241 SRCS 242 lldiv.cpp 243 HDRS 244 lldiv.h 245 DEPENDS 246 libc.hdr.types.lldiv_t 247 libc.src.__support.integer_operations 248) 249 250add_entrypoint_object( 251 bsearch 252 SRCS 253 bsearch.cpp 254 HDRS 255 bsearch.h 256 DEPENDS 257 libc.include.stdlib 258) 259 260add_header_library( 261 qsort_util 262 HDRS 263 qsort_data.h 264 qsort_util.h 265 heap_sort.h 266 quick_sort.h 267 DEPENDS 268 libc.include.stdlib 269 libc.src.__support.CPP.cstddef 270) 271 272add_entrypoint_object( 273 qsort 274 SRCS 275 qsort.cpp 276 HDRS 277 qsort.h 278 DEPENDS 279 .qsort_util 280 libc.hdr.types.size_t 281) 282 283add_entrypoint_object( 284 qsort_r 285 SRCS 286 qsort_r.cpp 287 HDRS 288 qsort_r.h 289 DEPENDS 290 .qsort_util 291 libc.hdr.types.size_t 292) 293 294add_object_library( 295 rand_util 296 SRCS 297 rand_util.cpp 298 HDRS 299 rand_util.h 300 DEPENDS 301 libc.src.__support.common 302) 303 304add_entrypoint_object( 305 rand 306 SRCS 307 rand.cpp 308 HDRS 309 rand.h 310 DEPENDS 311 .rand_util 312 libc.hdr.stdlib_macros 313 libc.src.__support.threads.sleep 314) 315 316add_entrypoint_object( 317 srand 318 SRCS 319 srand.cpp 320 HDRS 321 srand.h 322 DEPENDS 323 .rand_util 324) 325 326if(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 ) 391 else() 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 ) 410 endif() 411endif() 412 413if(NOT LLVM_LIBC_FULL_BUILD) 414 return() 415endif() 416 417add_entrypoint_object( 418 strtof_l 419 SRCS 420 strtof_l.cpp 421 HDRS 422 strtof_l.h 423 DEPENDS 424 libc.src.errno.errno 425 libc.src.__support.str_to_float 426) 427 428add_entrypoint_object( 429 strtod_l 430 SRCS 431 strtod_l.cpp 432 HDRS 433 strtod_l.h 434 DEPENDS 435 libc.src.errno.errno 436 libc.src.__support.str_to_float 437) 438 439add_entrypoint_object( 440 strtold_l 441 SRCS 442 strtold_l.cpp 443 HDRS 444 strtold_l.h 445 DEPENDS 446 libc.src.errno.errno 447 libc.src.__support.str_to_float 448) 449 450add_entrypoint_object( 451 strtol_l 452 SRCS 453 strtol_l.cpp 454 HDRS 455 strtol_l.h 456 DEPENDS 457 libc.src.errno.errno 458 libc.src.__support.str_to_integer 459) 460 461add_entrypoint_object( 462 strtoll_l 463 SRCS 464 strtoll_l.cpp 465 HDRS 466 strtoll_l.h 467 DEPENDS 468 libc.src.errno.errno 469 libc.src.__support.str_to_integer 470) 471 472add_entrypoint_object( 473 strtoul_l 474 SRCS 475 strtoul_l.cpp 476 HDRS 477 strtoul_l.h 478 DEPENDS 479 libc.src.errno.errno 480 libc.src.__support.str_to_integer 481) 482 483add_entrypoint_object( 484 strtoull_l 485 SRCS 486 strtoull_l.cpp 487 HDRS 488 strtoull_l.h 489 DEPENDS 490 libc.src.errno.errno 491 libc.src.__support.str_to_integer 492) 493 494if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) 495 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) 496endif() 497 498if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU) 499 add_entrypoint_object( 500 malloc 501 ALIAS 502 DEPENDS 503 .${LIBC_TARGET_OS}.malloc 504 ) 505 add_entrypoint_object( 506 free 507 ALIAS 508 DEPENDS 509 .${LIBC_TARGET_OS}.free 510 ) 511 add_entrypoint_object( 512 realloc 513 ALIAS 514 DEPENDS 515 .${LIBC_TARGET_OS}.realloc 516 ) 517 add_entrypoint_object( 518 calloc 519 ALIAS 520 DEPENDS 521 .${LIBC_TARGET_OS}.calloc 522 ) 523 add_entrypoint_object( 524 aligned_alloc 525 ALIAS 526 DEPENDS 527 .${LIBC_TARGET_OS}.aligned_alloc 528 ) 529endif() 530 531add_entrypoint_object( 532 _Exit 533 SRCS 534 _Exit.cpp 535 HDRS 536 _Exit.h 537 DEPENDS 538 libc.include.stdlib 539 libc.src.__support.OSUtil.osutil 540) 541 542# TODO: Move all exit functions to linux specific 543 544if(TARGET libc.src.__support.threads.mutex) 545add_header_library( 546 exit_handler 547 HDRS 548 exit_handler.h 549 DEPENDS 550 libc.src.__support.CPP.mutex 551 libc.src.__support.CPP.new 552 libc.src.__support.OSUtil.osutil 553 libc.src.__support.blockstore 554 libc.src.__support.fixedvector 555 libc.src.__support.threads.mutex 556) 557endif() 558 559add_entrypoint_object( 560 atexit 561 SRCS 562 atexit.cpp 563 HDRS 564 atexit.h 565 CXX_STANDARD 566 20 # For constinit 567 DEPENDS 568 .exit_handler 569) 570 571add_entrypoint_object( 572 at_quick_exit 573 SRCS 574 at_quick_exit.cpp 575 HDRS 576 at_quick_exit.h 577 CXX_STANDARD 578 20 # For constinit 579 DEPENDS 580 .exit_handler 581 .atexit 582) 583 584list(APPEND exit_deps 585 libc.src.__support.OSUtil.osutil 586 ._Exit 587) 588if (NOT LIBC_TARGET_OS_IS_BAREMETAL) 589 list(APPEND exit_deps 590 .atexit 591 ) 592endif() 593 594add_entrypoint_object( 595 exit 596 SRCS 597 exit.cpp 598 HDRS 599 exit.h 600 DEPENDS 601 ${exit_deps} 602) 603 604add_entrypoint_object( 605 abort 606 ALIAS 607 DEPENDS 608 .${LIBC_TARGET_OS}.abort 609) 610 611add_entrypoint_object( 612 system 613 ALIAS 614 DEPENDS 615 .${LIBC_TARGET_OS}.system 616) 617