Add libz.a to the sysroot
The libclang.so build against musl needs to link against libz. Using
a shared version complicates distributing clang, so add libz.a for now.
Bug: 216192129
Test: builds
Change-Id: I089f994174bcba9e762a52cf66d943a0321f3fb4
diff --git a/Android.bp b/Android.bp
index 81e72b6..7b7e22e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -658,6 +658,11 @@
"chmod a+x $(out)",
}
+cc_library_host_static {
+ name: "libz_static_for_sysroot",
+ whole_static_libs: ["libz"],
+}
+
cc_genrule {
name: "libc_musl_sysroot",
host_supported: true,
@@ -687,6 +692,7 @@
// libc++ headers
":libc_musl_sysroot_libc++_headers",
":libc_musl_sysroot_libc++abi_headers",
+ ":libc_musl_sysroot_zlib_headers",
// Libraries
":libc_musl",
@@ -694,6 +700,7 @@
":libc++abi",
":libc++",
":libc++_static",
+ ":libz_static_for_sysroot",
// Objects
":libc_musl_crti",
@@ -772,6 +779,7 @@
" -f $(location :libc++_static) " +
" -f $(location :clang_rt.crtbegin) " +
" -f $(location :clang_rt.crtend) " +
+ " -f $(location :libz_static_for_sysroot) " +
" && " +
"$(location zip2zip) -i $(genDir)/libs.zip -o $(genDir)/libs_renamed.zip " +
// rename libs from module names to desired names in sysroot
@@ -795,11 +803,14 @@
" lib/clang_rt.crtbegin.o:lib/crtbeginT.o " +
" lib/clang_rt.crtend.o:lib/crtend.o " +
" lib/clang_rt.crtend.o:lib/crtendS.o " +
+ // rename static libz
+ " lib/libz_static_for_sysroot.a:lib/libz.a " +
" && " +
"$(location merge_zips) -ignore-duplicates $(out) " +
" $(location :libc_musl_sysroot_bionic_headers) " +
" $(location :libc_musl_sysroot_libc++_headers) " +
" $(location :libc_musl_sysroot_libc++abi_headers) " +
+ " $(location :libc_musl_sysroot_zlib_headers) " +
" $(location :libc_musl_sysroot_bits) " +
" $(genDir)/sysroot.zip " +
" $(genDir)/libs_renamed.zip",