Export the unwinder implementation from libc.

This supports the soong commit which causes most platform binaries to stop
statically linking against the unwinder implementation. The soong commit
message has more motivation for this change.

ARM32 uses LLVM libunwind, while all other platforms use libgcc as the
unwinder implementation. This matches the current choices of unwinders on
the various architectures, but means that apps which were directly linking
against the libc.so unwinder symbols on ARM32 are now using LLVM libunwind
instead of libgcc.

Set libc_headers sdk_version to 1 so that libunwind_llvm can depend on it,
and stop statically linking libunwind into libc_malloc_debug.

Bug: 144430859
Change-Id: I52c7f7893d93f500383aeb0b76086c3b6f1935a5
diff --git a/libc/Android.bp b/libc/Android.bp
index 26cd3a3..2a5bce7 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1711,7 +1711,7 @@
                 keep_symbols_and_debug_frame: true,
             },
 
-            whole_static_libs: [ "libgcc_stripped" ],
+            whole_static_libs: [ "libunwind_llvm" ],
         },
         arm64: {
             version_script: ":libc.arm64.map",
@@ -1721,6 +1721,8 @@
             strip: {
                 keep_symbols: true,
             },
+
+            whole_static_libs: [ "libgcc_stripped" ],
         },
         x86: {
             // TODO: This is to work around b/24465209. Remove after root cause is fixed.
@@ -1734,6 +1736,8 @@
             strip: {
                 keep_symbols: true,
             },
+
+            whole_static_libs: [ "libgcc_stripped" ],
         },
         x86_64: {
             version_script: ":libc.x86_64.map",
@@ -1743,6 +1747,8 @@
             strip: {
                 keep_symbols: true,
             },
+
+            whole_static_libs: [ "libgcc_stripped" ],
         },
     },
 
@@ -1827,6 +1833,14 @@
     stl: "none",
     system_shared_libs: [],
 
+    // The build system generally requires that any dependencies of a target
+    // with an sdk_version must have a lower sdk_version. By setting sdk_version
+    // to 1 we let targets with an sdk_version that need to depend on the libc
+    // headers but cannot depend on libc itself due to circular dependencies
+    // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
+    // is correct because the headers can support any sdk_version.
+    sdk_version: "1",
+
     export_include_dirs: [
         "include",
         "kernel/uapi",