blob: 19c46fef380f6fa424101e92a4b1e2b3a5fc30e6 [file] [log] [blame]
Colin Cross22a72b02021-06-03 16:59:57 -07001// Build musl libc from source to eventually use as the libc for host modules in the platform build.
2// The list of sources to compile for each library is loaded from sources.bp, which is generated
3// by generate_bp.py.
4
5package {
6 default_visibility: ["//visibility:private"],
7 default_applicable_licenses: ["musl_license"],
8}
9
10license {
11 name: "musl_license",
12 visibility: [":__subpackages__"],
13 license_kinds: [
14 "SPDX-license-identifier-MIT",
15 "SPDX-license-identifier-BSD",
16 ],
17 license_text: ["COPYRIGHT"],
18}
19
20cc_library_headers {
21 name: "libc_musl_arch_headers",
22 host_supported: true,
23 device_supported: false,
24 system_shared_libs: [],
25 generated_headers: [
26 "libc_musl_alltypes.h",
27 "libc_musl_syscall.h",
28 ],
29 export_generated_headers: [
30 "libc_musl_alltypes.h",
31 "libc_musl_syscall.h",
32 ],
33 export_include_dirs: [
34 "arch/generic",
35 ],
36 arch: {
37 arm: {
38 export_include_dirs: ["arch/arm"],
39 },
40 arm64: {
41 export_include_dirs: ["arch/aarch64"],
42 },
43 x86: {
44 export_include_dirs: ["arch/i386"],
45 },
46 x86_64: {
47 export_include_dirs: ["arch/x86_64"],
48 },
49 },
50}
51
52cc_library_headers {
53 name: "libc_musl_private_headers",
54 host_supported: true,
55 device_supported: false,
56 system_shared_libs: [],
57 generated_headers: [
58 "libc_musl_version.h",
59 ],
60 export_generated_headers: [
61 "libc_musl_version.h",
62 ],
63 export_include_dirs: [
64 "src/include",
65 "src/internal",
66 ],
67}
68
69cc_library_headers {
70 name: "libc_musl_public_headers",
71 host_supported: true,
72 device_supported: false,
73 system_shared_libs: [],
74 export_system_include_dirs: [
Colin Cross195a9b32021-06-29 11:10:42 -070075 "android/include",
Colin Cross22a72b02021-06-03 16:59:57 -070076 "include",
77 ],
78}
79
80cc_defaults {
81 name: "libc_musl_defaults",
82 host_supported: true,
83 device_supported: false,
84 system_shared_libs: [],
85 cflags: [
86 // CFLAGS_C99FSE
87 "-nostdinc",
88 "-ffreestanding",
89 "-frounding-math",
90 "-Wa,--noexecstack",
91
92 // CFLAGS_AUTO
93 //"-Os",
94 "-O0",
95 "-pipe",
96 "-fomit-frame-pointer",
97 "-fno-unwind-tables",
98 "-fno-asynchronous-unwind-tables",
99 "-ffunction-sections",
100 "-fdata-sections",
101 //"-w",
102 "-Wno-pointer-to-int-cast",
103 "-Werror=implicit-function-declaration",
104 "-Werror=implicit-int",
105 "-Werror=pointer-sign",
106 "-Werror=pointer-arith",
107 "-Werror=int-conversion",
108 "-Werror=incompatible-pointer-types",
109 "-Qunused-arguments",
110 "-Waddress",
111 "-Warray-bounds",
112 "-Wchar-subscripts",
113 "-Wduplicate-decl-specifier",
114 "-Winit-self",
115 "-Wreturn-type",
116 "-Wsequence-point",
117 "-Wstrict-aliasing",
118 "-Wunused-function",
119 "-Wunused-label",
120 "-Wunused-variable",
121
122 // CFLAGS_ALL
123 "-D_XOPEN_SOURCE=700",
124
125 // undefine NDEBUG from global flags, musl defines it locally
126 "-UNDEBUG",
127
128 // disable warnings:
129 "-Wno-bitwise-op-parentheses",
130 "-Wno-dangling-else",
131 "-Wno-ignored-attributes",
132 "-Wno-logical-op-parentheses",
133 "-Wno-missing-braces",
134 "-Wno-missing-field-initializers",
135 "-Wno-parentheses",
136 "-Wno-shift-op-parentheses",
137 "-Wno-string-plus-int",
138 "-Wno-unused-parameter",
139 ],
140
141 ldflags: [
142 "-Wl,--sort-section,alignment",
143 "-Wl,--sort-common",
144 "-Wl,--gc-sections",
145 "-Wl,--hash-style=both",
146 "-Wl,--no-undefined",
147 // Can't use --exclude-libs=ALL, that excludes the static libraries
148 // used for building subparts of libc_musl.
149 //"-Wl,--exclude-libs=ALL",
150 "-Wl,--exclude-libs=libgcc.a",
151 "-Wl,--exclude-libs=libgcc_stripped.a",
152 "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
153 "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
154 "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a",
155 "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
156 ],
157
Colin Cross827123b2022-01-21 22:46:11 -0800158 asflags: ["-Wno-unused-command-line-argument"],
159
Colin Cross22a72b02021-06-03 16:59:57 -0700160 header_libs: [
161 // The order here is very important, private headers like src/include/features.h override
162 // public headers like include/features.h, and arch headers like arch/x86_64/ksigaction.h
163 // override private headers like src/internal/ksigaction.h.
164 "libc_musl_arch_headers",
165 "libc_musl_private_headers",
166 "libc_musl_public_headers",
167 ],
168
169 stl: "none",
170 c_std: "c99",
171 sanitize: {
172 never: true,
173 },
Colin Crossd5653712021-08-10 19:47:33 -0700174 target: {
175 darwin: {
176 enabled: false,
177 },
Colin Cross47fbb292021-10-12 17:32:06 -0700178 bionic: {
179 enabled: false,
180 },
Colin Cross2a1464c2021-12-23 08:51:57 -0800181 glibc: {
182 enabled: false,
183 },
Colin Crossd5653712021-08-10 19:47:33 -0700184 },
Colin Cross22a72b02021-06-03 16:59:57 -0700185}
186
Colin Cross2a1464c2021-12-23 08:51:57 -0800187cc_library_headers {
188 name: "libc_musl_headers",
189 visibility: ["//bionic/libc"],
190 host_supported: true,
191 device_supported: false,
192 system_shared_libs: [],
193 export_header_lib_headers: [
194 "libc_musl_arch_headers",
195 "libc_musl_public_headers",
196 "libc_llndk_headers",
197 ],
198 header_libs: [
199 "libc_musl_arch_headers",
200 "libc_musl_public_headers",
201 "libc_llndk_headers",
202 ],
203}
204
Colin Cross22a72b02021-06-03 16:59:57 -0700205//
206// The main musl libc library
207//
208
209cc_library {
210 name: "libc_musl",
211 visibility: ["//visibility:public"],
Colin Cross0c850682022-01-21 22:47:20 -0800212 defaults: ["libc_musl_defaults"],
213 whole_static_libs: ["libc_musl_static"],
214 shared: {
215 whole_static_libs: ["libc_musl_ldso"],
216 },
217 ldflags: [
218 "-Wl,-e,_dlstart",
219 "-nostdlib",
220 ],
221 dynamic_list: "dynamic.list",
222}
223
224// All the static parts of the main musl libc. Don't use this directly, use
225// the version exported through libc_musl instead.
226cc_library_static {
227 name: "libc_musl_static",
Colin Cross22a72b02021-06-03 16:59:57 -0700228 defaults: [
229 "libc_musl_defaults",
230 "libc_musl_sources",
231 ],
232 whole_static_libs: [
233 "libc_musl_opt",
234 "libc_musl_opt_nossp",
235 "libc_musl_nossp",
Colin Cross2a1464c2021-12-23 08:51:57 -0800236 "libexecinfo",
237 "libb64",
Colin Cross22a72b02021-06-03 16:59:57 -0700238 ],
Colin Cross22a72b02021-06-03 16:59:57 -0700239 multilib: {
240 lib32: {
241 whole_static_libs: ["libc_musl_compat32"],
242 },
243 },
Colin Cross22a72b02021-06-03 16:59:57 -0700244 export_header_lib_headers: [
245 "libc_musl_arch_headers",
246 "libc_musl_public_headers",
247 "libc_llndk_headers",
248 ],
249 header_libs: [
250 "libc_llndk_headers",
251 ],
252}
253
254// Musl sources that are compiled with -O3
255cc_library_static {
256 name: "libc_musl_opt",
257 defaults: [
258 "libc_musl_defaults",
259 "libc_musl_opt_sources",
260 ],
261 cflags: ["-O3"],
262}
263
264// Musl sources that are compiled with -O3 and -fno-stack-protector
265cc_library_static {
266 name: "libc_musl_opt_nossp",
267 defaults: [
268 "libc_musl_defaults",
269 "libc_musl_opt_nossp_sources",
270 ],
271 cflags: [
272 "-O3",
273 "-fno-stack-protector",
274 ],
275}
276
277// Musl sources that are compiled with -fno-stack-protector
278cc_library_static {
279 name: "libc_musl_nossp",
280 defaults: [
281 "libc_musl_defaults",
282 "libc_musl_nossp_sources",
283 ],
284 cflags: ["-fno-stack-protector"],
285}
286
287// Musl sources for 32-bit architectures
288cc_library_static {
289 name: "libc_musl_compat32",
290 defaults: [
291 "libc_musl_defaults",
292 "libc_musl_compat32_sources",
293 ],
294}
295
296// Musl sources for the dynamic linker.
297cc_library_static {
298 name: "libc_musl_ldso",
299 defaults: [
300 "libc_musl_defaults",
301 "libc_musl_ldso_sources",
302 ],
Colin Cross109b21b2022-01-21 22:42:37 -0800303 cflags: [
304 "-fno-stack-protector",
305 "-DLIBC_SONAME=libc_musl.so",
306 ],
Colin Cross22a72b02021-06-03 16:59:57 -0700307}
308
Colin Cross0c850682022-01-21 22:47:20 -0800309// Musl sources for the dynamic linker when used in the sysroot.
310cc_library_static {
311 name: "libc_musl_ldso_sysroot",
312 defaults: [
313 "libc_musl_defaults",
314 "libc_musl_ldso_sources",
315 ],
316 cflags: [
317 "-fno-stack-protector",
318 "-DLIBC_SONAME=libc.so",
319 ],
320}
321
Colin Cross22a72b02021-06-03 16:59:57 -0700322// An attempt to compile the dynamic linker as a standalone library separate from libc_musl.so.
323// Not used yet.
324cc_library_shared {
325 name: "musl_linker",
326 defaults: [
327 "libc_musl_defaults",
328 ],
329 nocrt: true,
330 static_libs: [
331 "libc_musl_ldso",
332 "libc_musl",
333 ],
334 ldflags: [
335 "-Wl,-e,_dlstart",
336 "-nostdlib",
337 "-Wl,--exclude-libs=libc_musl.a",
338 ],
339}
340
341// Convert the linker (which is actually libc_musl.so) into a .s file for embedding in crtbegin.
342cc_genrule {
343 name: "musl_linker_asm",
344 host_supported: true,
345 device_supported: false,
346 tools: ["extract_linker"],
347 cmd: "$(location) -s $(out) $(in)",
348 srcs: [":libc_musl"],
349 out: ["linker.s"],
Colin Cross47fbb292021-10-12 17:32:06 -0700350 target: {
351 darwin: {
352 enabled: false,
353 },
354 bionic: {
355 enabled: false,
356 },
Colin Cross2a1464c2021-12-23 08:51:57 -0800357 glibc: {
358 enabled: false,
359 },
Colin Cross47fbb292021-10-12 17:32:06 -0700360 },
Colin Cross22a72b02021-06-03 16:59:57 -0700361}
362
363// Convert the linker (which is actually libc_musl.so) into a linker script for embedding in
364// crtbegin.
365cc_genrule {
366 name: "musl_linker_script",
367 visibility: ["//visibility:public"],
368 host_supported: true,
369 device_supported: false,
370 tools: ["extract_linker"],
371 cmd: "$(location) -T $(out) $(in)",
372 srcs: [":libc_musl"],
373 out: ["linker.script"],
Colin Cross47fbb292021-10-12 17:32:06 -0700374 target: {
375 darwin: {
376 enabled: false,
377 },
378 bionic: {
379 enabled: false,
380 },
Colin Cross2a1464c2021-12-23 08:51:57 -0800381 glibc: {
382 enabled: false,
383 },
Colin Cross47fbb292021-10-12 17:32:06 -0700384 },
Colin Cross22a72b02021-06-03 16:59:57 -0700385}
386
387//
388// The musl CRT objects
389//
390
391cc_object {
392 name: "libc_musl_crt1",
393 defaults: [
394 "libc_musl_defaults",
395 "libc_musl_crt1_sources",
396 ],
397}
398
399cc_object {
400 name: "libc_musl_crti",
401 defaults: [
402 "libc_musl_defaults",
403 "libc_musl_crti_sources",
404 ],
405}
406
407cc_object {
408 name: "libc_musl_crtn",
409 defaults: [
410 "libc_musl_defaults",
411 "libc_musl_crtn_sources",
412 ],
413}
414
415cc_object {
416 name: "libc_musl_rcrt1",
417 defaults: [
418 "libc_musl_defaults",
419 "libc_musl_rcrt1_sources",
420 ],
421}
422
423cc_object {
424 name: "libc_musl_Scrt1",
425 defaults: [
426 "libc_musl_defaults",
427 "libc_musl_Scrt1_sources",
428 ],
429}
430
431//
432// The custom CRT objects for use in the platform build.
433// Embeds the linker into crtbegin_dynamic.
434//
435
436cc_object {
437 name: "libc_musl_crtbegin_dynamic",
438 defaults: ["libc_musl_defaults"],
439 visibility: ["//visibility:public"],
440 objs: [
441 "libc_musl_crt1",
442 "libc_musl_crti",
443 "clang_rt.crtbegin",
444 ],
445 srcs: [
446 ":musl_linker_asm",
447 "android/ldso_trampoline.cpp",
448 ],
449 cflags: [
450 // These are required to make sure the C code in ldso_trampoline.c
451 // doesn't have any dependencies on libc.
452 "-fno-stack-protector",
453 "-ftrivial-auto-var-init=uninitialized",
454 ],
455}
456
457cc_object {
458 name: "libc_musl_crtbegin_static",
459 defaults: ["libc_musl_defaults"],
460 visibility: ["//visibility:public"],
461 objs: [
462 "libc_musl_Scrt1",
463 "libc_musl_crti",
464 "clang_rt.crtbegin",
465 ],
466}
467
468cc_object {
469 name: "libc_musl_crtend",
470 defaults: ["libc_musl_defaults"],
471 visibility: ["//visibility:public"],
472 objs: [
473 "clang_rt.crtend",
474 "libc_musl_crtn",
475 ],
476}
477
478cc_object {
479 name: "libc_musl_crtbegin_so",
480 defaults: ["libc_musl_defaults"],
481 visibility: ["//visibility:public"],
482 objs: [
483 "libc_musl_crti",
484 "clang_rt.crtbegin",
485 ],
486}
487
488cc_object {
489 name: "libc_musl_crtend_so",
490 defaults: ["libc_musl_defaults"],
491 visibility: ["//visibility:public"],
492 objs: [
493 "clang_rt.crtend",
494 "libc_musl_crtn",
495 ],
496}
497
498//
499// Tests for the embedded linker trampoline
500//
501
502cc_test_host {
503 name: "libc_musl_ldso_trampoline_test",
504 srcs: ["android/ldso_trampoline_test.cpp"],
505 stl: "libc++",
Colin Crossd5653712021-08-10 19:47:33 -0700506 target: {
507 darwin: {
508 enabled: false,
509 },
510 },
Colin Cross22a72b02021-06-03 16:59:57 -0700511}
512
513//
514// Generated headers
515//
516
517genrule {
518 name: "libc_musl_version.h",
519 srcs: ["VERSION"],
520 out: ["version.h"],
521 cmd: "printf '#define VERSION \"%s\"\n' \"$$(cat $(location VERSION))\" > $(out)",
522}
523
524// libc_musl_arch_alltypes.h is split out of libc_musl_alltypes.h to ensure the arch-specific
525// alltypes.h.in ends up before the generic alltypes.h.in in the output.
526cc_genrule {
527 name: "libc_musl_arch_alltypes.h",
528 host_supported: true,
529 device_supported: false,
530 arch: {
531 arm: {
532 srcs: ["arch/arm/bits/alltypes.h.in"],
533 },
534 arm64: {
535 srcs: ["arch/aarch64/bits/alltypes.h.in"],
536 },
537 x86: {
538 srcs: ["arch/i386/bits/alltypes.h.in"],
539 },
540 x86_64: {
541 srcs: ["arch/x86_64/bits/alltypes.h.in"],
542 },
543 },
544 tool_files: ["tools/mkalltypes.sed"],
545 out: ["bits/alltypes.h"],
546 cmd: "sed -f $(location tools/mkalltypes.sed) $(in) > $(out)",
547}
548
549cc_genrule {
550 name: "libc_musl_alltypes.h",
551 host_supported: true,
552 device_supported: false,
553 srcs: [
554 "include/alltypes.h.in",
555 ":libc_musl_arch_alltypes.h",
556 ],
557 tool_files: ["tools/mkalltypes.sed"],
558 out: ["bits/alltypes.h"],
559 cmd: "( " +
560 "cat $(location :libc_musl_arch_alltypes.h) && " +
561 "sed -f $(location tools/mkalltypes.sed) $(location include/alltypes.h.in) " +
562 ") > $(out)",
563}
564
565cc_genrule {
566 name: "libc_musl_syscall.h",
567 host_supported: true,
568 device_supported: false,
569 arch: {
570 arm: {
571 srcs: ["arch/arm/bits/syscall.h.in"],
572 },
573 arm64: {
574 srcs: ["arch/aarch64/bits/syscall.h.in"],
575 },
576 x86: {
577 srcs: ["arch/i386/bits/syscall.h.in"],
578 },
579 x86_64: {
580 srcs: ["arch/x86_64/bits/syscall.h.in"],
581 },
582 },
583 out: ["bits/syscall.h"],
584 cmd: "cp $(in) $(out) && sed -n -e s/__NR_/SYS_/p < $(in) >> $(out)",
585}
586
Colin Cross0c850682022-01-21 22:47:20 -0800587//
588// Rules to generate a sysroot. This isn't used during the build, but can be convenient to run
589// configure scripts from external projects to generate necessary files to build against musl.
590//
591
592
593// A copy of libc_musl that uses libc.so as its soname for putting in the sysroot.
594cc_library_shared {
595 name: "libc_musl_for_sysroot",
596 defaults: ["libc_musl_defaults"],
597 whole_static_libs: ["libc_musl_static"],
598 shared: {
599 whole_static_libs: ["libc_musl_ldso_sysroot"],
600 },
601 ldflags: [
602 "-Wl,-e,_dlstart",
603 "-nostdlib",
604 "-Wl,--soname,libc.so",
605 ],
606 dynamic_list: "dynamic.list",
607}
608
609// An empty static library that will be copied to libdl.a, etc. in the sysroot.
610// Shouldn't be used by anything else besides the sysroot cc_genrule.
611cc_library_static {
612 name: "libc_musl_sysroot_static_empty",
613 defaults: [
614 "libc_musl_defaults",
615 ],
616}
617
Colin Cross44afa752022-02-10 17:32:43 -0800618// The linker and trampoline compiled as a .o file to use as part of the sysroot
619// crt.
620cc_object {
621 name: "libc_musl_linker_object",
622 defaults: ["libc_musl_defaults"],
623 srcs: [
624 ":musl_linker_asm",
625 "android/ldso_trampoline.cpp",
626 ],
627 cflags: [
628 // These are required to make sure the C code in ldso_trampoline.c
629 // doesn't have any dependencies on libc.
630 "-fno-stack-protector",
631 "-ftrivial-auto-var-init=uninitialized",
632 ],
633}
634
Colin Cross0c850682022-01-21 22:47:20 -0800635// The architecture-specific bits have to be handled separately because the label varies based
636// on architecture, which prevents using $(locations) to find them and requires using $(in)
637// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
638// genrule.
639cc_genrule {
640 name: "libc_musl_sysroot_bits",
641 host_supported: true,
642 device_supported: false,
643 arch: {
644 arm: {
645 srcs: ["arch/arm/bits/*.h"],
646 },
647 arm64: {
648 srcs: ["arch/aarch64/bits/*.h"],
649 },
650 x86: {
651 srcs: ["arch/i386/bits/*.h"],
652 },
653 x86_64: {
654 srcs: ["arch/x86_64/bits/*.h"],
655 },
656 },
657 out: ["libc_musl_sysroot_bits.zip"],
658 tools: ["soong_zip"],
659 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/bits -j -D $$(dirname $${includes[0]})",
660}
661
662genrule {
663 name: "libc_musl_clang_wrapper",
664 srcs: ["tools/musl-clang.in"],
665 out: ["musl-clang"],
666 cmd: "sed -e 's`@CC@`clang`' -e 's`@PREFIX@`$$(dirname \"$$0\")/..`' -e 's`@INCDIR@`$${libc}/include`' -e 's`@LIBDIR@`$${libc}/lib`' $(in) > $(out) && " +
667 "chmod a+x $(out)",
668}
669
670genrule {
671 name: "libc_musl_ld_wrapper",
672 srcs: ["tools/ld.musl-clang.in"],
673 out: ["ld.musl-clang"],
674 cmd: "sed -e 's`@CC@`clang`' -e 's`@LIBDIR@`$$(dirname \"$$0\")/../lib`' -e 's`@LDSO@`$$(dirname \"$$0\")/../lib/ld-musl.so.1`' $(in) > $(out) && " +
675 "chmod a+x $(out)",
676}
677
678cc_genrule {
679 name: "libc_musl_sysroot",
680 host_supported: true,
681 device_supported: false,
682 enabled: false,
683 target: {
684 musl: {
685 enabled: true,
686 },
687 },
688 srcs: [
689 "LICENSE",
690 "COPYRIGHT",
691
692 // Headers
693 "include/**/*.h",
694 "arch/generic/bits/*.h",
Colin Crossc798a682022-02-07 15:20:49 -0800695 "android/include/bits/*.h",
696 "android/include/sys/cdefs.h",
Colin Cross0c850682022-01-21 22:47:20 -0800697 ":libc_musl_syscall.h",
698 ":libc_musl_alltypes.h",
699 ":libc_musl_sysroot_bits",
700
Colin Crossc798a682022-02-07 15:20:49 -0800701 // Bionic kernel uapi headers
702 ":libc_musl_sysroot_bionic_headers",
703
Colin Cross0c850682022-01-21 22:47:20 -0800704 // Libraries
705 ":libc_musl",
706 ":libc_musl_for_sysroot",
707 ":libc_musl_static",
708
709 // Objects
710 ":libc_musl_crti",
711 ":libc_musl_crtn",
712 ":libc_musl_crt1",
713 ":libc_musl_rcrt1",
714 ":libc_musl_Scrt1",
715
Colin Cross44afa752022-02-10 17:32:43 -0800716 // Embedded linker objects and linker scripts
717 ":libc_musl_linker_object",
Colin Cross0c850682022-01-21 22:47:20 -0800718 ":musl_linker_script",
719
720 // Wrapper scripts
721 ":libc_musl_clang_wrapper",
722 ":libc_musl_ld_wrapper",
723
724 // Empty static libraries
725 ":libc_musl_sysroot_static_empty",
726 ],
727 out: ["libc_musl_sysroot.zip"],
728 tools: [
729 "soong_zip",
730 "merge_zips",
731 "zip2zip",
732 ],
733 cmd: "includes=($(locations include/**/*.h)) && " +
734 "bits=($(locations arch/generic/bits/*.h)) && " +
Colin Crossc798a682022-02-07 15:20:49 -0800735 "android_bits=($(locations android/include/bits/*.h)) && " +
Colin Cross44afa752022-02-10 17:32:43 -0800736 "ln -s libc_musl.so $(genDir)/ld-musl.so.1 && " +
737 "echo -e 'GROUP ( Scrt1-real.o libc_musl_linker_object.o )\nINCLUDE linker.script' > $(genDir)/Scrt1.ld && " +
738 "echo -e 'GROUP ( libc_musl.so )' > $(genDir)/libc.so && " +
Colin Cross0c850682022-01-21 22:47:20 -0800739 "$(location soong_zip) -o $(genDir)/sysroot.zip " +
740 " -j " +
741 " -f $(location LICENSE) " +
742 " -f $(location COPYRIGHT) " +
743 // headers
744 " -P include " +
745 " -C $$(dirname $${includes[0]}) " +
746 " -D $$(dirname $${includes[0]}) " +
747 " -P include/bits -j " +
748 " -f $(location :libc_musl_syscall.h) " +
749 " -f $(location :libc_musl_alltypes.h) " +
750 " -D $$(dirname $${bits[0]}) " +
Colin Crossc798a682022-02-07 15:20:49 -0800751 " -D $$(dirname $${android_bits[0]}) " +
752 " -P include/sys -j " +
753 " -f $(location android/include/sys/cdefs.h) " +
Colin Cross0c850682022-01-21 22:47:20 -0800754 // crt objects
755 " -P lib -j " +
756 " -f $(location :libc_musl_crti) " +
757 " -f $(location :libc_musl_crtn) " +
758 " -f $(location :libc_musl_crt1) " +
759 " -f $(location :libc_musl_rcrt1) " +
Colin Cross0c850682022-01-21 22:47:20 -0800760 // embedded linker crt objects
Colin Cross0c850682022-01-21 22:47:20 -0800761 " -f $(location :musl_linker_script) " +
Colin Cross44afa752022-02-10 17:32:43 -0800762 " -f $(location :libc_musl_linker_object) " +
763 // libs
764 " -f $(location :libc_musl) " +
765 " -f $(genDir)/ld-musl.so.1 " +
766 " -f $(genDir)/libc.so " +
Colin Cross0c850682022-01-21 22:47:20 -0800767 // clang wrappers
768 " -P bin -j " +
769 " -f $(location :libc_musl_clang_wrapper) " +
770 " -f $(location :libc_musl_ld_wrapper) " +
771 " && " +
772 // libs in a separate zip so they can be renamed
773 "$(location soong_zip) -o $(genDir)/libs.zip " +
774 " -P lib -j " +
Colin Cross0c850682022-01-21 22:47:20 -0800775 " -f $(location :libc_musl_static) " +
776 " -f $(location :libc_musl_sysroot_static_empty) " +
Colin Cross44afa752022-02-10 17:32:43 -0800777 " -f $(genDir)/Scrt1.ld " +
778 " -f $(location :libc_musl_Scrt1) " +
Colin Cross0c850682022-01-21 22:47:20 -0800779 " && " +
780 "$(location zip2zip) -i $(genDir)/libs.zip -o $(genDir)/libs_renamed.zip " +
781 // rename libs from module names to desired names in sysroot
782 " lib/libc_musl_static.a:lib/libc.a " +
Colin Cross44afa752022-02-10 17:32:43 -0800783 // Swap in linker script for Scrt1.o
784 " lib/Scrt1.o:lib/Scrt1-real.o " +
785 " lib/Scrt1.ld:lib/Scrt1.o " +
Colin Cross0c850682022-01-21 22:47:20 -0800786 // copy empty static libs
787 " lib/libc_musl_sysroot_static_empty.a:lib/libcrypt.a " +
788 " lib/libc_musl_sysroot_static_empty.a:lib/libdl.a " +
789 " lib/libc_musl_sysroot_static_empty.a:lib/libm.a " +
790 " lib/libc_musl_sysroot_static_empty.a:lib/libpthread.a " +
791 " lib/libc_musl_sysroot_static_empty.a:lib/libresolv.a " +
792 " lib/libc_musl_sysroot_static_empty.a:lib/librt.a " +
793 " lib/libc_musl_sysroot_static_empty.a:lib/libutil.a " +
794 " lib/libc_musl_sysroot_static_empty.a:lib/libxnet.a " +
795 " && " +
Colin Crossc798a682022-02-07 15:20:49 -0800796 "$(location merge_zips) -ignore-duplicates $(out) $(location :libc_musl_sysroot_bionic_headers) " +
797 " $(location :libc_musl_sysroot_bits) $(genDir)/sysroot.zip $(genDir)/libs_renamed.zip",
Colin Cross0c850682022-01-21 22:47:20 -0800798}
799
Colin Cross22a72b02021-06-03 16:59:57 -0700800build=["sources.bp"]