Skip to content

DOOM call-graph: libclang reference on the C ports (Part of #5630) - #6766

Merged
squid-shepherd[bot] merged 2 commits into
mainfrom
churn/5630-20261027T0537Z
Oct 27, 2026
Merged

squid-shepherd[bot] merged 2 commits into
mainfrom
churn/5630-20261027T0537Z

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #5630 (step 4; #3784's C reference is the instrument).

What

tests/tools/doom_speedrun/doom_clang_calls.py compares libclang's resolved call graph (tests/tools/clang_callgraph.py, preprocessor first) with the engine's calls_out_to on the 15 licensed C ports, by (file, caller), both sides restricted to repo-defined names, self-edges and vendored files dropped. Reported to <work>/results/<sha>/clang_calls.json, never scored. clang_callgraph.build now returns fatal (sources whose parse hit a fatal error), only when non-empty so other readers of the contract are unchanged.

Evidence (libclang 18.1.1, scans at 590c805, ~4 min for all 15)

Port recall precision disagreements in files without a fatal error
linuxdoom 0.9874 0.9726 0
chocolate-doom 0.9937 0.9199 0
crispy-doom 0.9956 0.9125 0
doomgeneric 0.9944 0.9218 0
doomretro 0.9758 0.7481 2
prboom-plus 0.9442 0.8591 0
doom-ascii 0.9908 0.9360 0
sdl-doom 0.9942 0.9259 0
puredoom 0.9818 0.9812 61
fastdoom 0.9884 0.9648 0
inter-doom 0.9875 0.9489 3
doom-wasm 0.9954 0.9135 0
dsda-doom 0.9842 0.8661 0
woof 0.9359 0.9136 6
nugget-doom 0.9392 0.9185 6

The clones have no build, so almost every file hits a fatal include error (config.h, SDL.h); clang then guesses types and can lose a call to a function of its own file (chocolate-doom opl.c AutoSelectDriver -> InitDriver is a real call clang drops). So the low precision is mostly the reference's blind spot, which is why the clean-file count is kept apart. Read: a lead, not a verdict.

Real lead from the clean files: a call made only through a function-like macro (#define FTOM(x) FixedMul(...), used in AM_Responder) is seen by the compiler and missed by the engine (puredoom and chocolate-doom am_map.c, FixedMul x6+ each). Other clean-file disagreements are header-defined static functions the reference attributes per translation unit (woof p_saveg.h, doomretro m_array.h, inter-doom stb_image_write.h).

Gates: pr_gates --fast 9/9; tests: new 5 + test_callgraph_tools, test_callgraph_oracle, test_doom_speedrun, tree-wide guards, 302 passed. Ratchets 9/9. No engine change, so no golden re-bless.

Class / Sibling gaps

Class: "compiler-resolved call edges the engine's text rules cannot see or invent", measured per C port. Members: all 15 licensed C ports run (table). C++ ports (eternity, gzdoom, odamex, edge-classic, doom3-bfg, doomsday, srb2): not run, the C reference reads .c only; the C++ reference (clang_callgraph.py ... cpp) needs system includes and its own comparer by qualified name (Sibling gap). Macro-expanded calls (FTOM -> FixedMul): an engine gap, different mechanism (macro-body resolution in the detector), not done here. Header-defined static functions in the reference (per-TU attribution): reference-side, not done here.

Remaining slices

  1. Engine: a call inside a function-like macro body, expanded at a use site in a function (needs a detector rule plus golden re-bless; am_map.c is the pin case).
  2. Optional: fold the clang recall/precision into callgraph_baseline.json with a --clang switch on callgraph_oracle.py (needs a build-less include stub to cut the fatal-error noise first).
  3. C++ ports through clang_callgraph.py cpp.

Lessons for agents

  • clang_callgraph.py and doom_clang_calls.py need the selfscan venv python: the system python has no clang, and build exits with an install hint.
  • A DOOM clone parses with a fatal include error in nearly every file (config.h, SDL.h): never drop those files wholesale (it empties the comparison); count them apart.

🤖 Generated with Claude Code

…py); clang_callgraph reports fatal-error files (Part of #5630)

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@squid-protocol squid-protocol added the shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md label Oct 27, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot marked this pull request as ready for review October 27, 2026 05:57
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot enabled auto-merge (squash) October 27, 2026 05:57
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-protocol squid-protocol added shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md and removed shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md labels Oct 27, 2026
@squid-shepherd

Copy link
Copy Markdown
Contributor

No description provided.

@squid-shepherd
squid-shepherd Bot merged commit 2ac09c8 into main Oct 27, 2026
41 checks passed
@squid-shepherd
squid-shepherd Bot deleted the churn/5630-20261027T0537Z branch October 27, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shepherd:merge Maintainer: merge when green (auto-merge, squash). Guide: docs/ci.md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant