Avoid linking libdexfile_support into static executables.

It doesn't define -DSTATIC_LIB, so it ends up compiling in dlopen() calls
that don't work in static executables. Use libdexfile_support_static
instead, which is intended for this use. That also requires adding a
corresponding libdexfiled_support_static.

This also fixes d/non-d library mixup because libdexfile_{external,support}
which depend on non-d libs were used in libartd_static_defaults.

Test: Build & boot
Test: art/test/run-test --chroot /data/local/art-test-chroot --jit --64 --timeout 5 151-OpenFileLimit
  and check that logcat has signal_dumper output without any fatal error
Bug: 141485154
Change-Id: I8005373814d73ceefc2891a77204d4ba89abb922
diff --git a/libdexfile/Android.bp b/libdexfile/Android.bp
index dea2a1a..e72ac11 100644
--- a/libdexfile/Android.bp
+++ b/libdexfile/Android.bp
@@ -388,15 +388,8 @@
     ],
 }
 
-cc_library_static {
-    name: "libdexfile_support_static",
-    defaults: ["libdexfile_static_defaults"],
-    visibility: [
-        "//art:__subpackages__",
-        // TODO(b/133140750): Clean this up.
-        "//system/core/debuggerd",
-        "//system/extras/simpleperf",
-    ],
+cc_defaults {
+    name: "libdexfile_support_static_defaults",
     host_supported: true,
     srcs: [
         "external/dex_file_supp.cc",
@@ -405,8 +398,6 @@
     // Using whole_static_libs here only as a "poor man's transitivity" kludge.
     whole_static_libs: [
         "libbase",
-        "libdexfile",
-        "libdexfile_external",
         "liblog",
         "libz",
         "libziparchive",
@@ -415,6 +406,37 @@
     export_header_lib_headers: ["libdexfile_external_headers"],
 }
 
+cc_library_static {
+    name: "libdexfile_support_static",
+    visibility: [
+        "//art:__subpackages__",
+        // TODO(b/133140750): Clean this up.
+        "//system/core/debuggerd",
+        "//system/core/init", // Dependency from Android.mk file, so not enforced.
+        "//system/extras/simpleperf",
+    ],
+    defaults: [
+        "libdexfile_static_defaults",
+        "libdexfile_support_static_defaults",
+    ],
+    whole_static_libs: [
+        "libdexfile",
+        "libdexfile_external",
+    ],
+}
+
+cc_library_static {
+    name: "libdexfiled_support_static",
+    defaults: [
+        "libdexfile_support_static_defaults",
+        "libdexfiled_static_defaults",
+    ],
+    whole_static_libs: [
+        "libdexfiled",
+        "libdexfiled_external",
+    ],
+}
+
 // The same source file is used in two tests here, so unlike other ART gtests it
 // doesn't use test_per_src. Its test target is
 // test-art-{host,target}-gtest-art_libdexfile_support_static_tests.
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 22dc208..477362b 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -429,8 +429,6 @@
         "libartpalette",
         "libbacktrace",
         "libbase",
-        "libdexfile_external", // libunwindstack dependency
-        "libdexfile_support", // libunwindstack dependency
         "liblog",
         "libnativebridge",
         "libnativeloader",
@@ -450,6 +448,7 @@
     ],
     static_libs: [
         "libart",
+        "libdexfile_support_static",
         "libelffile",
     ],
 }
@@ -464,6 +463,7 @@
     ],
     static_libs: [
         "libartd",
+        "libdexfiled_support_static",
         "libelffiled",
     ],
 }
diff --git a/tools/signal_dumper/Android.bp b/tools/signal_dumper/Android.bp
index 3faa149..acc7e2e 100644
--- a/tools/signal_dumper/Android.bp
+++ b/tools/signal_dumper/Android.bp
@@ -24,7 +24,7 @@
     defaults: ["signal_dumper_libbase_static_deps"],
     static_libs: [
         "libbase",
-        "libdexfile_support",
+        "libdexfile_support_static",
         "liblog",
         "liblzma",
     ],