Index: compiler-rt/CMakeLists.txt =================================================================== --- compiler-rt/CMakeLists.txt +++ compiler-rt/CMakeLists.txt @@ -304,6 +304,12 @@ # By default do not instrument or use profdata for compiler-rt. if(NOT COMPILER_RT_ENABLE_PGO) + if(LLVM_BUILD_INSTRUMENTED_COVERAGE) + string(REGEX REPLACE "-fprofile-instr-generate=\".*\"" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + string(REPLACE "-fcoverage-mapping" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) + string(REGEX REPLACE "-fprofile-instr-generate=\".*\"" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) + string(REPLACE "-fcoverage-mapping" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS}) + endif() if(LLVM_PROFDATA_FILE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-use") endif()