[libcxx-commits] [libcxx] [libc++] Remove unmaintained support for generating code coverage (PR #100630)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 25 11:50:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Louis Dionne (ldionne)
<details>
<summary>Changes</summary>
This patch removes support for generating code coverage information of libc++, which is unmaintained and I've never been able to utilize. It would be great to have support for generating code coverage in the test suite, however this incarnation of it doesn't seem to be properly hooked up into the test suite. Since it gets in the way of making the test suite more standalone, remove it.
---
Full diff: https://github.com/llvm/llvm-project/pull/100630.diff
4 Files Affected:
- (modified) libcxx/CMakeLists.txt (-16)
- (removed) libcxx/cmake/Modules/CodeCoverage.cmake (-50)
- (modified) libcxx/src/CMakeLists.txt (-5)
- (modified) libcxx/test/CMakeLists.txt (-12)
``````````diff
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 917c6becb7835..08406076236e9 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -310,10 +310,6 @@ endif()
option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF)
option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
-option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF)
-set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING
- "The Profile-rt library used to build with code coverage")
-
set(LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT OFF)
if (WIN32)
set(LIBCXX_HERMETIC_STATIC_LIBRARY_DEFAULT ON)
@@ -376,12 +372,6 @@ if (NOT LIBCXX_ENABLE_RTTI AND LIBCXX_ENABLE_EXCEPTIONS)
" for details.")
endif()
-# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE
-# is ON.
-if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE)
- message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE")
-endif()
-
if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
if (APPLE)
message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets")
@@ -490,12 +480,6 @@ endif()
# Configure compiler.
include(config-ix)
-# Configure coverage options.
-if (LIBCXX_GENERATE_COVERAGE)
- include(CodeCoverage)
- set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE)
-endif()
-
#===============================================================================
# Setup Compiler Flags
#===============================================================================
diff --git a/libcxx/cmake/Modules/CodeCoverage.cmake b/libcxx/cmake/Modules/CodeCoverage.cmake
deleted file mode 100644
index 1bd3a786812a5..0000000000000
--- a/libcxx/cmake/Modules/CodeCoverage.cmake
+++ /dev/null
@@ -1,50 +0,0 @@
-find_program(CODE_COVERAGE_LCOV lcov)
-if (NOT CODE_COVERAGE_LCOV)
- message(FATAL_ERROR "Cannot find lcov...")
-endif()
-
-find_program(CODE_COVERAGE_LLVM_COV llvm-cov)
-if (NOT CODE_COVERAGE_LLVM_COV)
- message(FATAL_ERROR "Cannot find llvm-cov...")
-endif()
-
-find_program(CODE_COVERAGE_GENHTML genhtml)
-if (NOT CODE_COVERAGE_GENHTML)
- message(FATAL_ERROR "Cannot find genhtml...")
-endif()
-
-set(CMAKE_CXX_FLAGS_COVERAGE "-g -O0 --coverage")
-
-function(setup_lcov_test_target_coverage target_name output_dir capture_dirs source_dirs)
- if (NOT DEFINED LIBCXX_BINARY_DIR)
- message(FATAL_ERROR "Variable must be set")
- endif()
-
- set(GCOV_TOOL "${LIBCXX_BINARY_DIR}/llvm-cov-wrapper")
- file(GENERATE OUTPUT ${GCOV_TOOL}
- CONTENT "#!/usr/bin/env bash\n${CODE_COVERAGE_LLVM_COV} gcov \"$@\"\n")
-
- file(MAKE_DIRECTORY ${output_dir})
-
- set(CAPTURE_DIRS "")
- foreach(cdir ${capture_dirs})
- list(APPEND CAPTURE_DIRS "-d;${cdir}")
- endforeach()
-
- set(EXTRACT_DIRS "")
- foreach(sdir ${source_dirs})
- list(APPEND EXTRACT_DIRS "'${sdir}/*'")
- endforeach()
-
- message(STATUS "Capture Directories: ${CAPTURE_DIRS}")
- message(STATUS "Extract Directories: ${EXTRACT_DIRS}")
-
- add_custom_target(generate-lib${target_name}-coverage
- COMMAND chmod +x ${GCOV_TOOL}
- COMMAND ${CODE_COVERAGE_LCOV} --gcov-tool ${GCOV_TOOL} --capture ${CAPTURE_DIRS} -o test_coverage.info
- COMMAND ${CODE_COVERAGE_LCOV} --gcov-tool ${GCOV_TOOL} --extract test_coverage.info ${EXTRACT_DIRS} -o test_coverage.info
- COMMAND ${CODE_COVERAGE_GENHTML} --demangle-cpp test_coverage.info -o test_coverage
- COMMAND ${CMAKE_COMMAND} -E remove test_coverage.info
- WORKING_DIRECTORY ${output_dir}
- COMMENT "Generating coverage results")
-endfunction()
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index bfc88c4c58812..fe9d2666fa4ca 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -147,11 +147,6 @@ if(NOT LIBCXX_INSTALL_LIBRARY)
set(exclude_from_all EXCLUDE_FROM_ALL)
endif()
-if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
- find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY)
-endif()
-add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
-
if (APPLE AND LLVM_USE_SANITIZER)
if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 001b29efcfefa..f8e186c59150a 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -49,15 +49,3 @@ add_lit_testsuite(check-cxx
"Running libcxx tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS cxx-test-depends)
-
-if (LIBCXX_GENERATE_COVERAGE)
- include(CodeCoverage)
- set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage")
- set(capture_dirs
- "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_objects.dir/"
- "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/"
- "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx_experimental.dir/"
- "${CMAKE_CURRENT_BINARY_DIR}")
- set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
- setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
-endif()
``````````
</details>
https://github.com/llvm/llvm-project/pull/100630
More information about the libcxx-commits
mailing list