Enable libc/libdl/libm/linker for host bionic

Disables debuggerd integration unless building for android.

Bug: 31559095
Test: Diff out/soong/build.ninja before/after, only change is moving
      linker's libdebuggerd_client static lib to the beginning of the
      list.
Test: lunch aosp_arm64-eng; mmma -j bionic
Change-Id: I62e725f7a9b98b7fe31637d0a835fd5846b0aff0
diff --git a/linker/Android.bp b/linker/Android.bp
index 4d770ac..5745d73 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -1,6 +1,7 @@
 cc_library_static {
     name: "liblinker_malloc",
     clang: true,
+    defaults: ["linux_bionic_supported"],
 
     srcs: [
         "linker_allocator.cpp",
@@ -13,6 +14,7 @@
 
 cc_binary {
     clang: true,
+    defaults: ["linux_bionic_supported"],
 
     srcs: [
         "dlfcn.cpp",
@@ -112,7 +114,6 @@
         "libbase",
         "libz",
         "liblog",
-        "libdebuggerd_client",
 
         // Important: The liblinker_malloc should be the last library in the list
         // to overwrite any other malloc implementations by other static libraries.
@@ -131,9 +132,15 @@
        },
     },
     target: {
+        android: {
+            static_libs: ["libdebuggerd_client"],
+        },
         android64: {
             cflags: ["-DTARGET_IS_64_BIT"],
         },
+        linux_bionic: {
+            cflags: ["-DTARGET_IS_64_BIT"],
+        },
     },
     compile_multilib: "both",
 
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 2e98bf0..a8cc814 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -40,7 +40,9 @@
 
 #include "android-base/strings.h"
 #include "android-base/stringprintf.h"
+#ifdef __ANDROID__
 #include "debuggerd/client.h"
+#endif
 
 #include <vector>
 
@@ -217,6 +219,7 @@
   __system_properties_init(); // may use 'environ'
 
   // Register the debuggerd signal handler.
+#ifdef __ANDROID__
   debuggerd_callbacks_t callbacks = {
     .get_abort_message = []() {
       return g_abort_message;
@@ -224,6 +227,7 @@
     .post_dump = &notify_gdb_of_libraries,
   };
   debuggerd_init(&callbacks);
+#endif
 
   g_linker_logger.ResetState();