I think what I’m facing here is actually the same issue as reported in [llvm-cov] Hash mismatches originating from class methods implemented in header files - #7 by Aleksa_Markovic. It’s just difficult to connect the dots, because a lot of details are hidden by Bazel build system in my cases.
I tried to use -femit-all-decls
, but it causes other build failures and it would not be the ideal solution anyways, as it makes compiler do more work than necessary.
Other options that I verified and they worked for me:
- Get rid of dynamic libraries when running coverage and build everything statically
- Move methods from headers to *.cc files, where possible
- Apply
used
annotation to the affected functions
While those methods above worked for me, they are also not great for a large code base. I posted a question on a related LLVM bug: "Mismatched function data" warnings when collecting profiles for clang · Issue #32849 · llvm/llvm-project · GitHub, but all-in-all there does not seem to be a satisfactory solution for this at the moment.