Revert^2 "Link lzma and lz4 compression libs statically into libartbase and use that"

This reverts commit 9960cbc0ff98978a9b32f14ae77d8ddb3c6908d9.

Reason for revert: This is the same as aosp/815019 except version_script is
excluded on Darwin. I think it should pass the mac targets, but haven't
tested.

Test: art/tools/buildbot-build.sh {--host,--target}
Test: art/test/testrunner/run_build_test_target.py art-asan (not on Darwin)
Test: python frameworks/rs/build_rs.py (on Darwin, thanks Orion!)
Bug: 118374951
Change-Id: I7a362381f6d891c6dc1304e5fcf6f8851aa67d7c
diff --git a/compiler/Android.bp b/compiler/Android.bp
index 30a65b2..1996469 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -183,7 +183,6 @@
     shared_libs: [
         "libbase",
         "libcutils",  // for atrace.
-        "liblzma",
     ],
     include_dirs: ["art/disassembler"],
     header_libs: [
@@ -199,7 +198,6 @@
     static_libs: [
         "libbase",
         "libcutils",
-        "liblzma",
     ],
 }
 
diff --git a/dex2oat/Android.bp b/dex2oat/Android.bp
index fd5f3cd..8ce96a4 100644
--- a/dex2oat/Android.bp
+++ b/dex2oat/Android.bp
@@ -71,11 +71,8 @@
     generated_sources: ["art_dex2oat_operator_srcs"],
     shared_libs: [
         "libbase",
-        "liblz4",
-        "liblzma",
     ],
     include_dirs: [
-        "external/lz4/lib",
         "external/zlib",
     ],
     export_include_dirs: ["."],
@@ -98,8 +95,6 @@
     },
     static_libs: [
         "libbase",
-        "liblz4",
-        "liblzma",
     ],
 }
 
@@ -247,7 +242,6 @@
         "libdexfile",
         "libartbase",
         "libbase",
-        "liblz4",
         "libsigchain",
     ],
     static_libs: [
@@ -285,7 +279,6 @@
         "libdexfiled",
         "libartbased",
         "libbase",
-        "liblz4",
         "libsigchain",
     ],
     static_libs: [
@@ -315,7 +308,6 @@
     ],
     static_libs: [
         "libbase",
-        "liblz4",
         "libsigchain_dummy",
     ],
 }
@@ -411,11 +403,11 @@
         "external/zlib",
     ],
     shared_libs: [
-        "libprofiled",
+        "libartbased",
         "libartd-compiler",
         "libartd-dexlayout",
         "libbase",
-        "liblz4",
+        "libprofiled",
         "libsigchain",
         "libziparchive",
     ],
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 5010f68..6a667bc 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -54,6 +54,10 @@
                 "libziparchive",
                 "libz",
             ],
+            // Exclude the version script from Darwin host since it's not
+            // supported by the linker there. That means ASan checks on Darwin
+            // might trigger ODR violations.
+            version_script: "libartbase.map",
         },
         host: {
             shared_libs: [
@@ -61,16 +65,31 @@
                 "libz",
             ],
         },
+        linux_glibc: {
+            version_script: "libartbase.map",
+        },
+        windows: {
+            version_script: "libartbase.map",
+        },
     },
     generated_sources: ["art_libartbase_operator_srcs"],
     cflags: ["-DBUILDING_LIBART=1"],
     shared_libs: [
         "liblog",
-	// For ashmem.
+        // For ashmem.
         "libcutils",
         // For common macros.
         "libbase",
     ],
+
+    // Utilities used by various ART libs and tools are linked in statically
+    // here to avoid shared lib dependencies outside the ART APEX. No target
+    // there should depend on these separately.
+    whole_static_libs: [
+        "liblz4",
+        "liblzma",
+    ],
+
     export_include_dirs: ["."],
     // ART's macros.h depends on libbase's macros.h.
     // Note: runtime_options.h depends on cmdline. But we don't really want to export this
diff --git a/libartbase/libartbase.map b/libartbase/libartbase.map
new file mode 100644
index 0000000..6249930
--- /dev/null
+++ b/libartbase/libartbase.map
@@ -0,0 +1,15 @@
+# This is used only to hide data symbols that get imported through
+# whole_static_libs, or else they might trigger the ASan odr-violation check.
+# Before adding symbols here, please make sure that it doesn't give rise to a
+# real ODR problem. All these symbols are either in .rodata or .data.rel.ro
+# sections.
+LIBARTBASE {
+  local:
+    PPMD7_kExpEscape;
+    XZ_SIG;
+    g_AlignedAlloc;
+    g_Alloc;
+    g_BigAlloc;
+    g_MidAlloc;
+    k7zSignature;
+};
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 86ee952..4c1b288 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -377,7 +377,6 @@
     include_dirs: [
         "art/sigchainlib",
         "external/icu/icu4c/source/common",
-        "external/lz4/lib",
         "external/zlib",
     ],
     header_libs: [
@@ -390,7 +389,6 @@
         "libnativebridge",
         "libnativeloader",
         "libbacktrace",
-        "liblz4",
         "liblog",
         // For atrace, properties, ashmem, set_sched_policy.
         "libcutils",
@@ -422,8 +420,6 @@
         "libbase",
         "libcutils",
         "liblog",
-        "liblz4",
-        "liblzma",
         "libnativebridge",
         "libnativeloader",
         "libunwindstack",