Skip to content

fix(libobs): build the Rust staticlib with the release profile - #81

Merged
zackees merged 2 commits into
obs-rust:masterfrom
chriscoveries:fix/80-corrosion-release-profile
Oct 10, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
chriscoveries:fix/80-corrosion-release-profile

Conversation

@chriscoveries

Copy link
Copy Markdown
Contributor

Pins PROFILE release on corrosion_import_crate so panic=abort applies in Debug and default (build-type-unset) builds. Profile evidence (default Xcode configure, before vs after) is in the commit message.

Fixes #80

@zackees

zackees commented Oct 10, 2026

Copy link
Copy Markdown
Member

Reviewed: the change is correct. Without PROFILE, Corrosion links a dev-profile (panic=unwind) staticlib for Debug and unset build types, so a panic in a #[no_mangle] shim could unwind across the C ABI. No CI has run yet because the PR is a draft. Mark it ready for review; once CI is green this can merge. Optional follow-up: a Tier 2 check that the linked staticlib was built with panic=abort, so this can't regress silently.

zackees and others added 2 commits October 10, 2026 09:16
Without PROFILE, Corrosion picks the dev profile for Debug or unset
CMAKE_BUILD_TYPE, so a default cmake build links a panic=unwind
staticlib and a shim panic would unwind across the C ABI (UB).
Pinning PROFILE release keeps panic=abort in every configuration.

Before (default configure, Xcode Debug config):
  Debug/cargo/build/aarch64-apple-darwin/debug/liblibobs_rust.a,
  no --profile flag (cargo dev).
After: every config builds
  <CONFIG>/cargo/build/aarch64-apple-darwin/release/liblibobs_rust.a
  with --profile=release.

Fixes #80

Local-Gate: v1 tree=a1056128db2cc0c744ad4c1f1e54599b37e9bad4 secs=27 lanes=lint:reused@ea6e8262155a,rust-test:reused@ca6f7994f8cc,tier2-linux:run
Ci-Attestation: {"at":1791650085,"gate":"rust/all/fmt","host":"linux-x86_64","key":"ea6e8262155a9e5411d3c55a7d1830d57d5b83f0a43cf2169f0cc765431aff15","lane":"lint","parents":["378e8ac07dcf408ca5912be3dd36aa99865f2bf4"],"secs":null,"stamp":"acca3a131f4f78f62fbf1ecdd80e4549","tree":"a1056128db2cc0c744ad4c1f1e54599b37e9bad4","v":1,"via":"reused"}
Ci-Attestation: {"at":1791650085,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"ea6e8262155a9e5411d3c55a7d1830d57d5b83f0a43cf2169f0cc765431aff15","lane":"lint","parents":["378e8ac07dcf408ca5912be3dd36aa99865f2bf4"],"secs":null,"stamp":"7412653d0d1441e16962573065becd1d","tree":"a1056128db2cc0c744ad4c1f1e54599b37e9bad4","v":1,"via":"reused"}
Ci-Attestation: {"at":1791650085,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"ca6f7994f8ccc6701543d917d54f7988fa7c6dfc75e745451523e7509613434a","lane":"rust-test","parents":["378e8ac07dcf408ca5912be3dd36aa99865f2bf4"],"secs":null,"stamp":"9d9261e9be0000492111db21a80e992c","tree":"a1056128db2cc0c744ad4c1f1e54599b37e9bad4","v":1,"via":"reused"}
Ci-Attestation: {"at":1791650458,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"81e4030b16913d441223e4e02f9cb37f8b9bc671363aacd16b3b287efb82317b","lane":"tier2-linux","parents":["378e8ac07dcf408ca5912be3dd36aa99865f2bf4"],"secs":27,"stamp":"c8697f46ddc131b086eec758f3bb9ef4","tree":"a1056128db2cc0c744ad4c1f1e54599b37e9bad4","v":1,"via":"run"}
@zackees
zackees force-pushed the fix/80-corrosion-release-profile branch from 62ac9ba to bafe476 Compare October 10, 2026 16:41
@zackees
zackees marked this pull request as ready for review October 10, 2026 16:41
@zackees

zackees commented Oct 10, 2026

Copy link
Copy Markdown
Member

Added a Tier 2 check in rust/tools/linux-validate/validate.sh. It configures (configure only, no build) an ENABLE_RUST_LIBOBS=ON tree with CMAKE_BUILD_TYPE=Debug and checks that the cargo staticlib in the libobs link graph comes from .../release/liblibobs_rust.a, which is the panic=abort profile.

RED (378e8ac, test only): /cargo/build/x86_64-unknown-linux-gnu/debug/liblibobs_rust.a -> FAIL: Debug libobs links a non-release (panic=unwind) Rust staticlib
GREEN (bafe476, with the PROFILE release fix): .../release/liblibobs_rust.a, run.sh exits 0, exports IDENTICAL (1752 symbols).
Rebased on master. Local gate passed and the head is stamped.

@zackees
zackees merged commit cef6d7f into obs-rust:master Oct 10, 2026
20 checks passed
@chriscoveries
chriscoveries deleted the fix/80-corrosion-release-profile branch October 11, 2026 02:18
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.

panic="abort" covers only profile.release; the default CMake config links a dev-profile (unwind) staticlib

2 participants