Link libvixl statically.

Instead of including shared library libvixl.so in the ART
Module, link libvixl statically to all binaries that use it,
namely libart-compiler.so and libart-disassembler.so which
shall increase in size with the additional libvixl code.

The ART Module size with default libvixl symbol visibility:
  - before: 88460730B
  - after: 86973943B (-1.42MiB)
With hidden libvixl symbol visibility:
  - before: 88337851B
  - after: 84962808B (-3.22MiB)
(This is with master-art where we do not have a boot
profile and therefore compile more code in boot image.)
The change from default to hidden visibility is done in
    https://android-review.googlesource.com/1697237 .

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 186902856
Change-Id: I040b0115b94b8690ee7be53e3ded8610d9f13e99
diff --git a/Android.mk b/Android.mk
index 6bb1476..3bdcc5f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -527,7 +527,6 @@
   lib/libprofile.so \
   lib/libsigchain.so \
   lib/libunwindstack.so \
-  lib/libvixl.so \
   lib/libziparchive.so \
   lib64/libadbconnection.so \
   lib64/libandroidio.so \
@@ -560,7 +559,6 @@
   lib64/libprofile.so \
   lib64/libsigchain.so \
   lib64/libunwindstack.so \
-  lib64/libvixl.so \
   lib64/libziparchive.so \
 
 PRIVATE_RUNTIME_APEX_DEPENDENCY_FILES := \
diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py
index 9044fc7..b83b8af 100755
--- a/build/apex/art_apex_test.py
+++ b/build/apex/art_apex_test.py
@@ -588,7 +588,6 @@
     self._checker.check_native_library('libnpt')
     self._checker.check_native_library('libunwindstack')
     self._checker.check_native_library('libziparchive')
-    self._checker.check_optional_native_library('libvixl')  # Only on ARM/ARM64
 
     # Allow extra dependencies that appear in ASAN builds.
     self._checker.check_optional_native_library('libclang_rt.asan*')
@@ -723,7 +722,6 @@
     # double_loadable:true, cf. go/double_loadable). Also, like in the release
     # package we need to look out for dependencies that should go through
     # exported library stubs (until b/128708192 is fixed).
-    self._checker.check_optional_native_library('libvixld')  # Only on ARM/ARM64
     self._checker.check_prefer64_library('libmeminfo')
     self._checker.check_prefer64_library('libprocinfo')
 
diff --git a/build/codegen.go b/build/codegen.go
index bc7dc42..96dd223 100644
--- a/build/codegen.go
+++ b/build/codegen.go
@@ -102,6 +102,13 @@
 			}
 		}
 
+		type libraryProps struct {
+			Target struct {
+				Android *CodegenLibraryArchProperties
+				Host    *CodegenLibraryArchProperties
+			}
+		}
+
 		type sharedLibraryProps struct {
 			Target struct {
 				Android *CodegenLibraryArchSharedProperties
@@ -119,20 +126,24 @@
 		arch := getCodegenArchProperties(archName)
 
 		cp := &commonProps{}
+		lp := &libraryProps{}
 		sharedLP := &sharedLibraryProps{}
 		staticLP := &staticLibraryProps{}
 		if host {
 			cp.Target.Host = &arch.CodegenCommonArchProperties
+			lp.Target.Host = &arch.CodegenLibraryArchProperties
 			sharedLP.Target.Host = &arch.CodegenLibraryArchSharedProperties
 			staticLP.Target.Host = &arch.CodegenLibraryArchStaticProperties
 		} else {
 			cp.Target.Android = &arch.CodegenCommonArchProperties
+			lp.Target.Android = &arch.CodegenLibraryArchProperties
 			sharedLP.Target.Android = &arch.CodegenLibraryArchSharedProperties
 			staticLP.Target.Android = &arch.CodegenLibraryArchStaticProperties
 		}
 
 		ctx.AppendProperties(cp)
 		if t.library {
+			ctx.AppendProperties(lp)
 			if t.static {
 				ctx.AppendProperties(staticLP)
 			}
@@ -167,6 +178,11 @@
 	Cppflags []string
 }
 
+type CodegenLibraryArchProperties struct {
+	Static_libs               []string
+	Export_static_lib_headers []string
+}
+
 type CodegenLibraryArchStaticProperties struct {
 	Static struct {
 		Whole_static_libs []string
@@ -182,6 +198,7 @@
 type codegenArchProperties struct {
 	CodegenSourceArchProperties
 	CodegenCommonArchProperties
+	CodegenLibraryArchProperties
 	CodegenLibraryArchStaticProperties
 	CodegenLibraryArchSharedProperties
 }
diff --git a/compiler/Android.bp b/compiler/Android.bp
index b90b7e8..d1eae50 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -210,37 +210,15 @@
     codegen: {
         arm: {
             // VIXL assembly support for ARM targets.
-            static: {
-                whole_static_libs: [
-                    "libvixl",
-                ],
-            },
-            shared: {
-                shared_libs: [
-                    "libvixl",
-                ],
-                // Export vixl headers as they are included in this library's exported headers.
-                export_shared_lib_headers: [
-                    "libvixl",
-                ],
-            },
+            static_libs: [
+                "libvixl",
+            ],
         },
         arm64: {
             // VIXL assembly support for ARM64 targets.
-            static: {
-                whole_static_libs: [
-                    "libvixl",
-                ],
-            },
-            shared: {
-                shared_libs: [
-                    "libvixl",
-                ],
-                // Export vixl headers as they are included in this library's exported headers.
-                export_shared_lib_headers: [
-                    "libvixl",
-                ],
-            },
+            static_libs: [
+                "libvixl",
+            ],
         },
     },
     shared_libs: [
@@ -292,37 +270,23 @@
     codegen: {
         arm: {
             // VIXL assembly support for ARM targets.
-            static: {
-                whole_static_libs: [
-                    "libvixld",
-                ],
-            },
-            shared: {
-                shared_libs: [
-                    "libvixld",
-                ],
-                // Export vixl headers as they are included in this library's exported headers.
-                export_shared_lib_headers: [
-                    "libvixld",
-                ],
-            },
+            static_libs: [
+                "libvixld",
+            ],
+            // Export vixl headers as they are included in this library's headers used by tests.
+            export_static_lib_headers: [
+                "libvixld",
+            ],
         },
         arm64: {
             // VIXL assembly support for ARM64 targets.
-            static: {
-                whole_static_libs: [
-                    "libvixld",
-                ],
-            },
-            shared: {
-                shared_libs: [
-                    "libvixld",
-                ],
-                // Export vixl headers as they are included in this library's exported headers.
-                export_shared_lib_headers: [
-                    "libvixld",
-                ],
-            },
+            static_libs: [
+                "libvixld",
+            ],
+            // Export vixl headers as they are included in this library's headers used by tests.
+            export_static_lib_headers: [
+                "libvixld",
+            ],
         },
     },
     shared_libs: [
@@ -474,11 +438,13 @@
         "libprofiled",
         "libartd-compiler",
         "libartd-simulator-container",
-        "libvixld",
 
         "libbacktrace",
         "libnativeloader",
     ],
+    static_libs: [
+        "libvixld",
+    ],
 
     target: {
         host: {
@@ -514,6 +480,8 @@
     },
     shared_libs: [
         "libartd-compiler",
+    ],
+    static_libs: [
         "libvixld",
     ],
 }
diff --git a/dex2oat/linker/arm/relative_patcher_thumb2.cc b/dex2oat/linker/arm/relative_patcher_thumb2.cc
index 72b93ec..99728cf 100644
--- a/dex2oat/linker/arm/relative_patcher_thumb2.cc
+++ b/dex2oat/linker/arm/relative_patcher_thumb2.cc
@@ -29,7 +29,6 @@
 #include "mirror/array-inl.h"
 #include "mirror/object.h"
 #include "read_barrier.h"
-#include "utils/arm/assembler_arm_vixl.h"
 
 namespace art {
 namespace linker {
diff --git a/disassembler/Android.bp b/disassembler/Android.bp
index 6682fd7..71ad051 100644
--- a/disassembler/Android.bp
+++ b/disassembler/Android.bp
@@ -57,10 +57,20 @@
 art_cc_library {
     name: "libart-disassembler",
     defaults: ["libart-disassembler-defaults"],
-    shared_libs: [
-        // For disassembler_arm*.
-        "libvixl",
-    ],
+    codegen: {
+        arm: {
+            static_libs: [
+                // For disassembler_arm*.
+                "libvixl",
+            ],
+        },
+        arm64: {
+            static_libs: [
+                // For disassembler_arm*.
+                "libvixl",
+            ],
+        },
+    },
     apex_available: [
         "com.android.art",
         "com.android.art.debug",
@@ -81,10 +91,20 @@
         "art_debug_defaults",
         "libart-disassembler-defaults",
     ],
-    shared_libs: [
-        // For disassembler_arm*.
-        "libvixld",
-    ],
+    codegen: {
+        arm: {
+            static_libs: [
+                // For disassembler_arm*.
+                "libvixld",
+            ],
+        },
+        arm64: {
+            static_libs: [
+                // For disassembler_arm*.
+                "libvixld",
+            ],
+        },
+    },
 
     apex_available: [
         "com.android.art",
diff --git a/runtime/Android.bp b/runtime/Android.bp
index f57f59f..8181cd9 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -779,7 +779,6 @@
     ],
     shared_libs: [
         "libartd-compiler",
-        "libvixld",
     ],
 }
 
diff --git a/simulator/Android.bp b/simulator/Android.bp
index 2c02179..d29319a 100644
--- a/simulator/Android.bp
+++ b/simulator/Android.bp
@@ -54,6 +54,8 @@
     shared_libs: [
         "libart",
         "libartbase",
+    ],
+    static_libs: [
         "libvixl",
     ],
 }
@@ -67,6 +69,8 @@
     shared_libs: [
         "libartd",
         "libartbased",
+    ],
+    static_libs: [
         "libvixld",
     ],
 }
diff --git a/test/Android.bp b/test/Android.bp
index 1a14eff..ec96ce6 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -120,7 +120,6 @@
     shared_libs: [
         "libartd",
         "libartd-disassembler",
-        "libvixld",
         "libart-gtest",
         "libdexfiled",
         "libprofiled",