pw_build_info: Better flag compatibility
Conditionally applies a GCC-only flag when building with gcc.
Change-Id: I22d8decbd780db89b3b07c6880ff4f46a185897f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/66784
Pigweed-Auto-Submit: Armando Montanez <amontanez@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
diff --git a/pw_build_info/build_id.cc b/pw_build_info/build_id.cc
index 7987667..d1e727f 100644
--- a/pw_build_info/build_id.cc
+++ b/pw_build_info/build_id.cc
@@ -33,6 +33,12 @@
} // namespace
+// Reading more than a uint8_t from gnu_build_id_begin triggers compiler
+// warnings that must be silenced.
+PW_MODIFY_DIAGNOSTICS_PUSH();
+PW_MODIFY_DIAGNOSTIC(ignored, "-Warray-bounds");
+PW_MODIFY_DIAGNOSTIC_GCC(ignored, "-Wstringop-overflow");
+
std::span<const std::byte> BuildId() {
// Read the sizes at the beginning of the note section.
ElfNoteInfo build_id_note_sizes;
@@ -46,4 +52,6 @@
build_id_note_sizes.descriptor_size));
}
+PW_MODIFY_DIAGNOSTICS_POP();
+
} // namespace pw::build_info