Skip to content

fix: correct OpusCompile workflow for shim linking on Windows and Linux x86#49

Merged
SineVector241 merged 2 commits intoAvionBlock:masterfrom
katruud:fix/arm64-apple-variadic-ctl
Apr 8, 2026
Merged

fix: correct OpusCompile workflow for shim linking on Windows and Linux x86#49
SineVector241 merged 2 commits intoAvionBlock:masterfrom
katruud:fix/arm64-apple-variadic-ctl

Conversation

@katruud
Copy link
Copy Markdown
Contributor

@katruud katruud commented Apr 8, 2026

Summary

Follow-up to #48 — fixes the Build with shim CI step that was failing on Windows (x86 and arm64) and Linux x86 after the non-variadic CTL shim was introduced.

Changes

.github/workflows/OpusCompile.yml

Windows: vcvarsall arch mapping

The ARCH env var is set for CMake (Win32, x64, ARM64) but vcvarsall.bat expects different names (x86, amd64, amd64_arm64). Added a mapping step so the correct MSVC toolchain is initialized for each target.

Windows x86: CRT linker error

When manually invoking link.exe to combine the static opus.lib with the shim into a DLL, the x86 SEH symbol __except_handler4_common was unresolved. This symbol lives in vcruntime.lib and isn't automatically pulled in during manual linking. Fixed by explicitly specifying ucrt.lib, vcruntime.lib, and msvcrt.lib on the link command.

Linux x86: architecture mismatch

The shim was being compiled as 64-bit (default gcc) while libopus.a was built as 32-bit (-m32). Fixed by passing -m32/-m64 to gcc in the shim build step to match the opus static library architecture.

CI verification

All jobs pass on the fork: https://github.com/katruud/OpusSharp/actions/runs/24160669210

Platform Status
Android (x64, x86, arm64, arm32) Passed
Linux (x64, x86, arm64, arm32) Passed
Windows (x64, x86, arm64) Passed
macOS (x64, arm64) Passed
iOS (device, simulator-arm64, simulator-x86_64) Passed
iOS-universal Passed
Wasm Passed
Create-Runtimes Passed

Local testing

The shim-enabled opus.dylib was built locally and tested in the Basis Unity project on macOS ARM64 (Apple Silicon). OpusEncoder.Ctl(OPUS_SET_BITRATE) and OpusEncoder.Ctl(OPUS_SET_COMPLEXITY) calls that previously failed with OPUS_BAD_ARG now succeed, and voice audio networking initializes without errors.

katruud added 2 commits April 8, 2026 16:43
- Windows: map CMake arch names (Win32, x64, ARM64) to vcvarsall
  equivalents (x86, amd64, amd64_arm64) for cross-compilation
- Linux x86: pass -m32 flag to gcc so the shim is compiled as 32-bit
  to match the i386 libopus.a static archive
Add explicit CRT libraries (ucrt.lib, vcruntime.lib, msvcrt.lib) to
the Windows link step. The x86 SEH handler symbol __except_handler4_common
lives in vcruntime.lib and isn't automatically pulled in when manually
invoking link.exe with a static opus.lib built by CMake with /MD.
@SineVector241 SineVector241 merged commit cf524ea into AvionBlock:master Apr 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants