• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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: [
75        "android/include",
76        "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
158    asflags: ["-Wno-unused-command-line-argument"],
159
160    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    },
174    target: {
175        darwin: {
176            enabled: false,
177        },
178        bionic: {
179            enabled: false,
180        },
181        glibc: {
182            enabled: false,
183        },
184    },
185}
186
187cc_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
205//
206// The main musl libc library
207//
208
209cc_library {
210    name: "libc_musl",
211    visibility: ["//visibility:public"],
212    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",
228    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",
236        "libexecinfo",
237        "libb64",
238        "libunwind",
239    ],
240    multilib: {
241        lib32: {
242            whole_static_libs: ["libc_musl_compat32"],
243        },
244    },
245    export_header_lib_headers: [
246        "libc_musl_arch_headers",
247        "libc_musl_public_headers",
248        "libc_llndk_headers",
249    ],
250    header_libs: [
251        "libc_llndk_headers",
252    ],
253}
254
255// Musl sources that are compiled with -O3
256cc_library_static {
257    name: "libc_musl_opt",
258    defaults: [
259        "libc_musl_defaults",
260        "libc_musl_opt_sources",
261    ],
262    cflags: ["-O3"],
263}
264
265// Musl sources that are compiled with -O3 and -fno-stack-protector
266cc_library_static {
267    name: "libc_musl_opt_nossp",
268    defaults: [
269        "libc_musl_defaults",
270        "libc_musl_opt_nossp_sources",
271    ],
272    cflags: [
273        "-O3",
274        "-fno-stack-protector",
275    ],
276}
277
278// Musl sources that are compiled with -fno-stack-protector
279cc_library_static {
280    name: "libc_musl_nossp",
281    defaults: [
282        "libc_musl_defaults",
283        "libc_musl_nossp_sources",
284    ],
285    cflags: ["-fno-stack-protector"],
286}
287
288// Musl sources for 32-bit architectures
289cc_library_static {
290    name: "libc_musl_compat32",
291    defaults: [
292        "libc_musl_defaults",
293        "libc_musl_compat32_sources",
294    ],
295}
296
297// Musl sources for the dynamic linker.
298cc_library_static {
299    name: "libc_musl_ldso",
300    defaults: [
301        "libc_musl_defaults",
302        "libc_musl_ldso_sources",
303    ],
304    cflags: [
305        "-fno-stack-protector",
306        "-DLIBC_SONAME=libc_musl.so",
307    ],
308}
309
310// Musl sources for the dynamic linker when used in the sysroot.
311cc_library_static {
312    name: "libc_musl_ldso_sysroot",
313    defaults: [
314        "libc_musl_defaults",
315        "libc_musl_ldso_sources",
316    ],
317    cflags: [
318        "-fno-stack-protector",
319        "-DLIBC_SONAME=libc.so",
320    ],
321}
322
323// An attempt to compile the dynamic linker as a standalone library separate from libc_musl.so.
324// Not used yet.
325cc_library_shared {
326    name: "musl_linker",
327    defaults: [
328        "libc_musl_defaults",
329    ],
330    nocrt: true,
331    static_libs: [
332        "libc_musl_ldso",
333        "libc_musl",
334    ],
335    ldflags: [
336        "-Wl,-e,_dlstart",
337        "-nostdlib",
338        "-Wl,--exclude-libs=libc_musl.a",
339    ],
340}
341
342// Convert the linker (which is actually libc_musl.so) into a .s file for embedding in crtbegin.
343cc_genrule {
344    name: "musl_linker_asm",
345    host_supported: true,
346    device_supported: false,
347    tools: ["extract_linker"],
348    cmd: "$(location) -s $(out) $(in)",
349    srcs: [":libc_musl"],
350    out: ["linker.s"],
351    target: {
352        darwin: {
353            enabled: false,
354        },
355        bionic: {
356            enabled: false,
357        },
358        glibc: {
359            enabled: false,
360        },
361    },
362}
363
364// Convert the linker (which is actually libc_musl.so) into a linker script for embedding in
365// crtbegin.
366cc_genrule {
367    name: "musl_linker_script",
368    visibility: ["//visibility:public"],
369    host_supported: true,
370    device_supported: false,
371    tools: ["extract_linker"],
372    cmd: "$(location) -T $(out) $(in)",
373    srcs: [":libc_musl"],
374    out: ["linker.script"],
375    target: {
376        darwin: {
377            enabled: false,
378        },
379        bionic: {
380            enabled: false,
381        },
382        glibc: {
383            enabled: false,
384        },
385    },
386}
387
388//
389// The musl CRT objects
390//
391
392cc_defaults {
393    name: "libc_musl_crt_defaults",
394    defaults: ["libc_musl_defaults"],
395    cflags: [
396        // These are required to make sure the C code in crt/*.c
397        // doesn't have any dependencies on libc.
398        "-fno-stack-protector",
399        "-ftrivial-auto-var-init=uninitialized",
400    ],
401}
402
403cc_object {
404    name: "libc_musl_crt1",
405    defaults: [
406        "libc_musl_crt_defaults",
407        "libc_musl_crt1_sources",
408    ],
409}
410
411cc_object {
412    name: "libc_musl_crti",
413    defaults: [
414        "libc_musl_crt_defaults",
415        "libc_musl_crti_sources",
416    ],
417}
418
419cc_object {
420    name: "libc_musl_crtn",
421    defaults: [
422        "libc_musl_crt_defaults",
423        "libc_musl_crtn_sources",
424    ],
425}
426
427cc_object {
428    name: "libc_musl_rcrt1",
429    defaults: [
430        "libc_musl_crt_defaults",
431        "libc_musl_rcrt1_sources",
432    ],
433}
434
435cc_object {
436    name: "libc_musl_Scrt1",
437    defaults: [
438        "libc_musl_crt_defaults",
439        "libc_musl_Scrt1_sources",
440    ],
441}
442
443//
444// The custom CRT objects for use in the platform build.
445// Embeds the linker into crtbegin_dynamic.
446//
447
448cc_object {
449    name: "libc_musl_crtbegin_dynamic",
450    defaults: ["libc_musl_defaults"],
451    visibility: ["//visibility:public"],
452    objs: [
453        "libc_musl_crt1",
454        "libc_musl_crti",
455        "clang_rt.crtbegin",
456    ],
457    srcs: [
458        ":musl_linker_asm",
459        "android/ldso_trampoline.cpp",
460    ],
461    cflags: [
462        // These are required to make sure the C code in ldso_trampoline.c
463        // doesn't have any dependencies on libc.
464        "-fno-stack-protector",
465        "-ftrivial-auto-var-init=uninitialized",
466    ],
467}
468
469cc_object {
470    name: "libc_musl_crtbegin_static",
471    defaults: ["libc_musl_defaults"],
472    visibility: ["//visibility:public"],
473    objs: [
474        "libc_musl_Scrt1",
475        "libc_musl_crti",
476        "clang_rt.crtbegin",
477    ],
478}
479
480cc_object {
481    name: "libc_musl_crtend",
482    defaults: ["libc_musl_defaults"],
483    visibility: ["//visibility:public"],
484    objs: [
485        "clang_rt.crtend",
486        "libc_musl_crtn",
487    ],
488}
489
490cc_object {
491    name: "libc_musl_crtbegin_so",
492    defaults: ["libc_musl_defaults"],
493    visibility: ["//visibility:public"],
494    objs: [
495        "libc_musl_crti",
496        "clang_rt.crtbegin",
497    ],
498}
499
500cc_object {
501    name: "libc_musl_crtend_so",
502    defaults: ["libc_musl_defaults"],
503    visibility: ["//visibility:public"],
504    objs: [
505        "clang_rt.crtend",
506        "libc_musl_crtn",
507    ],
508}
509
510//
511// Tests for the embedded linker trampoline
512//
513
514cc_test_host {
515    name: "libc_musl_ldso_trampoline_test",
516    srcs: ["android/ldso_trampoline_test.cpp"],
517    stl: "libc++",
518    target: {
519        darwin: {
520            enabled: false,
521        },
522    },
523}
524
525//
526// Generated headers
527//
528
529genrule {
530    name: "libc_musl_version.h",
531    srcs: ["VERSION"],
532    out: ["version.h"],
533    cmd: "printf '#define VERSION \"%s\"\n' \"$$(cat $(location VERSION))\" > $(out)",
534}
535
536// libc_musl_arch_alltypes.h is split out of libc_musl_alltypes.h to ensure the arch-specific
537// alltypes.h.in ends up before the generic alltypes.h.in in the output.
538cc_genrule {
539    name: "libc_musl_arch_alltypes.h",
540    host_supported: true,
541    device_supported: false,
542    arch: {
543        arm: {
544            srcs: ["arch/arm/bits/alltypes.h.in"],
545        },
546        arm64: {
547            srcs: ["arch/aarch64/bits/alltypes.h.in"],
548        },
549        x86: {
550            srcs: ["arch/i386/bits/alltypes.h.in"],
551        },
552        x86_64: {
553            srcs: ["arch/x86_64/bits/alltypes.h.in"],
554        },
555    },
556    tool_files: ["tools/mkalltypes.sed"],
557    out: ["bits/alltypes.h"],
558    cmd: "sed -f $(location tools/mkalltypes.sed) $(in) > $(out)",
559}
560
561cc_genrule {
562    name: "libc_musl_alltypes.h",
563    host_supported: true,
564    device_supported: false,
565    srcs: [
566        "include/alltypes.h.in",
567        ":libc_musl_arch_alltypes.h",
568    ],
569    tool_files: ["tools/mkalltypes.sed"],
570    out: ["bits/alltypes.h"],
571    cmd: "( " +
572        "cat $(location :libc_musl_arch_alltypes.h) && " +
573        "sed -f $(location tools/mkalltypes.sed) $(location include/alltypes.h.in) " +
574        ") > $(out)",
575}
576
577cc_genrule {
578    name: "libc_musl_syscall.h",
579    host_supported: true,
580    device_supported: false,
581    arch: {
582        arm: {
583            srcs: ["arch/arm/bits/syscall.h.in"],
584        },
585        arm64: {
586            srcs: ["arch/aarch64/bits/syscall.h.in"],
587        },
588        x86: {
589            srcs: ["arch/i386/bits/syscall.h.in"],
590        },
591        x86_64: {
592            srcs: ["arch/x86_64/bits/syscall.h.in"],
593        },
594    },
595    out: ["bits/syscall.h"],
596    cmd: "cp $(in) $(out) && sed -n -e s/__NR_/SYS_/p < $(in) >> $(out)",
597}
598
599//
600// Rules to generate a sysroot.  This isn't used during the build, but can be convenient to run
601// configure scripts from external projects to generate necessary files to build against musl.
602//
603
604
605// A copy of libc_musl that uses libc.so as its soname for putting in the sysroot.
606cc_library_shared {
607    name: "libc_musl_for_sysroot",
608    defaults: ["libc_musl_defaults"],
609    whole_static_libs: ["libc_musl_static"],
610    shared: {
611        whole_static_libs: ["libc_musl_ldso_sysroot"],
612    },
613    ldflags: [
614        "-Wl,-e,_dlstart",
615        "-nostdlib",
616        "-Wl,--soname,libc.so",
617    ],
618    dynamic_list: "dynamic.list",
619}
620
621// An empty static library that will be copied to libdl.a, etc. in the sysroot.
622// Shouldn't be used by anything else besides the sysroot cc_genrule.
623cc_library_static {
624    name: "libc_musl_sysroot_static_empty",
625    defaults: [
626        "libc_musl_defaults",
627    ],
628}
629
630// The linker and trampoline compiled as a .o file to use as part of the sysroot
631// crt.
632cc_object {
633    name: "libc_musl_linker_object",
634    defaults: ["libc_musl_defaults"],
635    srcs: [
636        ":musl_linker_asm",
637        "android/ldso_trampoline.cpp",
638    ],
639    cflags: [
640        // These are required to make sure the C code in ldso_trampoline.c
641        // doesn't have any dependencies on libc.
642        "-fno-stack-protector",
643        "-ftrivial-auto-var-init=uninitialized",
644    ],
645}
646
647// The architecture-specific bits have to be handled separately because the label varies based
648// on architecture, which prevents using $(locations) to find them and requires using $(in)
649// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
650// genrule.
651cc_genrule {
652    name: "libc_musl_sysroot_bits",
653    host_supported: true,
654    device_supported: false,
655    arch: {
656        arm: {
657            srcs: ["arch/arm/bits/*.h"],
658        },
659        arm64: {
660            srcs: ["arch/aarch64/bits/*.h"],
661        },
662        x86: {
663            srcs: ["arch/i386/bits/*.h"],
664        },
665        x86_64: {
666            srcs: ["arch/x86_64/bits/*.h"],
667        },
668    },
669    out: ["libc_musl_sysroot_bits.zip"],
670    tools: ["soong_zip"],
671    cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/bits -j -D $$(dirname $${includes[0]})",
672}
673
674genrule {
675    name: "libc_musl_clang_wrapper",
676    srcs: ["tools/musl-clang.in"],
677    out: ["musl-clang"],
678    cmd: "sed -e 's`@CC@`clang`' -e 's`@PREFIX@`$$(dirname \"$$0\")/..`' -e 's`@INCDIR@`$${libc}/include`' -e 's`@LIBDIR@`$${libc}/lib`' $(in) > $(out) && " +
679        "chmod a+x $(out)",
680}
681
682genrule {
683    name: "libc_musl_ld_wrapper",
684    srcs: ["tools/ld.musl-clang.in"],
685    out: ["ld.musl-clang"],
686    cmd: "sed -e 's`@CC@`clang`' -e 's`@LIBDIR@`$$(dirname \"$$0\")/../lib`' -e 's`@LDSO@`$$(dirname \"$$0\")/../lib/ld-musl.so.1`' $(in) > $(out) && " +
687        "chmod a+x $(out)",
688}
689
690cc_genrule {
691    name: "libc_musl_sysroot",
692    host_supported: true,
693    device_supported: false,
694    enabled: false,
695    target: {
696        musl: {
697            enabled: true,
698        },
699    },
700    srcs: [
701        "LICENSE",
702        "COPYRIGHT",
703
704        // Headers
705        "include/**/*.h",
706        "arch/generic/bits/*.h",
707        "android/include/bits/*.h",
708        "android/include/sys/cdefs.h",
709        ":libc_musl_syscall.h",
710        ":libc_musl_alltypes.h",
711        ":libc_musl_sysroot_bits",
712
713        // Bionic kernel uapi headers
714        ":libc_musl_sysroot_bionic_headers",
715
716        // libc++ headers
717        ":libc_musl_sysroot_libc++_headers",
718        ":libc_musl_sysroot_libc++abi_headers",
719
720        // Libraries
721        ":libc_musl",
722        ":libc_musl_for_sysroot",
723        ":libc_musl_static",
724        ":libc++abi",
725        ":libc++",
726        ":libc++_static",
727
728        // Objects
729        ":libc_musl_crti",
730        ":libc_musl_crtn",
731        ":libc_musl_crt1",
732        ":libc_musl_rcrt1",
733        ":libc_musl_Scrt1",
734        ":clang_rt.crtbegin",
735        ":clang_rt.crtend",
736
737        // Embedded linker objects and linker scripts
738        ":libc_musl_linker_object",
739        ":musl_linker_script",
740
741        // Wrapper scripts
742        ":libc_musl_clang_wrapper",
743        ":libc_musl_ld_wrapper",
744
745        // Empty static libraries
746        ":libc_musl_sysroot_static_empty",
747    ],
748    out: ["libc_musl_sysroot.zip"],
749    tools: [
750        "soong_zip",
751        "merge_zips",
752        "zip2zip",
753    ],
754    cmd: "includes=($(locations include/**/*.h)) && " +
755        "bits=($(locations arch/generic/bits/*.h)) && " +
756        "android_bits=($(locations android/include/bits/*.h)) && " +
757        "ln -s libc_musl.so $(genDir)/ld-musl.so.1 && " +
758        "echo -e 'GROUP ( Scrt1-real.o libc_musl_linker_object.o )\nINCLUDE linker.script' > $(genDir)/Scrt1.ld && " +
759        "echo -e 'GROUP ( libc_musl.so )' > $(genDir)/libc.so && " +
760        "$(location soong_zip) -o $(genDir)/sysroot.zip " +
761        " -j " +
762        "  -f $(location LICENSE) " +
763        "  -f $(location COPYRIGHT) " +
764        // headers
765        " -P include " +
766        "  -C $$(dirname $${includes[0]}) " +
767        "  -D $$(dirname $${includes[0]}) " +
768        " -P include/bits -j " +
769        "  -f $(location :libc_musl_syscall.h) " +
770        "  -f $(location :libc_musl_alltypes.h) " +
771        "  -D $$(dirname $${bits[0]}) " +
772        "  -D $$(dirname $${android_bits[0]}) " +
773        " -P include/sys -j " +
774        "  -f $(location android/include/sys/cdefs.h) " +
775        // crt objects
776        " -P lib -j " +
777        "  -f $(location :libc_musl_crti) " +
778        "  -f $(location :libc_musl_crtn) " +
779        "  -f $(location :libc_musl_crt1) " +
780        "  -f $(location :libc_musl_rcrt1) " +
781        // embedded linker crt objects
782        "  -f $(location :musl_linker_script) " +
783        "  -f $(location :libc_musl_linker_object) " +
784        // libs
785        "  -f $(location :libc_musl) " +
786        "  -f $(location :libc++abi) " +
787        "  -f $(location :libc++) " +
788        "  -f $(genDir)/ld-musl.so.1 " +
789        "  -f $(genDir)/libc.so " +
790        // clang wrappers
791        " -P bin -j " +
792        "  -f $(location :libc_musl_clang_wrapper) " +
793        "  -f $(location :libc_musl_ld_wrapper) " +
794        " && " +
795        // libs in a separate zip so they can be renamed
796        "$(location soong_zip) -o $(genDir)/libs.zip " +
797        " -P lib -j " +
798        "  -f $(location :libc_musl_static) " +
799        "  -f $(location :libc_musl_sysroot_static_empty) " +
800        "  -f $(genDir)/Scrt1.ld " +
801        "  -f $(location :libc_musl_Scrt1) " +
802        "  -f $(location :libc++_static) " +
803        "  -f $(location :clang_rt.crtbegin) " +
804        "  -f $(location :clang_rt.crtend) " +
805        " && " +
806        "$(location zip2zip) -i $(genDir)/libs.zip -o $(genDir)/libs_renamed.zip " +
807        // rename libs from module names to desired names in sysroot
808        " lib/libc_musl_static.a:lib/libc.a " +
809        " lib/libc++_static.a:lib/libc++.a " +
810        // Swap in linker script for Scrt1.o
811        " lib/Scrt1.o:lib/Scrt1-real.o " +
812        " lib/Scrt1.ld:lib/Scrt1.o " +
813        // copy empty static libs
814        " lib/libc_musl_sysroot_static_empty.a:lib/libcrypt.a " +
815        " lib/libc_musl_sysroot_static_empty.a:lib/libdl.a " +
816        " lib/libc_musl_sysroot_static_empty.a:lib/libm.a " +
817        " lib/libc_musl_sysroot_static_empty.a:lib/libpthread.a " +
818        " lib/libc_musl_sysroot_static_empty.a:lib/libresolv.a " +
819        " lib/libc_musl_sysroot_static_empty.a:lib/librt.a " +
820        " lib/libc_musl_sysroot_static_empty.a:lib/libutil.a " +
821        " lib/libc_musl_sysroot_static_empty.a:lib/libxnet.a " +
822        // rename clang crt objects to gcc names
823        " lib/clang_rt.crtbegin.o:lib/crtbegin.o " +
824        " lib/clang_rt.crtbegin.o:lib/crtbeginS.o " +
825        " lib/clang_rt.crtbegin.o:lib/crtbeginT.o " +
826        " lib/clang_rt.crtend.o:lib/crtend.o " +
827        " lib/clang_rt.crtend.o:lib/crtendS.o " +
828        " && " +
829        "$(location merge_zips) -ignore-duplicates $(out) " +
830        " $(location :libc_musl_sysroot_bionic_headers) " +
831        " $(location :libc_musl_sysroot_libc++_headers) " +
832        " $(location :libc_musl_sysroot_libc++abi_headers) " +
833        " $(location :libc_musl_sysroot_bits) " +
834        " $(genDir)/sysroot.zip " +
835        " $(genDir)/libs_renamed.zip",
836}
837
838build=["sources.bp"]
839