From 407468761d72c1031a871c18c29238135d9f0a88 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Tue, 29 Sep 2020 13:58:10 +0100 Subject: Link libart-disassembler statically into static libart-compiler. Necessary to avoid runtime dlopen of non-existing libart(d)-disassembler.so in host dex2oat. This increases the stripped dex2oat binary size by 4.8% or ~800 KB. Test: art/tools/buildbot-build.sh --host && \ art/test/testrunner/testrunner.py --optimizing --host --ndebug -t 465 with and without HOST_PREFER_32_BIT=true Bug: 145934348 Change-Id: I623019132175bd0430d30a421655484bdcb71857 --- compiler/optimizing/graph_visualizer.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/graph_visualizer.cc') diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index 3f6215a650..f9c63c4486 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -110,13 +110,17 @@ std::ostream& operator<<(std::ostream& os, const StringList& list) { } } +#ifndef ART_STATIC_LIBART_COMPILER using create_disasm_prototype = Disassembler*(InstructionSet, DisassemblerOptions*); +#endif + class HGraphVisualizerDisassembler { public: HGraphVisualizerDisassembler(InstructionSet instruction_set, const uint8_t* base_address, const uint8_t* end_address) : instruction_set_(instruction_set), disassembler_(nullptr) { +#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); @@ -132,10 +136,11 @@ class HGraphVisualizerDisassembler { << libart_disassembler_so_name << ": " << dlerror(); return; } +#endif // Reading the disassembly from 0x0 is easier, so we print relative // addresses. We will only disassemble the code once everything has // been generated, so we can read data in literal pools. - disassembler_ = std::unique_ptr((*create_disassembler)( + disassembler_ = std::unique_ptr(create_disassembler( instruction_set, new DisassemblerOptions(/* absolute_addresses= */ false, base_address, @@ -149,9 +154,11 @@ class HGraphVisualizerDisassembler { ~HGraphVisualizerDisassembler() { // We need to call ~Disassembler() before we close the library. disassembler_.reset(); +#ifndef ART_STATIC_LIBART_COMPILER if (libart_disassembler_handle_ != nullptr) { dlclose(libart_disassembler_handle_); } +#endif } void Disassemble(std::ostream& output, size_t start, size_t end) const { @@ -172,7 +179,9 @@ class HGraphVisualizerDisassembler { InstructionSet instruction_set_; std::unique_ptr disassembler_; +#ifndef ART_STATIC_LIBART_COMPILER void* libart_disassembler_handle_; +#endif }; -- cgit v1.2.3