Generate SHA-1 build ID for host-generated *.oat files (1/2).

For host-generated *.oat files, generate a SHA-1 build ID based on the
file content and write it to .note.gnu.build-id ELF section.  This
should allow various developer tools like profilers correlate the data
captured for files like boot.oat on the device with the corresponding
known version of the file during an offline analysis.

Test: Verified that boot.oat contains the build ID section now (with
      this change and https://android-review.googlesource.com/#/c/275630
      applied)
Test: Added ElfWriterTest::CheckBuildIdPresent test.
Test: make test-art-host
Bug: 31292208
Change-Id: Ie5e89da2ef87e34c27c0237ab34ddc7d2dc0aa3b
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index cbcc169..c222f90 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -37,6 +37,7 @@
       debuggable_(false),
       generate_debug_info_(kDefaultGenerateDebugInfo),
       generate_mini_debug_info_(kDefaultGenerateMiniDebugInfo),
+      generate_build_id_(false),
       implicit_null_checks_(true),
       implicit_so_checks_(true),
       implicit_suspend_checks_(false),
@@ -97,6 +98,7 @@
       debuggable_(debuggable),
       generate_debug_info_(generate_debug_info),
       generate_mini_debug_info_(kDefaultGenerateMiniDebugInfo),
+      generate_build_id_(false),
       implicit_null_checks_(implicit_null_checks),
       implicit_so_checks_(implicit_so_checks),
       implicit_suspend_checks_(implicit_suspend_checks),
@@ -196,6 +198,10 @@
     generate_mini_debug_info_ = true;
   } else if (option == "--no-generate-mini-debug-info") {
     generate_mini_debug_info_ = false;
+  } else if (option == "--generate-build-id") {
+    generate_build_id_ = true;
+  } else if (option == "--no-generate-build-id") {
+    generate_build_id_ = false;
   } else if (option == "--debuggable") {
     debuggable_ = true;
   } else if (option.starts_with("--top-k-profile-threshold=")) {