fix: correct OpusCompile workflow for shim linking on Windows and Linux x86#49
Merged
SineVector241 merged 2 commits intoAvionBlock:masterfrom Apr 8, 2026
Merged
Conversation
- 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
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #48 — fixes the
Build with shimCI step that was failing on Windows (x86 and arm64) and Linux x86 after the non-variadic CTL shim was introduced.Changes
.github/workflows/OpusCompile.ymlWindows: vcvarsall arch mapping
The
ARCHenv var is set for CMake (Win32,x64,ARM64) butvcvarsall.batexpects 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.exeto combine the staticopus.libwith the shim into a DLL, the x86 SEH symbol__except_handler4_commonwas unresolved. This symbol lives invcruntime.liband isn't automatically pulled in during manual linking. Fixed by explicitly specifyingucrt.lib,vcruntime.lib, andmsvcrt.libon the link command.Linux x86: architecture mismatch
The shim was being compiled as 64-bit (default
gcc) whilelibopus.awas built as 32-bit (-m32). Fixed by passing-m32/-m64to 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
Local testing
The shim-enabled
opus.dylibwas built locally and tested in the Basis Unity project on macOS ARM64 (Apple Silicon).OpusEncoder.Ctl(OPUS_SET_BITRATE)andOpusEncoder.Ctl(OPUS_SET_COMPLEXITY)calls that previously failed withOPUS_BAD_ARGnow succeed, and voice audio networking initializes without errors.