blob: aa653c38a8c3f4e940a4d1bad6049de0e908a774 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
|
add_entrypoint_object(
atoi
SRCS
atoi.cpp
HDRS
atoi.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
atof
SRCS
atof.cpp
HDRS
atof.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
atol
SRCS
atol.cpp
HDRS
atol.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
atoll
SRCS
atoll.cpp
HDRS
atoll.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
quick_exit
SRCS
quick_exit.cpp
HDRS
quick_exit.h
DEPENDS
libc.src.__support.OSUtil.osutil
.exit_handler
.at_quick_exit
.atexit
)
add_entrypoint_object(
getenv
SRCS
getenv.cpp
HDRS
getenv.h
DEPENDS
libc.config.app_h
)
add_entrypoint_object(
strfromf
SRCS
strfromf.cpp
HDRS
strfromf.h
DEPENDS
.str_from_util
)
add_entrypoint_object(
strfromd
SRCS
strfromd.cpp
HDRS
strfromd.h
DEPENDS
.str_from_util
)
add_entrypoint_object(
strfroml
SRCS
strfroml.cpp
HDRS
strfroml.h
DEPENDS
.str_from_util
)
add_header_library(
str_from_util
HDRS
str_from_util.h
DEPENDS
libc.src.stdio.printf_core.converter
libc.src.stdio.printf_core.core_structs
libc.src.stdio.printf_core.writer
libc.src.__support.str_to_integer
libc.src.__support.CPP.type_traits
)
add_entrypoint_object(
strtof
SRCS
strtof.cpp
HDRS
strtof.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
strtod
SRCS
strtod.cpp
HDRS
strtod.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
strtold
SRCS
strtold.cpp
HDRS
strtold.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
strtol
SRCS
strtol.cpp
HDRS
strtol.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
strtoll
SRCS
strtoll.cpp
HDRS
strtoll.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
strtoul
SRCS
strtoul.cpp
HDRS
strtoul.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
strtoull
SRCS
strtoull.cpp
HDRS
strtoull.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
a64l
SRCS
a64l.cpp
HDRS
a64l.h
DEPENDS
libc.hdr.stdint_proxy
libc.hdr.types.size_t
libc.src.__support.ctype_utils
)
add_entrypoint_object(
l64a
SRCS
l64a.cpp
HDRS
l64a.h
DEPENDS
libc.hdr.stdint_proxy
libc.hdr.types.size_t
libc.src.__support.ctype_utils
)
add_entrypoint_object(
abs
SRCS
abs.cpp
HDRS
abs.h
DEPENDS
libc.src.__support.integer_operations
)
add_entrypoint_object(
labs
SRCS
labs.cpp
HDRS
labs.h
DEPENDS
libc.src.__support.integer_operations
)
add_entrypoint_object(
llabs
SRCS
llabs.cpp
HDRS
llabs.h
DEPENDS
libc.src.__support.integer_operations
)
add_entrypoint_object(
div
SRCS
div.cpp
HDRS
div.h
DEPENDS
libc.hdr.types.div_t
libc.src.__support.integer_operations
)
add_entrypoint_object(
ldiv
SRCS
ldiv.cpp
HDRS
ldiv.h
DEPENDS
libc.hdr.types.ldiv_t
libc.src.__support.integer_operations
)
add_entrypoint_object(
lldiv
SRCS
lldiv.cpp
HDRS
lldiv.h
DEPENDS
libc.hdr.types.lldiv_t
libc.src.__support.integer_operations
)
add_entrypoint_object(
bsearch
SRCS
bsearch.cpp
HDRS
bsearch.h
DEPENDS
libc.include.stdlib
)
add_header_library(
qsort_util
HDRS
qsort_data.h
qsort_util.h
heap_sort.h
quick_sort.h
DEPENDS
libc.hdr.stdint_proxy
libc.include.stdlib
libc.src.__support.CPP.cstddef
)
add_entrypoint_object(
qsort
SRCS
qsort.cpp
HDRS
qsort.h
DEPENDS
.qsort_util
libc.hdr.stdint_proxy
libc.hdr.types.size_t
)
add_entrypoint_object(
qsort_r
SRCS
qsort_r.cpp
HDRS
qsort_r.h
DEPENDS
.qsort_util
libc.hdr.stdint_proxy
libc.hdr.types.size_t
)
add_object_library(
rand_util
SRCS
rand_util.cpp
HDRS
rand_util.h
DEPENDS
libc.src.__support.common
)
add_entrypoint_object(
rand
SRCS
rand.cpp
HDRS
rand.h
DEPENDS
.rand_util
libc.hdr.stdlib_macros
libc.src.__support.threads.sleep
)
add_entrypoint_object(
srand
SRCS
srand.cpp
HDRS
srand.h
DEPENDS
.rand_util
)
add_entrypoint_object(
memalignment
SRCS
memalignment.cpp
HDRS
memalignment.h
DEPENDS
libc.src.__support.common
libc.hdr.types.size_t
)
if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
if(LLVM_LIBC_INCLUDE_SCUDO)
set(SCUDO_DEPS "")
include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
# set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
if (LIBC_TARGET_OS_IS_DARWIN AND (LIBC_TARGET_ARCHITECTURE STREQUAL "arm"))
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO arm64)
else()
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
endif()
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
endif()
if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
endif()
list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
if (COMPILER_RT_BUILD_GWP_ASAN)
list(APPEND SCUDO_DEPS
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
)
endif()
add_entrypoint_external(
malloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
calloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
realloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
aligned_alloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
free
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
mallopt
DEPENDS
${SCUDO_DEPS}
)
else()
add_entrypoint_external(
malloc
)
add_entrypoint_external(
calloc
)
add_entrypoint_external(
realloc
)
add_entrypoint_external(
aligned_alloc
)
add_entrypoint_external(
free
)
add_entrypoint_external(
mallopt
)
endif()
endif()
if(NOT LLVM_LIBC_FULL_BUILD)
return()
endif()
add_entrypoint_object(
strtof_l
SRCS
strtof_l.cpp
HDRS
strtof_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
strtod_l
SRCS
strtod_l.cpp
HDRS
strtod_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
strtold_l
SRCS
strtold_l.cpp
HDRS
strtold_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_float
)
add_entrypoint_object(
strtol_l
SRCS
strtol_l.cpp
HDRS
strtol_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
strtoll_l
SRCS
strtoll_l.cpp
HDRS
strtoll_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
strtoul_l
SRCS
strtoul_l.cpp
HDRS
strtoul_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
add_entrypoint_object(
strtoull_l
SRCS
strtoull_l.cpp
HDRS
strtoull_l.h
DEPENDS
libc.src.errno.errno
libc.src.__support.str_to_integer
)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()
if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU)
add_entrypoint_object(
malloc
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.malloc
)
add_entrypoint_object(
free
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.free
)
add_entrypoint_object(
realloc
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.realloc
)
add_entrypoint_object(
calloc
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.calloc
)
add_entrypoint_object(
aligned_alloc
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.aligned_alloc
)
endif()
add_entrypoint_object(
_Exit
SRCS
_Exit.cpp
HDRS
_Exit.h
DEPENDS
libc.include.stdlib
libc.src.__support.OSUtil.osutil
)
# TODO: Move all exit functions to linux specific
if(TARGET libc.src.__support.threads.mutex)
add_header_library(
exit_handler
HDRS
exit_handler.h
DEPENDS
libc.src.__support.CPP.mutex
libc.src.__support.CPP.new
libc.src.__support.OSUtil.osutil
libc.src.__support.blockstore
libc.src.__support.fixedvector
libc.src.__support.threads.mutex
)
endif()
add_entrypoint_object(
atexit
SRCS
atexit.cpp
HDRS
atexit.h
CXX_STANDARD
20 # For constinit
DEPENDS
.exit_handler
)
add_entrypoint_object(
at_quick_exit
SRCS
at_quick_exit.cpp
HDRS
at_quick_exit.h
CXX_STANDARD
20 # For constinit
DEPENDS
.exit_handler
.atexit
)
list(APPEND exit_deps
libc.src.__support.OSUtil.osutil
._Exit
)
if (NOT LIBC_TARGET_OS_IS_BAREMETAL)
list(APPEND exit_deps
.atexit
)
endif()
add_entrypoint_object(
exit
SRCS
exit.cpp
HDRS
exit.h
DEPENDS
${exit_deps}
)
add_entrypoint_object(
abort
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.abort
)
add_entrypoint_object(
system
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.system
)
|