Skip to content

Add Clang coverage pass integrated with test build flow#2

Draft
ggeier wants to merge 2 commits into
mainfrom
codex/integrate-coverage-report-generation
Draft

Add Clang coverage pass integrated with test build flow#2
ggeier wants to merge 2 commits into
mainfrom
codex/integrate-coverage-report-generation

Conversation

@ggeier

@ggeier ggeier commented Mar 5, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Provide an opt-in way to generate Clang/LLVM coverage from the project's test suite and export LCOV output for CI and local analysis.
  • Keep the instrumentation opt-in and guarded to avoid affecting regular builds and to require a Clang toolchain when enabled.

Description

  • Add a new CMake option COLDTRACE_ENABLE_COVERAGE to enable Clang coverage instrumentation and enforce Clang when enabled, and disable IPO while coverage is active.
  • When enabled, add compiler/link flags -fprofile-instr-generate and -fcoverage-mapping, and wire llvm-profdata/llvm-cov usage to generate reports.
  • Collect test executable targets into a global property COLDTRACE_TEST_TARGETS in test/CMakeLists.txt and use that list to build coverage object lists for reporting.
  • Add a coverage custom target that runs the test suite via ctest with LLVM_PROFILE_FILE, merges profiles via llvm-profdata, emits a summary via llvm-cov report, and exports LCOV to coverage/coverage.lcov, and document usage in README.md.

Testing

  • Ran configuration with cmake -S . -B build-coverage -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCOLDTRACE_ENABLE_COVERAGE=ON, which configured successfully.
  • Attempted to build the coverage target with cmake --build build-coverage --target coverage -j4, which failed during linking in this environment due to Swift/Clang TSAN runtime / libdispatch linker incompatibilities unrelated to the coverage wiring; the failure prevented completing runtime test execution and profile merging.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant