Skip to content

exp(cov): GCC JIT gcov + Codecov mapping via c_runtime_cov.h - #49

Merged
esrrhs merged 4 commits into
masterfrom
exp/jit-gcc-coverage
Nov 3, 2026
Merged

esrrhs merged 4 commits into
masterfrom
exp/jit-gcc-coverage

Conversation

@esrrhs

@esrrhs esrrhs commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Summary

Re-applies the wiped #47 coverage work onto current master (a6fe459, which already includes #48). The old PR had been merged, then disappeared when master was force-updated; this branch cherry-picks only the coverage commits (with #48 conflict resolutions preserved).

Enable usable Codecov signal for GCC JIT-emitted runtime C under USE_COV.

Changes

  1. GCC JIT gcov (USE_COV) — When coverage is on, pass -fprofile-arcs / -ftest-coverage / --coverage into the GCC JIT compile/link of generated C, place temps under build/jit_cov, use a two-step .c→.o→.so so .gcno/.gcda stay harvestable, and keep the .c after unload for lcov. TCC path unchanged.
  2. CI extract includes jit_cov — After one lcov --directory build capture, --extract keeps src/*, include/*, and build/jit_cov/* so JIT hits are not dropped before Codecov upload. Adds --ignore-errors inconsistent for #line → .lua end-line noise.
  3. View header + #line mapping — Codecov cannot usefully browse build/jit_cov/fakelua_jit_*.c. Add checked-in src/compile/c_runtime_cov.h (byte-identical view of kCRuntimeHeader) and wrap the paste with #line 1 \"src/compile/c_runtime_cov.h\" so Fl* runtime hits map to an in-repo src/ path. Reset to <fakelua-generated> afterward so preamble / #line→.lua stay unchanged.
  4. Sync test — Unit test asserts the view file stays byte-identical to the raw-string body (kCRuntimeHeader remains the compile-time source of truth).
  5. cppcheck / CVar.flag_ — Exclude the Codecov twin from cppcheck; initialize key CVar.flag_ = 0 while keeping master's UNLIKELY (perf(jit): optimize loop advance, closure call, condition comparisons and itoa #48) behavior.

Caveats

  • TCC still blind — TCC JIT is not instrumented; only GCC JIT contributes coverage under USE_COV.
  • Local coverage — Full local cov on c_runtime_cov.h is ~87.8% in the measured run; residual gaps are expected for cold error/edge paths.
  • build/jit_cov and coverage.info remain gitignored artifacts — not committed.

Commits

  • 15f9a8e exp: instrument GCC JIT emitted C with gcov when USE_COV
  • 62197d7 ci(cov): include build/jit_cov GCC JIT temps in Codecov upload
  • bd90271 exp(cov): map GCC JIT Fl* runtime hits onto checked-in c_runtime_cov.h
  • bf5ebe3 fix(ci): silence cppcheck on c_runtime_cov view and init CVar.flag_

Do not merge from this bot turn; review CI / Codecov first.

When USE_COV is on, pass -fprofile-arcs/-ftest-coverage/--coverage into
the GCC JIT compile/link of generated C, place temps under build/jit_cov,
use a two-step .c→.o→.so so .gcno/.gcda names stay harvestable, and keep
the .c after unload for lcov. TCC path unchanged.
When USE_COV instruments GCC JIT (see prior commit), .gcno/.gcda land under
build/jit_cov. The previous lcov --extract kept only src/* and include/*, so
those hits were dropped before Codecov upload.

Extract policy: still one capture of --directory build (--no-external), then
--extract src/* + include/* + build/jit_cov/*. That keeps host sources and
JIT-emitted fakelua_jit_*.c, and drops #line-remapped .lua paths plus
/usr/CPM noise. Add --ignore-errors inconsistent because JIT #line → .lua
confuses lcov end-line checks (and some host TUs trip the same).

unit_tests already exercise AllJitTypes (incl. GCC); TCC remains uninstrumented.
Codecov cannot usefully browse build/jit_cov/fakelua_jit_*.c. Add
src/compile/c_runtime_cov.h as a view-only copy of the kCRuntimeHeader
C body and have CGen wrap that paste with
  #line 1 "src/compile/c_runtime_cov.h"
so gcov attributes FlFastAlloc etc. to a real in-repo path under src/.
Reset to <fakelua-generated> afterward so per-TU preamble/boilerplate
and later #line→.lua mapping are unchanged.

kCRuntimeHeader remains the compile-time source of truth; a unit test
asserts the view file stays byte-identical to the raw-string body.
CI extract already covers src/*; keep build/jit_cov/* as a residual net.
Exclude Codecov twin c_runtime_cov.h from cppcheck (body lived in
kCRuntimeHeader string before and tripped returnDanglingLifetime FPs).
Initialize key CVar.flag_ = 0 to match existing runtime init pattern;
keep view and SoT byte-synced.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 79.31034% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.49%. Comparing base (a6fe459) to head (bf5ebe3).

Files with missing lines Patch % Lines
src/jit/gcc_jit.cpp 78.82% 18 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #49      +/-   ##
==========================================
+ Coverage   88.45%   88.49%   +0.04%     
==========================================
  Files         124      125       +1     
  Lines       26109    27211    +1102     
==========================================
+ Hits        23095    24081     +986     
- Misses       3014     3130     +116     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@esrrhs
esrrhs merged commit 6331a7c into master Nov 3, 2026
9 checks passed
@esrrhs
esrrhs deleted the exp/jit-gcc-coverage branch November 3, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants