This is an archive of the discontinued LLVM Phabricator instance.

[cmake] By default do not instrument compiler-rt if LLVM_BUILD_INSTRUMENTED_COVERAGE is ON
ClosedPublic

Authored by djtodoro on Aug 16 2021, 6:05 AM.

Details

Summary

I wasn't able to build all the LLVM projects when LLVM_BUILD_INSTRUMENTED_COVERAGE is set to ON since the compiler is finding some issues with unresolved symbols inside compiler-rt. If the compiler-rt isn't meant to be built with LLVM_BUILD_INSTRUMENTED_COVERAGE by default, I think that something like this makes sense.

Diff Detail

Event Timeline

djtodoro created this revision.Aug 16 2021, 6:05 AM
djtodoro requested review of this revision.Aug 16 2021, 6:05 AM
Herald added a subscriber: Restricted Project. · View Herald TranscriptAug 16 2021, 6:05 AM
vsk added inline comments.Aug 24 2021, 1:42 PM
compiler-rt/CMakeLists.txt
313

It looks like support for what you're trying to do might already exist. Could you share more context on COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG & COMPILER_RT_ENABLE_PGO, and why these are/aren't applicable for your workflow?

djtodoro added inline comments.Aug 25 2021, 8:19 AM
compiler-rt/CMakeLists.txt
313

Basically, I am facing similar problems as described in the D75499. That patch disabled PGO related flags for compiler-rt, but it applies to the LLVM_BUILD_INSTRUMENTED option only.
There is another instrumentation option LLVM_BUILD_INSTRUMENTED_COVERAGE (we cannot specify both LLVM_BUILD_INSTRUMENTED and LLVM_BUILD_INSTRUMENTED_COVERAGE) that includes -fcoverage-mapping in addition to -fprofile-instr-generate. I was wondering if we should do the same for this CMAKE option (I definitely need to add something like COMPILER_RT_HAS_FNO_CIVERAGE_MAPPING_FLAG, and to cover all other spots in CMake files, etc).

djtodoro updated this revision to Diff 368662.Aug 25 2021, 9:05 AM
  • follow the LLVM_BUILD_INSTRUMENTED approach of disabling PGO flags
djtodoro updated this revision to Diff 368818.Aug 25 2021, 11:44 PM
  • nit: fixing an elsif()

Ping. :)

This is very similar to D75499. The patch disabled PGO related flags for compiler-rt in the case of LLVM_BUILD_INSTRUMENTED.
There is another instrumentation option LLVM_BUILD_INSTRUMENTED_COVERAGE which should have been addressed as well.

vitalybuka resigned from this revision.Oct 20 2021, 10:43 AM
vitalybuka added a subscriber: MaskRay.

Ping. :)

This is very similar to D75499. The patch disabled PGO related flags for compiler-rt in the case of LLVM_BUILD_INSTRUMENTED.
There is another instrumentation option LLVM_BUILD_INSTRUMENTED_COVERAGE which should have been addressed as well.

Does @xur have an opinion on this? I don't have one here.
Maybe @petrhosek @MaskRay ?

Can you combine the conditions? Maybe looks like:

(LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG

Can you combine the conditions? Maybe looks like:

(LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE) AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG

@MaskRay thanks for your comment, it makes sense to me.

djtodoro updated this revision to Diff 385460.Nov 8 2021, 5:10 AM
  • addressing the comment
MaskRay accepted this revision.Nov 8 2021, 1:22 PM

Thanks!

This revision is now accepted and ready to land.Nov 8 2021, 1:22 PM
This revision was landed with ongoing or failed builds.Nov 9 2021, 2:00 AM
This revision was automatically updated to reflect the committed changes.