Also create VerifierDeps for boot image compilation.

It used to be that ART ensured all code in the boot classpath was fully
verified. Now that we have mainline, we cannot guarantee this at
compile-time. Therefore make boot image compilation also use
VerifierDeps.

Test: test.py
Change-Id: I414de823fe79a6637679550cdb16c1b28f397ed2
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index caf8753..2a0a6a9 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -1746,16 +1746,16 @@
   }
 
   // If there is no existing `verifier_deps` (because of non-existing vdex), or
-  // the existing `verifier_deps` is not valid anymore, create a new one for
-  // non boot image compilation. The verifier will need it to record the new dependencies.
-  // Then dex2oat can update the vdex file with these new dependencies.
-  if (!GetCompilerOptions().IsBootImage() && !GetCompilerOptions().IsBootImageExtension()) {
-    // Dex2oat creates the verifier deps.
-    // Create the main VerifierDeps, and set it to this thread.
-    verifier::VerifierDeps* verifier_deps =
-        Runtime::Current()->GetCompilerCallbacks()->GetVerifierDeps();
-    CHECK(verifier_deps != nullptr);
-    Thread::Current()->SetVerifierDeps(verifier_deps);
+  // the existing `verifier_deps` is not valid anymore, create a new one. The
+  // verifier will need it to record the new dependencies. Then dex2oat can update
+  // the vdex file with these new dependencies.
+  // Dex2oat creates the verifier deps.
+  // Create the main VerifierDeps, and set it to this thread.
+  verifier::VerifierDeps* main_verifier_deps =
+      Runtime::Current()->GetCompilerCallbacks()->GetVerifierDeps();
+  // Verifier deps can be null when unit testing.
+  if (main_verifier_deps != nullptr) {
+    Thread::Current()->SetVerifierDeps(main_verifier_deps);
     // Create per-thread VerifierDeps to avoid contention on the main one.
     // We will merge them after verification.
     for (ThreadPoolWorker* worker : parallel_thread_pool_->GetWorkers()) {
@@ -1779,14 +1779,13 @@
                   timings);
   }
 
-  if (!GetCompilerOptions().IsBootImage() && !GetCompilerOptions().IsBootImageExtension()) {
+  if (main_verifier_deps != nullptr) {
     // Merge all VerifierDeps into the main one.
-    verifier::VerifierDeps* verifier_deps = Thread::Current()->GetVerifierDeps();
     for (ThreadPoolWorker* worker : parallel_thread_pool_->GetWorkers()) {
       std::unique_ptr<verifier::VerifierDeps> thread_deps(worker->GetThread()->GetVerifierDeps());
       worker->GetThread()->SetVerifierDeps(nullptr);  // We just took ownership.
-      verifier_deps->MergeWith(std::move(thread_deps),
-                               GetCompilerOptions().GetDexFilesForOatFile());
+      main_verifier_deps->MergeWith(std::move(thread_deps),
+                                    GetCompilerOptions().GetDexFilesForOatFile());
     }
     Thread::Current()->SetVerifierDeps(nullptr);
   }
diff --git a/runtime/common_runtime_test.cc b/runtime/common_runtime_test.cc
index d7c77e8..e8c8385 100644
--- a/runtime/common_runtime_test.cc
+++ b/runtime/common_runtime_test.cc
@@ -460,6 +460,7 @@
     "-Xmx64m",
     "--runtime-arg",
     "-Xverify:softfail",
+    "--force-determinism",
   };
   CHECK_EQ(dex_files.size(), dex_locations.size());
   for (const std::string& dex_file : dex_files) {