webrtc-sys: forward-declare PeerContext as struct (fixes 4x LNK2019 on windows-msvc)#1167
Open
wcares wants to merge 1 commit into
Open
webrtc-sys: forward-declare PeerContext as struct (fixes 4x LNK2019 on windows-msvc)#1167wcares wants to merge 1 commit into
wcares wants to merge 1 commit into
Conversation
…n windows-msvc) include/livekit/jsep.h forward-declares `class PeerContext;`, but PeerContext is a cxx shared type defined Rust-side as `pub struct PeerContext` (src/peer_connection.rs), so cxx emits `struct PeerContext` everywhere it generates C++. Under the MSVC ABI (clang-cl/cl) the class-vs-struct tag is part of the mangled name, so rust::Box<class PeerContext> (jsep.cpp) and rust::Box<struct PeerContext> (cxx-generated peer_connection.cc) mangle to different symbols -> 4 unresolved externals at link on x86_64-pc-windows-msvc. No-op on Linux/macOS (Itanium ABI). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
|
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
webrtc-sys/include/livekit/jsep.hforward-declaresclass PeerContext;, butPeerContextis a cxx shared type defined on the Rust side aspub struct PeerContext(src/peer_connection.rs), so cxx emitsstruct PeerContexteverywhere it generates C++.Under the MSVC ABI (clang-cl / cl), the
classvsstructtag is part of the mangled name, sorust::Box<class PeerContext>(fromjsep.cpp, which includesjsep.h) andrust::Box<struct PeerContext>(from the cxx-generatedpeer_connection.cc) mangle to different symbols → 4 unresolved externals at link onx86_64-pc-windows-msvc:GCC/Clang on Linux/macOS use the Itanium ABI, which ignores the class/struct tag in mangling, so this never surfaces there — only the MSVC ABI is affected. Verified identical in webrtc-sys 0.3.21 and 0.3.32.
Fix (1 word)
jsep.his the only place in the crate that tagsPeerContextasclass; every other reference usesrust::Box<PeerContext>(untagged) and the cxx bridge declares itstruct. Making the forward declarationstructmakes the tag consistent crate-wide. No-op on Linux/macOS; fixes the link on windows-msvc.Verification
With this change applied (via
[patch.crates-io]),omnynet-agentlinks clean with thelivekit-avfeature ON onx86_64-pc-windows-msvc(clang-cl), in combination with+crt-staticfor the libwebrtc/MTprebuilt, and runtime-connects to a LiveKit room (rust SDK 0.7.42).Closes the windows-msvc build failure tracked in #1154.