summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
author Dmitrii Ishcheikin <ishcheikin@google.com> 2023-08-22 23:50:44 +0000
committer Dmitrii Ishcheikin <ishcheikin@google.com> 2023-08-23 14:05:41 +0000
commit61b1c151163a09ad49c0b74c19ee84caeb4d0345 (patch)
tree6b805b96dcca4655e351f7d4858accd56ed4f728 /compiler
parent134d1ae6e38c679f0325b08a1e773e526a00db78 (diff)
Revert^3 "Merge libart and libart-compiler into a single library"
This reverts commit 4617cc65933921f40b8dd09ad630850a984486c7. Reason for revert: app startup regressions b/296703167 b/295363008 Change-Id: Ib31df00f80c57b9c86d6d0254e795b9ad6e22e00
Diffstat (limited to 'compiler')
-rw-r--r--compiler/Android.bp89
-rw-r--r--compiler/export/jit_create.h33
-rw-r--r--compiler/jit/jit_compiler.cc4
-rw-r--r--compiler/libart-compiler.map34
-rw-r--r--compiler/optimizing/graph_visualizer.cc10
5 files changed, 76 insertions, 94 deletions
diff --git a/compiler/Android.bp b/compiler/Android.bp
index a690898523..6472613cfe 100644
--- a/compiler/Android.bp
+++ b/compiler/Android.bp
@@ -37,7 +37,6 @@ cc_defaults {
"libartpalette",
],
header_libs: [
- "libart_headers",
"libart_generated_headers",
],
}
@@ -66,23 +65,11 @@ art_cc_defaults {
],
},
},
- // 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: [
- "libart-disassembler",
- ],
- },
- },
+ runtime_libs: [
+ // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load
+ // `libart-disassembler.so`.
+ "libart-disassembler",
+ ],
}
// Dependencies of libartd-compiler, used to propagate libartd-compiler deps when static linking.
@@ -109,23 +96,11 @@ art_cc_defaults {
],
},
},
- // 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: [
- "libartd-disassembler",
- ],
- },
- },
+ runtime_libs: [
+ // `art::HGraphVisualizerDisassembler::HGraphVisualizerDisassembler` may dynamically load
+ // `libartd-disassembler.so`.
+ "libartd-disassembler",
+ ],
}
art_cc_defaults {
@@ -269,7 +244,14 @@ 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.
+ ],
header_libs: [
"art_cmdlineparser_headers", // For compiler_options.
"art_disassembler_headers",
@@ -277,6 +259,8 @@ art_cc_defaults {
],
export_include_dirs: ["."],
+ // Not using .map.txt because this is an internal API
+ version_script: "libart-compiler.map",
}
cc_defaults {
@@ -301,7 +285,7 @@ gensrcs {
output_extension: "operator_out.cc",
}
-art_cc_library_static {
+art_cc_library {
name: "libart-compiler",
defaults: [
"libart-compiler-defaults",
@@ -309,6 +293,11 @@ art_cc_library_static {
"art_hugepage_defaults",
"libart-compiler_deps",
],
+ shared_libs: [
+ // libart is not included in libart-compiler_deps to allow libart-compiler(-for-test)
+ // select suitable libart library (either with or without LTO).
+ "libart",
+ ],
target: {
android: {
lto: {
@@ -334,6 +323,9 @@ art_cc_library_static {
"art_hugepage_defaults",
"libart-compiler_deps",
],
+ header_libs: [
+ "libart_headers",
+ ],
}
cc_defaults {
@@ -341,6 +333,7 @@ cc_defaults {
defaults: [
"libart-compiler_static_base_defaults",
"libart-disassembler_static_defaults",
+ "libart_static_defaults",
"libartbase_static_defaults",
"libdexfile_static_defaults",
"libprofile_static_defaults",
@@ -356,6 +349,7 @@ cc_defaults {
defaults: [
"libart-compiler_static_base_defaults",
"libart-disassembler_static_defaults",
+ "libart-for-test_static_defaults",
"libartbase_static_defaults",
"libdexfile_static_defaults",
"libprofile_static_defaults",
@@ -363,13 +357,16 @@ cc_defaults {
whole_static_libs: ["libart-compiler-for-test"],
}
-art_cc_library_static {
+art_cc_library {
name: "libartd-compiler",
defaults: [
"art_debug_defaults",
"libart-compiler-defaults",
"libartd-compiler_deps",
],
+ shared_libs: [
+ "libartd",
+ ],
apex_available: [
"com.android.art.debug",
// TODO(b/183882457): This lib doesn't go into com.android.art, but
@@ -385,6 +382,7 @@ cc_defaults {
"libart-compiler_static_base_defaults",
"libartbased_static_defaults",
"libartd-disassembler_static_defaults",
+ "libartd_static_defaults",
"libdexfiled_static_defaults",
"libprofiled_static_defaults",
],
@@ -401,34 +399,19 @@ cc_defaults {
"libart-compiler_static_base_defaults",
"libartbased_static_defaults",
"libartd-disassembler_static_defaults",
+ "libartd-for-test_static_defaults",
"libdexfiled_static_defaults",
"libprofiled_static_defaults",
],
whole_static_libs: ["libartd-compiler"],
}
-// 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",
- "test_broken_com.android.art",
- ],
-}
-
// Properties common to `libart-compiler-gtest` and `libartd-compiler-gtest`.
art_cc_defaults {
name: "libart-compiler-gtest-common",
srcs: [
"common_compiler_test.cc",
],
- header_libs: [
- "libart_headers",
- ],
}
art_cc_library_static {
diff --git a/compiler/export/jit_create.h b/compiler/export/jit_create.h
deleted file mode 100644
index 53dd45ef93..0000000000
--- a/compiler/export/jit_create.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2023 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_CREATE_H_
-#define ART_COMPILER_EXPORT_JIT_CREATE_H_
-
-#include "base/macros.h"
-
-namespace art HIDDEN {
-namespace jit {
-
-class JitCompilerInterface;
-
-// Used in `libart-runtime` to create `libart-compiler` JIT.
-JitCompilerInterface* jit_create();
-
-} // namespace jit
-} // namespace art
-
-#endif // ART_COMPILER_EXPORT_JIT_CREATE_H_
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index 86c0f80974..e67236769e 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -17,6 +17,7 @@
#include "jit_compiler.h"
#include "android-base/stringprintf.h"
+
#include "arch/instruction_set.h"
#include "arch/instruction_set_features.h"
#include "art_method-inl.h"
@@ -28,7 +29,6 @@
#include "compiler.h"
#include "debug/elf_debug_writer.h"
#include "driver/compiler_options.h"
-#include "export/jit_create.h"
#include "jit/debugger_interface.h"
#include "jit/jit.h"
#include "jit/jit_code_cache.h"
@@ -125,7 +125,7 @@ void JitCompiler::ParseCompilerOptions() {
}
}
-JitCompilerInterface* jit_create() {
+EXPORT extern "C" JitCompilerInterface* jit_load() {
VLOG(jit) << "Create jit compiler";
auto* const jit_compiler = JitCompiler::Create();
CHECK(jit_compiler != nullptr);
diff --git a/compiler/libart-compiler.map b/compiler/libart-compiler.map
new file mode 100644
index 0000000000..f66052a329
--- /dev/null
+++ b/compiler/libart-compiler.map
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 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.
+#
+
+ART_COMPILER {
+ global:
+ extern "C++" {
+ art::debug::MakeMiniDebugInfo*;
+ *art::debug::WriteDebugInfo*;
+ art::Compiler::Create*;
+ art::CompilerOptions::*;
+ art::CreateTrampoline*;
+ art::IntrinsicObjects::*;
+ art::linker::operator*art::linker::LinkerPatch::Type*;
+ art::operator*art::Whence*;
+ };
+
+ jit_load;
+
+ local:
+ *;
+};
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index c2c0953044..bd33fde907 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -115,9 +115,7 @@ std::ostream& operator<<(std::ostream& os, const StringList& list) {
}
}
-// 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
+#ifndef ART_STATIC_LIBART_COMPILER
using create_disasm_prototype = Disassembler*(InstructionSet, DisassemblerOptions*);
#endif
@@ -127,7 +125,7 @@ class HGraphVisualizerDisassembler {
const uint8_t* base_address,
const uint8_t* end_address)
: instruction_set_(instruction_set), disassembler_(nullptr) {
-#ifdef ART_TARGET
+#ifndef ART_STATIC_LIBART_COMPILER
constexpr const char* libart_disassembler_so_name =
kIsDebugBuild ? "libartd-disassembler.so" : "libart-disassembler.so";
libart_disassembler_handle_ = dlopen(libart_disassembler_so_name, RTLD_NOW);
@@ -161,7 +159,7 @@ class HGraphVisualizerDisassembler {
~HGraphVisualizerDisassembler() {
// We need to call ~Disassembler() before we close the library.
disassembler_.reset();
-#ifdef ART_TARGET
+#ifndef ART_STATIC_LIBART_COMPILER
if (libart_disassembler_handle_ != nullptr) {
dlclose(libart_disassembler_handle_);
}
@@ -186,7 +184,7 @@ class HGraphVisualizerDisassembler {
InstructionSet instruction_set_;
std::unique_ptr<Disassembler> disassembler_;
-#ifdef ART_TARGET
+#ifndef ART_STATIC_LIBART_COMPILER
void* libart_disassembler_handle_;
#endif
};