Skip to content

scope: a cc_binary executable is the baseline object of its sources - #44

Merged
AlexanderLanin merged 2 commits into
mainfrom
dcalavrezo_cc_binary_baseline
Oct 16, 2026
Merged

AlexanderLanin merged 2 commits into
mainfrom
dcalavrezo_cc_binary_baseline

Conversation

@dcalavrezo-qorix

Copy link
Copy Markdown
Contributor

Closes #40.

Why

A cc_binary links its own translation units straight into the executable; they sit in no archive. The aspect took the zero-coverage baseline objects from the .a archives in CcInfo only, so an untested binary's own sources (lifecycle's launch_manager main.cpp) had no object carrying their mapping: absent from the report, listed in unmapped_files.txt as no-data. Library sources were never affected.

Changes

  • coverage_scope.bzl: for a cc_binary, the coverage-built executable joins the baseline objects, as already done for rust_binary. The reporter passes all baseline objects to one llvm-cov --empty-profile call, which merges a file seen in both the executable and an archive, so no duplicate rows.
  • Analysis test test_cc_binary_collects_main_and_executable (fixture cbin); 18 analysis tests.
  • End-to-end workspace: untested cc_binary //src:tool in the scope; main.cpp checked at exact 0 % on both backends; hand-derived golden records (LLVM: brace line through closing brace; gcov: signature and statement lines), cross-checked with GCC 12.2's gcov on the gcno.
  • Found on the way: the scope's .gcno baseline notes are built in the exec configuration, which takes the host options, so GCC optimised them and folded return 0 into the entry line. --host_cxxopt=-O0 added to the consumer gcov config and documented in step 4b; the LLVM backend is unaffected (front-end mapping). baselibs' QNX config should get the same line.
  • Manual section "Binaries in the scope", release notes 0.4.2, verification report counts.

Validation

bazel test //tests/unit/...: 26 pass. tests/end_to_end/run_end_to_end_test.sh: 25 checks pass, LLVM and gcov goldens match.

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
2026/10/16 14:13:00 Downloading https://releases.bazel.build/8.6.0/release/bazel-8.6.0-linux-x86_64...
Extracting Bazel installation...
Starting local Bazel server (8.6.0) and connecting to it...
INFO: Invocation ID: 9a270c9f-57d2-4655-9291-852e8f0ebfa2
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Loading: 0 packages loaded
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)
Analyzing: target //:license-check (1 packages loaded, 0 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (5 packages loaded, 6 targets configured)

Analyzing: target //:license-check (65 packages loaded, 10 targets configured)

Analyzing: target //:license-check (86 packages loaded, 10 targets configured)

Analyzing: target //:license-check (143 packages loaded, 836 targets configured)

Analyzing: target //:license-check (151 packages loaded, 3277 targets configured)

Analyzing: target //:license-check (151 packages loaded, 3277 targets configured)

Analyzing: target //:license-check (151 packages loaded, 3277 targets configured)

Analyzing: target //:license-check (161 packages loaded, 8659 targets configured)

Analyzing: target //:license-check (163 packages loaded, 9766 targets configured)

Analyzing: target //:license-check (163 packages loaded, 9766 targets configured)

Analyzing: target //:license-check (167 packages loaded, 9792 targets configured)

Analyzing: target //:license-check (167 packages loaded, 9792 targets configured)

Analyzing: target //:license-check (176 packages loaded, 11707 targets configured)

Analyzing: target //:license-check (176 packages loaded, 11712 targets configured)

Analyzing: target //:license-check (177 packages loaded, 11828 targets configured)

INFO: Analyzed target //:license-check (179 packages loaded, 12076 targets configured).
[9 / 16] checking cached actions
[15 / 16] [Prepa] Building tools/license.check.license_check.jar ()
INFO: Found 1 target...
Target //tools:license.check.license_check up-to-date:
  bazel-bin/tools/license.check.license_check
  bazel-bin/tools/license.check.license_check.jar
INFO: Elapsed time: 37.370s, Critical Path: 2.22s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/tools/license.check.license_check tools/formatted.txt <args omitted>
usage: org.eclipse.dash.licenses.cli.Main [-batch <int>] [-cd <url>]
       [-confidence <int>] [-ef <url>] [-excludeSources <sources>] [-help] [-lic
       <url>] [-project <shortname>] [-repo <url>] [-review] [-summary <file>]
       [-timeout <seconds>] [-token <token>]

@dcalavrezo-qorix dcalavrezo-qorix changed the title scope: the executable of a cc_binary is the baseline object of its sources scope: a cc_binary executable is the baseline object of its sources Oct 16, 2026
@dcalavrezo-qorix
dcalavrezo-qorix force-pushed the dcalavrezo_cc_binary_baseline branch from b3b5398 to 754b117 Compare October 16, 2026 10:28
A cc_binary links its own translation units straight into the executable;
they sit in no archive, so an untested main.cpp had no object carrying its
coverage mapping, was absent from the report and listed as no-data in
unmapped_files.txt (lifecycle launch_manager, #40). The aspect now adds the
coverage-built executable to the baseline objects, as it does for
rust_binary.

The gcov baseline notes of untested files are built in the exec
configuration and take the host options; the consumer config gains
--host_cxxopt=-O0 next to --cxxopt=-O0 so their line tables match the test
builds (GCC folds a constant return into the entry line when optimising).

Analysis test for the executable in the objects manifest; the end-to-end
workspace gets an untested cc_binary whose main.cpp is checked at exact 0 %
on both backends (hand-derived goldens, cross-checked with gcov on the
gcno). Manual, release notes 0.4.2, verification report counts.

Closes #40

Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com>
@dcalavrezo-qorix
dcalavrezo-qorix force-pushed the dcalavrezo_cc_binary_baseline branch from 754b117 to 6dce2fe Compare October 16, 2026 10:39
@dcalavrezo-qorix

Copy link
Copy Markdown
Contributor Author

Validated on lifecycle with this branch via git_override (eclipse-score/lifecycle#804, draft, do not merge). Linux coverage job, run 38887734269:

SF:score/launch_manager/src/daemon/src/main.cpp
DA:17,0
DA:18,0
DA:19,0
LF:3
LH:0

main.cpp is in the report at 0 % and gone from unmapped_files.txt (no-data 31 → 30, declaration-only 18 unchanged). The override pins 754b117, which differs from the current head only by the black-box test marker update.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-44: https://eclipse-score.github.io/coverage_tool/pr-44/

The HTML came from one llvm-cov show over the test binaries plus the
baseline objects with the merged test profile. An executable among the
baseline objects carries a main like every test binary: with the same
structural hash llvm-cov attributed a test's counts to it (lifecycle's
untested main.cpp at 100 %), with a different hash it dropped the file
(no row in the end-to-end index). The LCOV was right, it already took
baseline-only files from a separate --empty-profile run.

The HTML now does the same: baseline-only files are rendered with
--empty-profile over the baseline objects, their pages and index rows are
spliced into the report, and the Totals row the effective-coverage gate
reads is recomputed over all rows. Unit tests for the splice; end-to-end
checks of the index rows of the untested C++ sources, the binary's main.cpp
and the Rust binary's main.rs at 0 %.

Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused baseline and HTML changes have supporting regression coverage, with no unresolved review findings.

0 open findings

What changed in this PR

Fixes #40 by including untested cc_binary sources in coverage reports at 0%, rather than leaving them unmapped.

Changes:

  • Collects binary executables as baseline coverage objects.
  • Renders baseline-only HTML separately, merging pages and recalculating index totals.
  • Adds regression coverage, gcov host compilation settings, and documentation.
File Description
tests/​unit/​starlark/​fixtures/​BUILD Adds a C++ binary fixture.
tests/​unit/​starlark/​fixtures/​bin_main.cpp Supplies the fixture entry point.
tests/​unit/​starlark/​coverage_scope_tests.bzl Checks binary sources and executable collection.
tests/​unit/​score_coverage/​reporter_test.py Tests HTML merging and totals.
tests/​end_to_end/​testcases/​test_summary.py Checks the additional zero-coverage source.
tests/​end_to_end/​run_end_to_end_test.sh Checks binary coverage and HTML rows.
tests/​end_to_end/​expected/​expected_lcov.dat Adds LLVM baseline expectations.
tests/​end_to_end/​expected/​expected_lcov_gcov.dat Adds gcov baseline expectations.
tests/​end_to_end/​consumer/​tools/​coverage/​BUILD Includes the untested binary in scope.
tests/​end_to_end/​consumer/​src/​main.cpp Adds an untested entry point.
tests/​end_to_end/​consumer/​src/​BUILD Defines the consumer binary.
tests/​end_to_end/​consumer/​.bazelrc Disables host C++ optimization for gcov.
score_coverage/​reporter.py Separately renders and merges baseline HTML.
score_coverage/​coverage_scope.bzl Collects C++ executables as baseline objects.
docs/​verification/​verification_report.rst Updates test inventory counts.
docs/​release/​release_notes.rst Documents the fix and integration settings.
docs/​manual/​user_manual.rst Explains binary scope handling and gcov settings.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AlexanderLanin
AlexanderLanin merged commit 5035813 into main Oct 16, 2026
12 checks passed
@AlexanderLanin
AlexanderLanin deleted the dcalavrezo_cc_binary_baseline branch October 16, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

main function missing in coverage report

3 participants