Skip to content

rust: port cf preprocessor to obs-util - #1807

Closed
nathan-v wants to merge 6 commits into
obs-rust:masterfrom
nathan-v:port/cf-preprocessor
Closed

nathan-v wants to merge 6 commits into
obs-rust:masterfrom
nathan-v:port/cf-preprocessor

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1499

What and why

Replace libobs/util/cf-lexer.c.h in production with the safe obs-util::cf_preprocessor core and C ABI adapters. Preserve the public headers, five exported entry points, struct layouts, token provenance, directive whitespace, duplicate-definition behavior, macro argument diagnostics, root-relative includes, and depth-first dependency order. The C implementation remains in the C-reference unity group and the independent oracle; existing C tests are unchanged. The declaration oracle shares that original C preprocessor rather than compiling it twice. Tests extend the existing Utilities category binary.

The C characterization landed in #1502. Defined behavior is preserved; C undefined behavior has explicit boundaries recorded in the issue decision, the parity test header, and rust/README.md: Rust stops at the valid terminator for an unterminated macro invocation, treats empty includes as empty streams, and retains live dependency lexer provenance. Recursive cycles and the C cursor/provenance overruns are outside terminating differential parity. No protocol or intended user-facing behavior change; Tier 4 does not apply.

RED → GREEN

  • RED: 6aa48fda3. SOLDR_RUSTC_WRAPPER=none soldr cargo test -p obs-util cf_preprocessor --lib failed all 51 characterization mirrors at the todo!() stub (0 passed). This was pushed and opened as the draft checkpoint before GREEN.
  • GREEN: 2e711430e (core compatibility fixes 7af3580c2; initial implementation c59e886a5). Focused tests: 68 passed, including original C-test mirrors, real-header layouts, public definition lifecycle, file includes/dependency order, 256-case arbitrary-byte parity, generated conditional/macro parity, numeric and defined unterminated directives, and separate guards for C-undefined inputs.
  • Follow-up RED: b836f17c7 fails C parity for whitespace before a macro call. Hosted Linux Fast Gate at c1a377e3c also exposed host scanf differences for incomplete 0x. GREEN 7af3580c2 preserves C's non-skipping macro cursor and probes only bounded constant literals through the existing CRT platform boundary; numeric parsing and its host grammar choices remain in the safe core. The final workspace and native Tier 2 suites were rerun before pushing this fix.
  • Windows integration: 2e711430e uses a direct CRT sscanf declaration to match C inline linkage and avoid LNK4217 against libcaption. Include fixtures use forward-slash source paths, as the original C root-relative include code requires, and explicitly assert that files were loaded. All 68 focused tests and local Fast Gate lint passed before this push; hosted Windows verification remains mandatory.
  • Mutation check: temporarily inverted == to !=; cf_preprocessor_generated_directives failed against the C oracle. Correct code restored.

Local CI before the GREEN push

  • soldr cargo test --workspace --locked: 2,247 passed, 1 ignored, plus passing doctests. All 68 focused tests and Fast Gate lint also passed before the final compatibility-fix push.
  • OBS_GATE_SKIP_SELF_TEST=1 ./lint: passed, including formatters, warnings-denied Clippy and Dylints. This is the PR Fast Gate mode; the separate Checks job runs the Python self-tests.
  • Native macOS Tier 2: both libraries built; loader paths verified independently, then the unchanged full CTest suite ran against each: 205 passed, 1 skipped out of 206 in OFF and ON. Exported symbols identical: 1,877. test_svt_av1 skips in both modes. Only the local build used /tmp/obs1499-local-ci.xcconfig (ENABLE_HARDENED_RUNTIME=NO) to permit Homebrew cmocka loading; no signing-policy change is committed. The stock script's DYLD_PRINT_LIBRARIES | grep -q probe gives a false negative under pipefail; recording the full loader output verifies the requested framework and avoids SIGPIPE.

Local environment limits, not claimed as passes:

  • Full ./lint Python self-tests fail in 13 files on this macOS host; the same failures reproduce on untouched master 29722decc. No unrelated fixes are included.
  • ./unittest passes the native workspace tests, then its Windows-GNU compile check is unsupported by soldr on Apple Silicon.
  • The local cross lane stops in existing obs-data/src/json_decref.c because the Windows C SDK's stdio.h is unavailable.
  • Docker Tier 2 was attempted, but Podman stopped during image preparation and would not remain running after restart. Linux OFF/ON coverage must come from hosted PR CI. No local-gate attestation is claimed.

Hosted CI

Final head 2e711430ec8abcc914ca7bd59257717f5df967a6: workflow 39834451796 completed successfully before readiness. CI Gate ✅ passed. Verified successful Fast Gate, Python/data checks, Linux Tier 2 build and OFF/ON suites, Windows/macOS Rust tests, Windows/macOS native Tier 2, and Windows/macOS cross lint. The PR is mergeable.

GitHub's Linux aggregate check API retains status=in_progress alongside conclusion=success and completed_at=2026-10-22T18:58:21Z. Both underlying Linux suites, the completed workflow and the required gate are successful; no failed or cancelled selected validation is treated as a pass.

Checklist

  • Base is master; claim and collision checks completed
  • Existing C characterization, then separate RED and GREEN commits
  • Public headers and existing C tests unchanged
  • No new Rust test executable or workflow
  • Defined behavior preserved; C-UB boundaries documented
  • Local CI run before pushing GREEN, with environment limits stated
  • Current-head hosted PR CI passes before readiness

@nathan-v
nathan-v marked this pull request as ready for review October 22, 2026 19:13
@nathan-v
nathan-v requested a review from zackees as a code owner October 22, 2026 19:13
@nathan-v

Copy link
Copy Markdown
Contributor Author

Closing at the maintainer’s request: @vpacher’s original work on #1499 remains active; the stale claim was a missed refresh. This PR duplicates that coordinated work.

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.

rust: Port util/cf-lexer.c (cf preprocessor) to obs-util

1 participant