Skip to content

bazel: add code coverage build option - #3716

Open
napetrov wants to merge 4 commits into
mainfrom
issue3530-code-coverage
Open

bazel: add code coverage build option#3716
napetrov wants to merge 4 commits into
mainfrom
issue3530-code-coverage

Conversation

@napetrov

Copy link
Copy Markdown
Contributor

Description

Add a typed Bazel --code_coverage=true option corresponding to Make CODE_COVERAGE=yes for supported Linux Intel compiler builds.

This is a focused Make-to-Bazel option-parity improvement toward #3530. The option is disabled by default and does not instrument external dependencies.

What changed

  • add the typed boolean --code_coverage=true interface
  • apply Make-compatible host compile/link coverage options only to oneDAL-owned actions
  • scope GCOV_BUILD to Make CORE.objs_a/y-equivalent DAAL modules
  • keep separately built threading, oneAPI DAL, DPC++, tests, examples, and tools outside the GCOV_BUILD define scope
  • use -Xscoverage for DPC++ link actions while leaving DPC++ compilation unchanged
  • preserve coverage runtime linkage for instrumented executable/test actions
  • reject unsupported OS/compiler selections clearly
  • document the action-level mapping and add a bounded GCC negative smoke to CI

Validation

Validated on Linux before push; pushed exact head is d7002469af09b3f84cab54af2d57ed5df9f032c3 (the final two changes after validation were comment/table-whitespace only).

Focused action matrix

ICX/DPC++ Bazel aquery checks verified:

  • DAAL core compile: GCOV_BUILD and -coverage
  • threading compile: -coverage, no GCOV_BUILD
  • oneAPI host compile: -coverage, no GCOV_BUILD
  • DPC++ compile: neither -coverage nor GCOV_BUILD
  • host module/final/executable/test links: -coverage
  • DPC++ links: -Xscoverage
  • static archives: no coverage linker option
  • default-off actions: no coverage tokens
  • no coverage flags leaked into external dependency actions

Build/test proof

CC=icx CXX=icpx bazelisk test \
  //cpp/daal/src/algorithms/dtrees/gbt/regression:test_gbt_regression_model_builder_unit_host \
  --code_coverage=true --cpu=sse2 --jobs=2 --test_output=errors

Result: 1/1 passed. The run produced 152 .gcda files.

CC=icx CXX=icpx bazelisk build \
  //cpp/oneapi/dal/table:table_dpc \
  --code_coverage=true --release_dpc=true --cpu=sse2 --jobs=2

Result: passed with the real DPC++ module link using -Xscoverage.

GCC selection was also verified to fail analysis with the intended diagnostic. CI YAML parse, git diff --check, and git show --check passed.

Scope notes

Make enables this mode only for CODE_COVERAGE=yes on Linux. Bazel is stricter: unsupported targets/compiler selections fail clearly instead of silently disabling coverage. Static archive actions remain flag-free; final executable/test links receive the coverage driver option needed to resolve the runtime from instrumented objects.

Review

Independent final review: APPROVE. Two documentation-only suggestions were applied before push.


Checklist

  • Changes reviewed locally
  • Documentation updated
  • Commits include Signed-off-by
  • Focused ICX host and DPC++ build/test validation completed
  • Default behavior unchanged
  • Unsupported selections fail clearly
  • No production performance effect unless explicitly enabled

Ubuntu added 2 commits July 24, 2026 09:03
Signed-off-by: Ubuntu <ubuntu@ip-172-31-3-43.ec2.internal>
Signed-off-by: Ubuntu <ubuntu@ip-172-31-3-43.ec2.internal>
@napetrov
napetrov marked this pull request as ready for review July 26, 2026 11:58
Copilot AI review requested due to automatic review settings July 26, 2026 11:58
The existing CI smoke check only exercised the rejection path (GCC
host compiler). Add dev/bazel/tests/code_coverage_test.sh, run on the
icx toolchain, which builds DAAL core and the separately built
threading module with --code_coverage=true and inspects bazel aquery
output to confirm the Make-equivalent -coverage/-DGCOV_BUILD flags are
actually applied where documented, and only there.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Bazel-typed --code_coverage=true build option to mirror Make’s CODE_COVERAGE=yes for supported Linux ICX builds, applying coverage instrumentation in an action-local way (oneDAL-owned actions only) and documenting/validating the mapping in CI.

Changes:

  • Introduce a new typed Bazel flag (@config//:code_coverage) with a .bazelrc alias --code_coverage.
  • Add action-local coverage compile/link flags for oneDAL rules, with GCOV_BUILD scoped to DAAL core modules and a DPC++ link-mode mapping (-Xscoverage).
  • Document behavior and add CI smoke tests (negative GCC rejection + positive ICX aquery-based verification).

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
INSTALL.md Documents Bazel equivalent of Make coverage mode and its scoping rules.
dev/bazel/tests/code_coverage_test.sh Adds an ICX positive-path smoke that validates action flags via bazel aquery.
dev/bazel/tests/BUILD Exports the new coverage smoke script.
dev/bazel/README.md Documents the Make→Bazel mapping and the action-level coverage behavior table.
dev/bazel/daal.bzl Adds define_gcov_build plumbing so DAAL modules can opt into GCOV_BUILD under coverage.
dev/bazel/config/config.tpl.BUILD Introduces the typed boolean build setting code_coverage.
dev/bazel/cc.bzl Implements coverage flag injection for compile/link actions and prevents transitive leakage.
cpp/daal/BUILD Explicitly disables GCOV_BUILD for the separately built DAAL threading module.
.ci/pipeline/ci.yml Adds GCC rejection smoke and ICX positive coverage smoke build to CI.
.bazelrc Adds a --flag_alias for code_coverage.

Comment thread dev/bazel/cc.bzl
Comment on lines +118 to +128
linker_inputs.append(cc_common.create_linker_input(
owner = linker_input.owner,
libraries = depset(linker_input.libraries),
user_link_flags = [
flag
for flag in linker_input.user_link_flags
if flag not in coverage_link_flags
],
additional_inputs = depset(linker_input.additional_inputs),
linkstamps = depset(linker_input.linkstamps),
))
Comment thread .ci/pipeline/ci.yml
displayName: 'install opencl'
- script: |
.ci/env/apt.sh dpcpp
displayName: 'dpcpp installation'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this actually get used if the public CI jobs are not running anything with GPUs?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants