Skip to content

cgen: restore -trace-calls in the new compiler - #28788

Open
medvednikov wants to merge 3 commits into
masterfrom
codex/restore-trace-calls-20260919
Open

medvednikov wants to merge 3 commits into
masterfrom
codex/restore-trace-calls-20260919

Conversation

@medvednikov

@medvednikov medvednikov commented Sep 19, 2026

Copy link
Copy Markdown
Member

Summary

Restore V1-compatible -trace-calls in the new C backend, without routing through -old-compiler.

  • Reuse the existing tracing runtime and tid/ns/ssize/name output for function entries, module/function names and arity, C.main, _vinit, and _vcleanup. Traces go to stderr; program stdout is unchanged.
  • Restore -trace-fns selection by function/module names and glob patterns, independently of the existing -d trace custom call-site hooks.
  • Propagate instrumentation into parallel generation and bypass uninstrumented module caches and literal-output shortcuts.
  • Prevent _vinit from resetting the trace clock/stack baseline, which caused address-sized negative stack deltas. Exclude the tracing runtime from tracing/profiling recursion.
  • Parse the trace prelude separately before user files, preserving implicit imports such as $embed_file's runtime.
  • Add codegen and end-to-end regression coverage, require -new-compiler in trace tests, and document the flags and stack-delta limitations.
./v -trace-calls examples/hello_world.v
./examples/hello_world
./v -trace-calls -trace-fns 'main.*,println,_vcleanup' run examples/hello_world.v

The os.join_path fixture uses a spread argument so it remains an actual join_path call rather than being lowered to join_path_single by the new compiler.

Upstream integration

Merged master 2b99da47ea7268c152d8b90aae18517b39c1f788, resolving the _vinit conflict by preserving both the trace hook and upstream gc_runtime_init(). The implicit embed-import fix is committed, not pending.

Published integration commit: 6415933439171a6da708b5c87e881ca1070ac4c6. Its complete tree, 77a709228fd6a4dfcbad1ee6ec1d32369314d8c1, exactly matches the tree rebuilt and tested locally. No temporary workflows, patch-transport files, or synthetic assembly history are included in this PR.

Validation

Rebuilt the integrated compiler on Linux with VJOBS=2, then passed all three focused suites using the new compiler explicitly:

VJOBS=2 ./v -new-compiler vlib/v/gen/c/trace_calls_test.v
VJOBS=2 ./v -new-compiler vlib/v/tests/trace_calls_test.v
VJOBS=2 ./v -new-compiler vlib/v/gen/c/parallel_worker_test.v

The end-to-end suite covers filtering, recursive calls, normal dead-code elimination, serial/parallel generation, -prod, combined profiling/tracing, and implicit embed imports. The final hello-world smoke test also passed, with stdout exactly Hello, World!\n and tracing on stderr, including builtin calls and cleanup without address-sized negative stack values. git diff --check and formatting verification of the new tracing code/tests and modified tracing runtime passed.

The pre-integration feature and implicit-import fix also passed the focused Linux Actions validation in run https://github.com/vlang/v/actions/runs/35445012768.

Validation limits

This is not a claim that the full repository CI is green. An earlier upstream-integration Actions attempt built successfully but exited 139 on its first codegen test (https://github.com/vlang/v/actions/runs/35445429442); that failure was not reproduced in the final local integrated build with VJOBS=2. Fresh PR CI still needs to complete.

Earlier broader validation reported the same 12 failing / 41 passing skip-unused compiler-error fixtures with both the modified and original unpatched compiler; the full C-generator directory run exceeded the local execution timeout. The 32-bit cases were skipped because 32-bit headers are unavailable. macOS/Windows were not executed locally.

Keep both the -trace-calls startup hook and upstream gc_runtime_init in _vinit.

Rebuilt and passed the trace-calls codegen, integration, and parallel-worker tests with -new-compiler on the complete merged tree.
@medvednikov
medvednikov marked this pull request as ready for review September 19, 2026 14:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-19T14:38:02.003538Z 6415933 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

1 participant