diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/Android.bp | 237 | ||||
-rw-r--r-- | compiler/export/jit_load.h | 31 | ||||
-rw-r--r-- | compiler/jit/jit_compiler.cc | 1 | ||||
-rw-r--r-- | compiler/optimizing/graph_visualizer.cc | 10 |
4 files changed, 184 insertions, 95 deletions
diff --git a/compiler/Android.bp b/compiler/Android.bp index 117e8dc6b0..3b44e37e0a 100644 --- a/compiler/Android.bp +++ b/compiler/Android.bp @@ -28,6 +28,124 @@ package { default_applicable_licenses: ["art_license"], } +// Common dependencies for debug/release libart-compiler builds +libart_cc_defaults { + name: "libart-compiler_common_dependencies", + shared_libs: [ + "libbase", + "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib. + ], +} + +// Collect all required dependencies for build targets that link against libart-compiler +// Workaround for lack of static_libs transitive dependencies propagation (b/169779783) +libart_cc_defaults { + name: "libart-compiler_dependencies", + defaults: ["libart-compiler_common_dependencies"], + + codegen: { + arm: { + // VIXL assembly support for ARM targets. + static_libs: [ + "libvixl", + ], + }, + arm64: { + // VIXL assembly support for ARM64 targets. + static_libs: [ + "libvixl", + ], + }, + }, + shared_libs: [ + "libartbase", + "libartpalette", + "libdexfile", + "libprofile", + ], + static_libs: [ + "libelffile", + ], + + // In order to save memory on device `art::HGraphVisualizerDisassembler` loads `libart-disassembler.so` + // dynamically. Host builds of `libart-compiler` depend on `libart-disassembler` directly with + // `shared_libs` or `static_libs` + target: { + host: { + shared: { + shared_libs: [ + "libart-disassembler", + ], + }, + }, + android: { + runtime_libs: [ + // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load + // `libart-disassembler.so`. + "libart-disassembler", + ], + }, + }, +} + +libart_cc_defaults { + name: "libartd-compiler_dependencies", + defaults: ["libart-compiler_common_dependencies"], + + codegen: { + arm: { + // VIXL assembly support for ARM targets. + 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_libs: [ + "libvixld", + ], + // Export vixl headers as they are included in this library's headers used by tests. + export_static_lib_headers: [ + "libvixld", + ], + }, + }, + shared_libs: [ + "libartbased", + "libartd-disassembler", + "libartpalette", + "libdexfiled", + "libprofiled", + ], + static_libs: [ + "libelffiled", + ], + + // In order to save memory on device `art::HGraphVisualizerDisassembler` loads `libartd-disassembler.so` + // dynamically. Host builds of `libartd-compiler` depend on `libartd-disassembler` directly with + // `shared_libs` or `static_libs` + target: { + host: { + shared: { + shared_libs: [ + "libartd-disassembler", + ], + }, + }, + android: { + runtime_libs: [ + // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load + // `libartd-disassembler.so`. + "libartd-disassembler", + ], + }, + }, +} + art_cc_defaults { name: "libart-compiler-defaults", defaults: ["art_defaults"], @@ -157,29 +275,30 @@ art_cc_defaults { ], }, }, - static: { - cflags: ["-DART_STATIC_LIBART_COMPILER"], - }, generated_sources: ["art_compiler_operator_srcs"], - shared_libs: [ - "libbase", - "liblzma", // libelffile(d) dependency; must be repeated here since it's a static lib. - ], + export_include_dirs: ["."], header_libs: [ "art_cmdlineparser_headers", // For compiler_options. "art_disassembler_headers", "libnativehelper_header_only", ], - - export_include_dirs: ["."], + // TODO: since libart-compiler is a static lib now + // replace version script with EXPORT/HIDDEN attributes // Not using .map.txt because this is an internal API version_script: "libart-compiler.map", } -cc_defaults { - name: "libart-compiler_static_base_defaults", - whole_static_libs: [ - "libbase", +// Export headers required by `libart-runtime` to use JIT from `libart-compiler` +cc_library_headers { + name: "libart-compiler_jit_headers", + defaults: ["art_defaults"], + host_supported: true, + + export_include_dirs: ["export"], + + apex_available: [ + "com.android.art", + "com.android.art.debug", ], } @@ -198,41 +317,18 @@ gensrcs { output_extension: "operator_out.cc", } -art_cc_library { +art_cc_library_static { name: "libart-compiler", defaults: [ - "libart-compiler-defaults", - "dex2oat-pgo-defaults", "art_hugepage_defaults", + "dex2oat-pgo-defaults", + "libart-compiler-defaults", + "libart-compiler_dependencies", ], - codegen: { - arm: { - // VIXL assembly support for ARM targets. - static_libs: [ - "libvixl", - ], - }, - arm64: { - // VIXL assembly support for ARM64 targets. - static_libs: [ - "libvixl", - ], - }, - }, - shared_libs: [ - "libart", - "libartbase", - "libartpalette", - "libprofile", - "libdexfile", - ], - static_libs: ["libelffile"], - runtime_libs: [ - // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load - // `libart-disassembler.so`. - "libart-disassembler", + header_libs: [ + "libart_headers", + "libart_generated_headers", ], - target: { android: { lto: { @@ -249,58 +345,25 @@ art_cc_library { cc_defaults { name: "libart-compiler_static_defaults", defaults: [ - "libart-compiler_static_base_defaults", + "libart-compiler_dependencies", "libart-disassembler_static_defaults", - "libart_static_defaults", "libartbase_static_defaults", "libdexfile_static_defaults", "libprofile_static_defaults", ], - whole_static_libs: ["libart-compiler"], } -art_cc_library { +art_cc_library_static { name: "libartd-compiler", defaults: [ "art_debug_defaults", "libart-compiler-defaults", + "libartd-compiler_dependencies", ], - codegen: { - arm: { - // VIXL assembly support for ARM targets. - 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_libs: [ - "libvixld", - ], - // Export vixl headers as they are included in this library's headers used by tests. - export_static_lib_headers: [ - "libvixld", - ], - }, - }, - shared_libs: [ - "libartbased", - "libartd", - "libartpalette", - "libprofiled", - "libdexfiled", - ], - static_libs: ["libelffiled"], - runtime_libs: [ - // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load - // `libartd-disassembler.so`. - "libartd-disassembler", + header_libs: [ + "libart_headers", + "libart_generated_headers", ], - apex_available: [ "com.android.art.debug", // TODO(b/183882457): This lib doesn't go into com.android.art, but @@ -313,14 +376,12 @@ art_cc_library { cc_defaults { name: "libartd-compiler_static_defaults", defaults: [ - "libart-compiler_static_base_defaults", "libartbased_static_defaults", + "libartd-compiler_dependencies", "libartd-disassembler_static_defaults", - "libartd_static_defaults", "libdexfiled_static_defaults", "libprofiled_static_defaults", ], - whole_static_libs: ["libartd-compiler"], } // Properties common to `libart-compiler-gtest` and `libartd-compiler-gtest`. @@ -341,7 +402,6 @@ art_cc_library { "libart-compiler-gtest-common", ], shared_libs: [ - "libart-compiler", "libart-disassembler", "libartbase-art-gtest", "libart-runtime-gtest", @@ -355,7 +415,6 @@ art_cc_library { "libart-compiler-gtest-common", ], shared_libs: [ - "libartd-compiler", "libartd-disassembler", "libartbased-art-gtest", "libartd-runtime-gtest", @@ -490,7 +549,6 @@ art_cc_test { "liblzma", ], static_libs: [ - "libartd-compiler", "libelffiled", "libvixld", ], @@ -516,7 +574,6 @@ art_cc_test { // TODO(b/192070541): Consider linking `libart-simulator-container` // dynamically. "libart-simulator-container", - "libart-compiler", "libelffile", "libvixl", ], @@ -554,8 +611,6 @@ art_cc_test { "liblzma", ], static_libs: [ - "libartd-compiler", "libelffiled", - "libvixld", ], } diff --git a/compiler/export/jit_load.h b/compiler/export/jit_load.h new file mode 100644 index 0000000000..21a0254180 --- /dev/null +++ b/compiler/export/jit_load.h @@ -0,0 +1,31 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_COMPILER_EXPORT_JIT_LOAD_H_ +#define ART_COMPILER_EXPORT_JIT_LOAD_H_ + +namespace art { +namespace jit { + +class JitCompilerInterface; + +// used in `libart-runtime` to load `libart-compiler` JIT +extern "C" JitCompilerInterface* jit_load(); + +} // namespace jit +} // namespace art + +#endif // ART_COMPILER_EXPORT_JIT_LOAD_H_ diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index f12a3ad52b..07a9969285 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -29,6 +29,7 @@ #include "compiler.h" #include "debug/elf_debug_writer.h" #include "driver/compiler_options.h" +#include "export/jit_load.h" #include "jit/debugger_interface.h" #include "jit/jit.h" #include "jit/jit_code_cache.h" diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index e1199dfb72..1e41a22e91 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -115,7 +115,9 @@ std::ostream& operator<<(std::ostream& os, const StringList& list) { } } -#ifndef ART_STATIC_LIBART_COMPILER +// On target: load `libart-disassembler` only when required (to save on memory) +// On host: `libart-disassembler` should be linked directly (either as a static or dynamic lib) +#ifdef ART_TARGET using create_disasm_prototype = Disassembler*(InstructionSet, DisassemblerOptions*); #endif @@ -125,7 +127,7 @@ class HGraphVisualizerDisassembler { const uint8_t* base_address, const uint8_t* end_address) : instruction_set_(instruction_set), disassembler_(nullptr) { -#ifndef ART_STATIC_LIBART_COMPILER +#ifdef ART_TARGET constexpr const char* libart_disassembler_so_name = kIsDebugBuild ? "libartd-disassembler.so" : "libart-disassembler.so"; libart_disassembler_handle_ = dlopen(libart_disassembler_so_name, RTLD_NOW); @@ -159,7 +161,7 @@ class HGraphVisualizerDisassembler { ~HGraphVisualizerDisassembler() { // We need to call ~Disassembler() before we close the library. disassembler_.reset(); -#ifndef ART_STATIC_LIBART_COMPILER +#ifdef ART_TARGET if (libart_disassembler_handle_ != nullptr) { dlclose(libart_disassembler_handle_); } @@ -184,7 +186,7 @@ class HGraphVisualizerDisassembler { InstructionSet instruction_set_; std::unique_ptr<Disassembler> disassembler_; -#ifndef ART_STATIC_LIBART_COMPILER +#ifdef ART_TARGET void* libart_disassembler_handle_; #endif }; |