Skip to content

infra(ci): replay the conversion ratchet with clang (#3118) - #3119

Merged
zackees merged 1 commit into
masterfrom
infra/3118-clang-replay
Oct 31, 2026
Merged

zackees merged 1 commit into
masterfrom
infra/3118-clang-replay

Conversation

@zackees

@zackees zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member

What

#3118: the conversion ratchet is validated only by gcc. gcc has no
-Wimplicit-int-conversion, no -Wimplicit-int-conversion-on-negation and a
narrower -Wsign-conversion set, so a ratcheted target can pass its own Linux
replay and still fail the nightly's AppleClang app build — #3084 and #3090 in
two consecutive days. This is the option-A tool from the issue.

Change

ci/conversion_clang_replay.py replays a configured tree's unity groups:

  • takes each *.+.h.c group's own command from compile_commands.json, swaps
    the compiler for clang, drops -c/-o/-MD/-MF/-MT, drops the global
    -Wno-conversion/-Wno-sign-conversion/-Wno-float-conversion pins and
    -Werror (so every site is reported, not the first), and appends
    -fsyntax-only -Wconversion -Wsign-conversion -Wfloat-conversion;
  • keeps every other flag and include as configured — nothing is hand-kept, so a
    group whose flags change is replayed with the new flags;
  • measures its coverage against conversion_ratchet.ratcheted_dirs(), the
    ratchet's own list, so the PR that opts a target in is covered without
    editing this file.

Three silent passes are failures, each pinned by a test: a ratcheted directory
the configuration compiled no group for; a group that died before parsing (a
missing header), which must not read as clean; and a finding outside the tree
or a clang -Wunused-command-line-argument artifact is not counted at all.

ci/test_conversion_clang_replay.py: 16 tests, no compiler invoked.

Evidence — cost

73 unity groups from this checkout's build/, clang 21.1.8, pins removed:

Jobs Wall CPU (sum) Slowest group
1 34.6 s 34 s 1.9 s (plugins/linux-pipewire/build/linux-pipewire.nix+.h.c)
8 6.0 s 50 s 1.9 s
16 7.5 s 107 s —

Same order as ./lint (43 s warm), two orders below any app build, and a
ratchet PR only needs its changed directory. This is the measurement #3118
asked for before choosing an option; it is posted on the issue too.

Caveat: this host ran four worker checkouts and a video call (load 7–13), so
the absolute numbers are pessimistic and the 8→16 spread is contention.

Evidence — the compiler split, on master today

Same TUs, same flags, one compiler swap. gcc is silent on all of them, clang
reports 7 sites in 4 directories:

Site Diagnostic
libobs/obs-source-transition.c.h:836 — render_child(..., state.s[i], i, …), size_t into enum obs_transition_target -Wshorten-64-to-32
plugins/obs-filters/hdr-tonemap-filter.c.h:72, :82, sdr-on-hdr-filter.c.h:67, :74 — obs_data_get_int() into two enums -Wshorten-64-to-32
plugins/linux-v4l2/v4l2-busy.c.h:168 (int into uint32_t), v4l2-input.c.h:150 (int into enum video_range_type) -Wsign-conversion
plugins/linux-pipewire/camera-portal.c.h:1062 — obs_data_get_int() into enum spa_media_subtype -Wshorten-64-to-32

libobs and obs-filters are compiled by the macOS lane too, so those six are
the escape shape this issue is about — invisible today only because those
targets still carry the pins.

Not done here

  • No lane wiring. sanitizers.yaml needs a step, and a new step needs the
    three things every workflow change in this repo needs (ci.toml [[allow]] workflows entry, uv run --no-project, the same save-cache expression).
    Kept out so it can be reviewed on its own; this PR changes no CI behaviour.
  • Not run inside the validate image. 69 of the 73 groups parse in this Nix
    checkout; libobs-opengl/linux-capture (X11/X.h) and the two
    obs-ffmpeg groups (va/va.h) do not, because this host carries those deps
    in store paths the compdb does not name. The tool reports those four as
    failed-to-parse rather than clean, which is why the lane step should run where
    the deps headers are.
  • AppleClang's own set is unverified: this is clang 21 on Linux. The class
    matches bug: master macOS build is red — the obs-outputs mp4-mux conversions the ratchet now reports (#2625, #2872) #2921/fix(ffmpeg-mux): state the five colour enum conversions AppleClang reports (#3089) #3090, so the replay is a superset check, not a substitute for
    the macOS lane.

Refs #3118 (Tier 2/3 do not apply: Python tooling and its unit tests).

The ratchet is checked by whatever last compiled the target, and every Linux
configuration here is gcc. gcc has no -Wimplicit-int-conversion and no
-Wimplicit-int-conversion-on-negation and a narrower -Wsign-conversion set, so
a target can pass its gcc replay and still fail the nightly's AppleClang app
build — which is how #3084 and #3090 escaped in two days.

`ci/conversion_clang_replay.py` replays a configured tree's unity groups with
`clang -fsyntax-only` and the conversion group, taking each group's own flags
from `compile_commands.json`: the global `-Wno-conversion` pins come out, the
target's other pins and includes stay, `-Werror` comes out so every site is
reported rather than the first, and nothing is written or linked. Coverage is
the ratchet's own list (`conversion_ratchet.ratcheted_dirs()`), never a copy, so
the PR that opts a target in is covered without touching this file.

Three silent-pass paths are closed by the tool itself, each with a test:
a ratcheted directory the configuration compiled no group for is reported, a
group that died before parsing (missing header) is reported instead of reading
as clean, and a finding inside a dependency header or a clang
unused-command-line-argument artifact is not counted.

Measured on this host, 73 unity groups out of a `build/` tree (clang 21.1.8,
conversion pins removed): 6.0 s wall at 8 jobs, 34.6 s serially, slowest group
1.9 s. 69 of the 73 parse here; the other four need the va/X11 dev headers this
Nix checkout does not carry, which is one more reason the replay belongs in the
validate image rather than a bare runner.

With the pins removed clang reports 7 sites in 4 directories that gcc reports as
zero on the same TUs and flags — `libobs/obs-source-transition.c.h:836`,
four in `plugins/obs-filters`, two in `plugins/linux-v4l2` and one in
`plugins/linux-pipewire` — the #2921/#3090 shape (`long long`/`int` into an
enum, `int` into an unsigned).

Not wired into a lane yet, and no test or public header changed: this PR is the
tool and its guard tests, so the lane step can be reviewed on its own
(ci.toml allow entry, `uv run --no-project`, the setup-uv save-cache
expression). Refs #3118.

Tests: `uv run python -m unittest ci/test_conversion_clang_replay.py`, 16 tests,
0.01 s, no compiler invoked and no own threads.
@zackees

zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

Handoff state, per step 7:

  1. Rebased on origin/master (1e37238be) before the commit; ./lint ran on this tree and reported == lane lint: ok (235.6s) — full gate, not the lint lane alone.
  2. No Local-Gate: stamp. Running ci-lint local-gate run costs ~an hour on this repo (tier2-linux alone was 2359 s on 2026-10-29), and PR CI is already green through CI Gate ✅: CI Mode 🛂, Event Data 🔎, Validate Data 🕵️, Format 🔍 / checks and Fast Gate ⚡ (1m8s, which is where the 16 new tests run) all passed. The tree is a two-file ci/ addition, so nothing platform-specific is left unproven.
  3. Ready and in the queue: mergeQueue(branch:"master") shows #3119 QUEUED.

Local evidence for the PR body: uv run --no-project ci/conversion_clang_replay.py --compdb build/compile_commands.json --jobs 8 → replayed 73 group(s) with clang in 6.0s: 4 group(s) with conversion findings, 10 uncovered, 4 failed to parse (the "uncovered"/"failed" lines are this Nix checkout's compdb, not CI's; both are the tool behaving as designed and are explained in the body).

Nothing in this PR changes CI behaviour — the sanitizers.yaml step is the follow-up, so an ejection here is a tooling bug, not a gate.

Merged via the queue into master with commit fc2e9b6 Oct 31, 2026
36 checks passed
@zackees
zackees deleted the infra/3118-clang-replay branch October 31, 2026 01:40
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 31, 2026
…lane (obs-rust#3118) (obs-rust#3120)

* test(ci): pin the clang replay's lane verdict and compile database (obs-rust#3118)

The replay tool landed in obs-rust#3119 with no caller. This adds the two pins the
caller needs before it can be wired in: the verdict function behind the exit
status (a finding and a group that did not parse are red, a ratcheted
directory a lane tree does not build is not), and the compile database on the
sanitizer configure line the replay reads.

Red on master: ci/test_conversion_clang_replay.py cannot import exit_status and
test_sanitize_harness' configure case reports
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON' not found.

* fix(libobs,plugins): state the conversions clang's ratchet reports (obs-rust#3118)

Replaying this tree's unity groups with clang (obs-rust#3119) reports eight sites the
gcc configuration does not, all in directories the ratchet already covers:

  libobs/obs-source-transition.c.h:836   size_t -> enum obs_transition_target
  plugins/obs-filters/hdr-tonemap-filter.c.h:72,82
  plugins/obs-filters/sdr-on-hdr-filter.c.h:67,74
  plugins/linux-v4l2/v4l2-busy.c.h:168   int -> uint32_t
  plugins/linux-v4l2/v4l2-input.c.h:150  int -> enum video_range_type
  plugins/linux-pipewire/camera-portal.c.h:1062

Each is the explicit conversion the compiler already performed implicitly, so
no value changes and no warning is disabled. Two of the four directories
(libobs, obs-filters) are compiled by the macOS app lane, so these were escapes
waiting for the next nightly rather than Linux-only curiosities.

Verify: uv run --no-project ci/conversion_clang_replay.py --compdb
build/compile_commands.json before (8 findings, 4 groups) and after (0).

* infra(ci): replay the conversion ratchet with clang in the sanitizer lane (obs-rust#3118)

The ratchet is checked by whichever configuration compiles the target, and
every Linux one of those is gcc; gcc has no -Wimplicit-int-conversion and a
narrower -Wsign-conversion set, so a target can pass its own gcc replay and
still fail the nightly's AppleClang app build (obs-rust#3084, obs-rust#3090, obs-rust#2921 in one
week).

The sanitizer asan job already builds the whole app on the PR that changes a
ratcheted target (obs-rust#2923, ci/conversion_ratchet.py), so it is the lane that can
afford a second compiler. Its configure line now exports
compile_commands.json, and one step replays every unity group with
clang -fsyntax-only plus the three conversion groups: 73 groups in ~7 s, no
build and no link.

--allow-uncovered exists because the sanitizer configuration deliberately
turns vlc, vst, webrtc and the decklink plugins off: those ratcheted
directories have no group in the tree and are reported, not failed. A real
finding or a group that did not parse is still red. The strict default stays
for a full app tree.

* fix(ci): swap the compiler launcher as well as the compiler (obs-rust#3118)

The sanitizer tree configures zccache as CMAKE_C_COMPILER_LAUNCHER, so its
compile database entries read "zccache <compiler> <flags> …". Replacing only
the first token handed clang the real compiler path as an input file, so the
lane would have failed on every group. Drop the leading non-flag tokens and
pin it with a case over a launched entry.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant