Skip to content

build(obs-scripting): Exempt the SWIG Python runtime from -Wpedantic (#2695) - #2696

Merged
zackees merged 5 commits into
masterfrom
infra/2695-obs-scripting-pedantic
Oct 27, 2026
Merged

zackees merged 5 commits into
masterfrom
infra/2695-obs-scripting-pedantic

Conversation

@zackees

@zackees zackees commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

What breaks

The Ubuntu app build (build-project.yaml ubuntu-build, the OBS-Studio-Rust variant) fails on master at -Werror=pedantic in shared/obs-scripting. PR CI cannot see it — PRs run no app build — so it only shows in a nightly / dispatched Scheduled run.

build_ubuntu/shared/obs-scripting/swig/swigpyrun.h:2610:22: error: ISO C forbids conversion of function pointer to object pointer type [-Werror=pedantic]
build_ubuntu/shared/obs-scripting/swig/swigpyrun.h:2611:19: error: ... [-Werror=pedantic]
build_ubuntu/shared/obs-scripting/swig/swigpyrun.h:2612:18: error: ... [-Werror=pedantic]
build_ubuntu/shared/obs-scripting/swig/swigpyrun.h:2613:23: error: ... [-Werror=pedantic]
shared/obs-scripting/obs-scripting-python.h:157:57: error: ISO C does not support '__FUNCTION__' predefined identifier [-Werror=pedantic]
shared/obs-scripting/obs-scripting-python-frontend.c.h:295:17: note: in expansion of macro 'py_error'

Neither file is ours: swig/swigpyrun.h is generated (swig -external-runtime) and py_error() is the upstream glue macro around __FUNCTION__.

Fix

shared/obs-scripting/cmake/python.cmake already opts the obs-scripting target out of -Wcast-qual for that same generated header (#516). This adds -Wno-pedantic to the same C-only generator expression. No generated file is edited and the global C flag lists keep -Wpedantic — a new pin asserts that.

RED

175e351a0 adds ci/test_scripting_pedantic_exemption.py, which fails on master:

FAIL: test_obs_scripting_opts_out_of_pedantic_for_c
AssertionError: '-Wno-pedantic' not found in ' $<$<COMPILE_LANG_AND_ID:C,AppleClang,Clang,GNU>:-Wno-cast-qual>'
Ran 3 tests — FAILED (failures=1)

GREEN

5ab5211b2 adds the flag. Local:

$ uv run --project . python -m unittest ci/test_scripting_pedantic_exemption.py
Ran 3 tests ... OK
$ uv run ci/msvc_flags.py      # the new flag stays inside the C-only genex
(no findings, exit 0)
$ uv run --project . python -m unittest ci.test_msvc_flags ci.test_uv_run
Ran 19 tests ... OK
$ uvx [email protected] check ci/test_scripting_pedantic_exemption.py
All checks passed!

The flag mechanism itself, on the exact diagnostics (a 6-line C file compiled with -std=c11 -Wpedantic -Werror, then with the added -Wno-pedantic): both errors appear, then exit 0.

The authoritative GREEN is the Ubuntu app-build lane on this branch — a dispatched Scheduled run is in flight; its link and result go in the next comment.

Fixes #2695


Second batch: the SWIG wrappers and vendored librtmp

The first dispatched run cleared obs-scripting and then failed one step later, on the same diagnostic in the SWIG wrapper objects (obspythonPYTHON_wrap.c, obsluaLUA_wrap.c) — -Wno-pedantic added beside their existing -Wno-cast-qual (71fc87df7), and the pin covers all three SWIG targets.

It also proved the class reaches vendored librtmp, which logs with the GNU __FUNCTION__ (amf.c 16, hashswf.c 7, handshake.h 22, rtmp.c 114 sites). That is fixed as a token-for-token __func__ swap (ab81a7b23) — the standard C99 identifier, identical semantics — rather than -Wno-pedantic on obs-outputs, which would also drop the diagnostic for our own code in that plugin. Local: gcc -std=c17 -Wpedantic -Werror -fsyntax-only over amf.c/hashswf.c went 16/1 → 0/0.


GREEN on the lane

Dispatched Scheduled on this branch, run 40585658256: Build 🧱 / Ubuntu 🐧 (OBS-Studio-Rust) passes — the app build compiles shared/obs-scripting and obs-outputs at -Wpedantic now. PR CI is green (CI Gate ✅), Tier 2 Linux included.

The Ubuntu app build fails on master at -Werror=pedantic in
shared/obs-scripting: the SWIG-generated swigpyrun.h converts function
pointers to object pointers, and obs-scripting-python.h's py_error() macro
uses __FUNCTION__. This test fails on master because the obs-scripting
target has no -Wno-pedantic yet, and it also asserts the global C flag
lists keep -Wpedantic, so the fix cannot be a tree-wide relaxation.
…2695)

The Ubuntu app build (OBS-Studio-Rust variant) fails on master at
-Werror=pedantic, in two files we do not own:

  swig/swigpyrun.h:2610-2613   ISO C forbids conversion of function pointer
                               to object pointer type (generated: swig
                               -external-runtime)
  obs-scripting-python.h:157   ISO C does not support '__FUNCTION__'
                               (upstream glue, expanded by py_error() at
                               obs-scripting-python-frontend.c.h:295)

The obs-scripting target already opts out of -Wcast-qual for the same
generated header (#516); add -Wno-pedantic to the same C-only generator
expression. The global C flag lists keep -Wpedantic, and no generated file
is edited.

RED: ci/test_scripting_pedantic_exemption.py fails on master (1 of 3 tests).
GREEN: it passes with this commit; uv run ci/msvc_flags.py stays clean.
zackees and others added 3 commits October 27, 2026 14:16
…ppers (#2695)

The first dispatched Ubuntu run cleared the obs-scripting target and then
failed one step later on the SWIG wrapper objects, same diagnostic:

  obspythonPYTHON_wrap.c:1766-1771, 2424-2430, 2666-2669, 4482-57124
  obsluaLUA_wrap.c:1176
  error: ISO C forbids conversion of function pointer to object pointer type

Both targets already carry -Wno-cast-qual for the same generated code; add
-Wno-pedantic beside it in the same C-only generator expression. The pin now
covers all three SWIG targets (obs-scripting, obspython, obslua).
The Fast Gate lint lane's gersemi -c step rejects the argument layout left
by the previous commit; this is the formatter's own output, no change to
the flags themselves.
#2695)

Vendored librtmp logs its function name with the GNU extension
__FUNCTION__, which -Wpedantic rejects in the strict C the repo builds with
(CMAKE_C_EXTENSIONS FALSE, -std=c17): amf.c 16 sites, hashswf.c 7, handshake.h
22, rtmp.c 114. The Ubuntu app build compiles obs-outputs, so it fails there
next, after the scripting targets are fixed.

__func__ is the standard C99 identifier with identical semantics, so this is a
token-for-token swap in the vendored files rather than a -Wno-pedantic on the
obs-outputs target, which would also drop the diagnostic for our own code in
that plugin. No behaviour changes; the vendored code stays warning-clean under
the same flags.

Verified locally with the real flags: gcc -std=c17 -Wpedantic -Werror
-fsyntax-only over amf.c and hashswf.c went from 16 and 1 pedantic errors to
0 and 0.
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Pushed 006f06f90 on top of 71fc87df7: shared/obs-scripting/cmake/python.cmake failed the Fast Gate's gersemi -c step (the target_compile_options argument layout from the first commit). The commit is gersemi's own output only — no flag change — and ci/local_gate.py --only gersemi plus ci/test_scripting_pedantic_exemption.py (3 tests OK) both pass locally at that tip. Whoever owns this branch: pull before pushing again.

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

GREEN: dispatched Scheduled on the branch — run 40585658256, job Build 🧱 / Ubuntu 🐧 (OBS-Studio-Rust) success. PR CI CI Gate ✅ green, Tier 2 Linux (tests ON/OFF, both serial parts) green. Handed off to the coordinator.

@zackees
zackees marked this pull request as ready for review October 27, 2026 21:36
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit 1369daf Oct 27, 2026
70 of 75 checks passed
@zackees
zackees deleted the infra/2695-obs-scripting-pedantic branch October 27, 2026 21:46
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
…es (obs-rust#2703) (obs-rust#2704)

* ci: Pin that the SWIG scripting targets exempt -Wmissing-prototypes (obs-rust#2703)

obs-rust#2678 enabled -Wmissing-prototypes tree-wide and the Ubuntu app build
(OBS-Studio-Rust) and the Flatpak build now stop compiling
shared/obs-scripting: the SWIG-generated glue declares its entry points
with no prototype in scope.

The test fails on master at all four sites that already exempt the same
generated files from -Wcast-qual, and it pins that the global C lists keep
the rule so the obs-rust#2624 ratchet still applies to first-party code.

* build(obs-scripting): Exempt the SWIG sources from -Wmissing-prototypes (obs-rust#2703)

obs-rust#2678 enabled -Wmissing-prototypes tree-wide; the Ubuntu app build
(OBS-Studio-Rust) and the Flatpak build then stopped compiling
shared/obs-scripting, because the SWIG-generated glue declares its entry
points with no prototype in scope:

  obs-scripting-lua-frontend.c.h:320   add_lua_frontend_funcs
  obs-scripting-lua-source.c.h:766     undef_lua_script_sources
  obs-scripting-lua.c.h:1075..1320     obs_lua_script_* / obs_lua_load / obs_lua_unload
  obs-scripting-python-frontend.c.h:418 add_python_frontend_funcs

Generated code cannot be edited, so each SWIG target opts out of that one
diagnostic beside the -Wno-cast-qual (obs-rust#516) and -Wno-pedantic (obs-rust#2696)
exemptions it already carries: obs-scripting (lua.cmake, python.cmake),
obspython and obslua for their own wrapper objects. The global C lists keep
-Wmissing-prototypes and -Wstrict-prototypes, so the obs-rust#2624 ratchet still
applies to first-party code.

RED: ci/test_scripting_missing_prototypes.py fails at all four sites.
GREEN: it passes; ci/test_scripting_pedantic_exemption.py, ci.test_uv_run
and ci.test_ci_toml stay green, gersemi ok.

* build(obs-scripting): Exempt -Wstrict-prototypes too (obs-rust#2703)

The Ubuntu app build passed the -Wmissing-prototypes sites and then stopped
one TU later on the same generated glue, which declares functions as
'foo()' rather than 'foo(void)':

  shared/obs-scripting/obs-scripting-python.c.h:741:25
  error: function declaration isn't a prototype [-Werror=strict-prototypes]

obs-rust#2678 enabled both rules together, so both exemptions travel together; the
pin test now asserts each C-only genex carries both.
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.

infra: The Ubuntu app build fails at -Werror=pedantic in obs-scripting (#2643 fallout)

1 participant