Skip to content

Commit

Permalink
Link libvixl statically.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vmarko committed May 10, 2021
1 parent bcec38f commit 053e138
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 72 deletions.
2 changes: 0 additions & 2 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ PRIVATE_ART_APEX_DEPENDENCY_LIBS := \
lib/libprofile.so \
lib/libsigchain.so \
lib/libunwindstack.so \
lib/libvixl.so \
lib/libziparchive.so \
lib64/libadbconnection.so \
lib64/libandroidio.so \
Expand Down Expand Up @@ -560,7 +559,6 @@ PRIVATE_ART_APEX_DEPENDENCY_LIBS := \
lib64/libprofile.so \
lib64/libsigchain.so \
lib64/libunwindstack.so \
lib64/libvixl.so \
lib64/libziparchive.so \

PRIVATE_RUNTIME_APEX_DEPENDENCY_FILES := \
Expand Down
2 changes: 0 additions & 2 deletions build/apex/art_apex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ def run(self):
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*')
Expand Down Expand Up @@ -723,7 +722,6 @@ def run(self):
# 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')

Expand Down
17 changes: 17 additions & 0 deletions build/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ func codegen(ctx android.LoadHookContext, c *codegenProperties, t moduleType) {
}
}

type libraryProps struct {
Target struct {
Android *CodegenLibraryArchProperties
Host *CodegenLibraryArchProperties
}
}

type sharedLibraryProps struct {
Target struct {
Android *CodegenLibraryArchSharedProperties
Expand All @@ -119,20 +126,24 @@ func codegen(ctx android.LoadHookContext, c *codegenProperties, t moduleType) {
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)
}
Expand Down Expand Up @@ -167,6 +178,11 @@ type CodegenCommonArchProperties struct {
Cppflags []string
}

type CodegenLibraryArchProperties struct {
Static_libs []string
Export_static_lib_headers []string
}

type CodegenLibraryArchStaticProperties struct {
Static struct {
Whole_static_libs []string
Expand All @@ -182,6 +198,7 @@ type CodegenLibraryArchSharedProperties struct {
type codegenArchProperties struct {
CodegenSourceArchProperties
CodegenCommonArchProperties
CodegenLibraryArchProperties
CodegenLibraryArchStaticProperties
CodegenLibraryArchSharedProperties
}
Expand Down
82 changes: 25 additions & 57 deletions compiler/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -210,37 +210,15 @@ art_cc_library {
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: [
Expand Down Expand Up @@ -292,37 +270,23 @@ art_cc_library {
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: [
Expand Down Expand Up @@ -474,11 +438,13 @@ art_cc_test {
"libprofiled",
"libartd-compiler",
"libartd-simulator-container",
"libvixld",

"libbacktrace",
"libnativeloader",
],
static_libs: [
"libvixld",
],

target: {
host: {
Expand Down Expand Up @@ -514,6 +480,8 @@ art_cc_test {
},
shared_libs: [
"libartd-compiler",
],
static_libs: [
"libvixld",
],
}
1 change: 0 additions & 1 deletion dex2oat/linker/arm/relative_patcher_thumb2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
36 changes: 28 additions & 8 deletions disassembler/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,20 @@ art_cc_defaults {
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",
Expand All @@ -81,10 +91,20 @@ art_cc_library {
"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",
Expand Down
1 change: 0 additions & 1 deletion runtime/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,6 @@ art_cc_test {
],
shared_libs: [
"libartd-compiler",
"libvixld",
],
}

Expand Down
4 changes: 4 additions & 0 deletions simulator/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ art_cc_library {
shared_libs: [
"libart",
"libartbase",
],
static_libs: [
"libvixl",
],
}
Expand All @@ -67,6 +69,8 @@ art_cc_library {
shared_libs: [
"libartd",
"libartbased",
],
static_libs: [
"libvixld",
],
}
Expand Down
1 change: 0 additions & 1 deletion test/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ art_cc_defaults {
shared_libs: [
"libartd",
"libartd-disassembler",
"libvixld",
"libart-gtest",
"libdexfiled",
"libprofiled",
Expand Down

0 comments on commit 053e138

Please sign in to comment.