fix(linux): give the compositor's build.rs its own freestanding-header fallback - #315
Conversation
|
Warning Review limit reached
Next review available in: 13 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…r fallback
`cargo check -p openscreen-compositor` failed on a stock Ubuntu box, x86_64
included:
/usr/include/stdio.h:34:10: fatal error: 'stddef.h' file not found
bindgen a échoué sur les headers ffmpeg: ClangDiagnostic(...)
Ubuntu ships `libclang.so.1` from the runtime package and its builtin header
directory from `libclang-N-dev`. With only the former — the common case — clang
has no freestanding headers of its own, and glibc's `#include_next` finds none.
scripts/build-linux-compositor-addon.mjs already worked around it by exporting
BINDGEN_EXTRA_CLANG_ARGS, but that only ever covered the build going through the
script; cargo on its own stayed broken. electron/native/pipewire-capture hit the
same wall and solved it inside its build.rs precisely so that a bare `cargo
build` works too. This ports that fix to the compositor.
The gcc vendor directory is derived from CARGO_CFG_TARGET_ARCH and matched on the
`<arch>-` prefix, so Debian's x86_64-linux-gnu, arm64's aarch64-linux-gnu and
Arch's x86_64-pc-linux-gnu all resolve, while a cross-gcc built for the other
architecture is still refused — its type widths would be wrong. Both limits.h and
stddef.h are required: a directory holding one but not the other looks like a
valid candidate and would fix only half the problem.
The script's bindgenClangArgs() goes with it. Keeping it would not be merely
redundant: build.rs defers to a non-empty caller-supplied value, so the script's
guess would keep winning — including when it is the worse of the two.
Verified on clean builds with BINDGEN_EXTRA_CLANG_ARGS unset. The reverted
build.rs still fails with the error above; the new one finishes. And
`npm run build:native:compositor:linux` builds, stages and passes its
unprefixed-symbol check.
fce9dcc to
2edde0e
Compare
Summary
cargo check -p openscreen-compositor --manifest-path crates/Cargo.tomlfails on a stock Ubuntu box — x86_64 included, this is not an arm64 issue:Ubuntu ships
libclang.so.1from the runtime package and its builtin header directory fromlibclang-N-dev. With only the former — the common case — clang has no freestanding headers of its own, and glibc's#include_nextfinds none.scripts/build-linux-compositor-addon.mjsalready worked around this by exportingBINDGEN_EXTRA_CLANG_ARGS, but that only ever covered the build going through the script; cargo on its own stayed broken.electron/native/pipewire-capturehit the same wall and solved it inside itsbuild.rsprecisely so a barecargo buildworks too — its doc comment says as much. This ports that fix to the compositor.crates/compositor/build.rsfreestanding_header_args(). gcc vendor dir derived fromCARGO_CFG_TARGET_ARCH, matched on the<arch>-prefix so Debian'sx86_64-linux-gnu, arm64'saarch64-linux-gnuand Arch'sx86_64-pc-linux-gnuall resolve, while a cross-gcc for the other architecture is refused (wrong type widths). Requires bothlimits.handstddef.h. Defers to a non-empty caller-supplied value.scripts/build-linux-compositor-addon.mjsbindgenClangArgs()deleted.Deleting the script's copy is load-bearing, not cleanup.
build.rsdefers to a non-empty caller-suppliedBINDGEN_EXTRA_CLANG_ARGS, so if the script kept setting one, its guess would keep winning — including when it is the worse of the two. Leaving it would have made this fix inert on exactly the machines that need it.Related issue
No existing issue — found while verifying #293.
Type of change
Release impact
Build-time only; nothing in the shipped artifact changes.
Desktop impact
The new code is gated on
target_os == "linux". On macOS the sysroot comes fromxcrun, on Windows from MSVC — neither path is touched, andscripts/build-linux-compositor-addon.mjsalready exits early whenprocess.platform !== "linux".Screenshots / video
No visual change.
Testing
Ubuntu, x86_64,
libclang-18runtime only (nolibclang-18-dev).A/B on clean builds (
cargo clean -p openscreen-compositorbetween each),BINDGEN_EXTRA_CLANG_ARGSunset:build.rsmainfatal error: 'stddef.h' file not found→ panicFinishedScript path —
npm run build:native:compositor:linux, withBINDGEN_EXTRA_CLANG_ARGSunset: builds, stages the renamed ffmpeg libraries, copies the addon, and passes its ownVerified: no unprefixed ffmpeg imports remain in the addoncheck.Suite —
npx vitest run→ 141 files, 1694 passed, 1 skipped, 0 failed.biome checkclean.cargo fmt --checkshows no diff inbuild.rs(the deviations it reports are pre-existing inaudio.rs/compositor_linux.rsonmain).Not verified on Windows or macOS locally — only the
x86_64-unknown-linux-gnutarget is installed here. Thetarget_os == "linux"gate is the argument, and CI'swindows-latest/macosbuild jobs are the check.Note on #293
Rebased onto
mainafter #293 merged. The expected conflict inscripts/build-linux-compositor-addon.mjsis resolved:bindgenClangArgs()is gone, and #293'sMULTIARCHconstant stays —resolveLibclangDir()still needs it for the library path, only the gcc-include half went away.Deleting it also left a dangling doc reference in
electron/native/pipewire-capture/build.rs, which pointed readers atbindgenClangArgs(). It now names its actual twin,freestanding_header_args()incrates/compositor/build.rs.Re-verified after the rebase: clean
cargo checkwithBINDGEN_EXTRA_CLANG_ARGSunset,npm run build:native:compositor:linuxgreen through its unprefixed-symbol check,npx vitest run142 files / 1698 passed / 0 failed,biome checkclean.🤖 Generated with Claude Code