简体   繁体   中英

Android dex2oat build:ERROR: Dex2oat failed to compile a boot image

build Android 9.0

ERROR: Dex2oat failed to compile a boot image. The boot classpath is likely inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS=–runtime-arg -verbose: verifier to see verification errors.

when apply the below patch can reslove the dexoat,but still break build 99% and always waiting .

From a177377c4f206c7c4c5463158cf83af65fae17a9 Mon Sep 17 00:00:00 2001
Date: Wed, 3 Jul 2019 14:28:40 +0800
Subject: [PATCH] Revert "Use FdFile::Copy() in dex2oat for better error
 checking."

This reverts commit b55cc6df451e7653baf6f49dce1f2a0c03ba4bc6.
---
 dex2oat/dex2oat.cc | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index fe927bbc1c..974eaec711 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -2223,14 +2223,15 @@ class Dex2Oat FINAL {
         TimingLogger::ScopedTiming t("dex2oat OatFile copy", timings_);
         std::unique_ptr<File> in(OS::OpenFileForReading(oat_filenames_[i]));
         std::unique_ptr<File> out(OS::CreateEmptyFile(oat_unstripped_[i]));
-        int64_t in_length = in->GetLength();
-        if (in_length < 0) {
-          PLOG(ERROR) << "Failed to get the length of oat file: " << in->GetPath();
-          return false;
-        }
-        if (!out->Copy(in.get(), 0, in_length)) {
-          PLOG(ERROR) << "Failed to copy oat file to file: " << out->GetPath();
-          return false;
+        size_t buffer_size = 8192;
+        std::unique_ptr<uint8_t[]> buffer(new uint8_t[buffer_size]);
+        while (true) {
+          int bytes_read = TEMP_FAILURE_RETRY(read(in->Fd(), buffer.get(), buffer_size));
+          if (bytes_read <= 0) {
+            break;
+          }
+          bool write_ok = out->WriteFully(buffer.get(), bytes_read);
+          CHECK(write_ok);
         }
         if (out->FlushCloseOrErase() != 0) {
           PLOG(ERROR) << "Failed to flush and close copied oat file: " << oat_unstripped_[i];
-- 
2.19.1

现在我们使用以下解决方法 export WITH_DEXPREOPT=falsee 来禁用 dex2oat

just disable optimization for the sse4.2/popcount

in the file

./art/build/Android.bp

        host: {
        cflags: [
            // Bug: 15446488. We don't omit the frame pointer to work around
            // clang/libunwind bugs that cause SEGVs in run-test-004-ThreadStress.
            "-fno-omit-frame-pointer",
            // The build assumes that all our x86/x86_64 hosts (such as buildbots and developer
            // desktops) support at least sse4.2/popcount. This firstly implies that the ART
            // runtime binary itself may exploit these features. Secondly, this implies that
            // the ART runtime passes these feature flags to dex2oat and JIT by calling the
            // method InstructionSetFeatures::FromCppDefines(). Since invoking dex2oat directly
            // does not pick up these flags, cross-compiling from a x86/x86_64 host to a
            // x86/x86_64 target should not be affected.
            //"-msse4.2",
            //"-mpopcnt",
        ],
    },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM