Index: compiler-rt/CMakeLists.txt =================================================================== --- compiler-rt/CMakeLists.txt +++ compiler-rt/CMakeLists.txt @@ -312,6 +312,12 @@ elseif(LLVM_BUILD_INSTRUMENTED AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-generate") endif() + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) + list(APPEND SANITIZER_COMMON_CFLAGS "-fno-profile-instr-generate") + endif() + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) + list(APPEND SANITIZER_COMMON_CFLAGS "-fno-coverage-mapping") + endif() endif() # The following is a workaround for powerpc64le. This is the only architecture Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake =================================================================== --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -191,6 +191,11 @@ elseif(LLVM_BUILD_INSTRUMENTED AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) list(APPEND NO_PGO_FLAGS "-fno-profile-instr-generate") endif() + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) + list(APPEND NO_PGO_FLAGS "-fno-profile-instr-generate") + elseif(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) + list(APPEND NO_PGO_FLAGS "-fno-coverage-mapping") + endif() endif() list(LENGTH LIB_SOURCES LIB_SOURCES_LENGTH) Index: compiler-rt/cmake/config-ix.cmake =================================================================== --- compiler-rt/cmake/config-ix.cmake +++ compiler-rt/cmake/config-ix.cmake @@ -80,6 +80,7 @@ check_cxx_compiler_flag(-fno-profile-generate COMPILER_RT_HAS_FNO_PROFILE_GENERATE_FLAG) check_cxx_compiler_flag(-fno-profile-instr-generate COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) check_cxx_compiler_flag(-fno-profile-instr-use COMPILER_RT_HAS_FNO_PROFILE_INSTR_USE_FLAG) +check_cxx_compiler_flag(-fno-coverage-mapping COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) check_cxx_compiler_flag("-Werror -msse3" COMPILER_RT_HAS_MSSE3_FLAG) check_cxx_compiler_flag("-Werror -msse4.2" COMPILER_RT_HAS_MSSE4_2_FLAG) check_cxx_compiler_flag(--sysroot=. COMPILER_RT_HAS_SYSROOT_FLAG) Index: compiler-rt/lib/crt/CMakeLists.txt =================================================================== --- compiler-rt/lib/crt/CMakeLists.txt +++ compiler-rt/lib/crt/CMakeLists.txt @@ -29,6 +29,12 @@ elseif(LLVM_BUILD_INSTRUMENTED AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) list(APPEND try_compile_flags "-fno-profile-instr-generate") endif() + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_PROFILE_INSTR_GENERATE_FLAG) + list(APPEND try_compile_flags "-fno-profile-instr-generate") + endif() + if(LLVM_BUILD_INSTRUMENTED_COVERAGE AND COMPILER_RT_HAS_FNO_COVERAGE_MAPPING_FLAG) + list(APPEND try_compile_flags "-fno-coverage-mapping") + endif() endif() string(REPLACE ";" " " extra_flags "${try_compile_flags}")