[WSLC] Generate WSLC SDK FFI bindings with bindgen#669
Open
SohamDas2021 wants to merge 3 commits into
Open
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the WSLC backend’s Rust FFI surface from hand-written declarations to bindgen-generated bindings, so ABI drift between the pinned WSLC SDK header (wslcsdk.h) and our Rust types/signatures is caught at compile time rather than becoming silent runtime UB.
Changes:
- Add and commit bindgen-generated WSLC SDK bindings (
wslcsdk_sys.rs) plus a PowerShell regeneration script. - Refactor
wslc_bindings.rsinto a thin façade over the generated module (DLL anti-hijack load + required-symbol validation + RAII guards). - Update the WSLC runner + policy mapping and add documentation/runbook for maintaining the bindings.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/backends/wslc/common/src/wslcsdk_sys.rs | New bindgen-generated ABI surface + dynamic-loading WslcSdk table (committed artifact). |
| src/backends/wslc/common/src/wslc_bindings.rs | Façade over generated bindings: safe-ish load(), required-export validation, RAII guards, S_OK, helpers. |
| src/backends/wslc/common/src/wsl_container_runner.rs | Update call sites/struct field names/enum constants and callback ABI to match bindgen output. |
| src/backends/wslc/common/src/policy_mapping.rs | Update networking mode mapping/tests to use bindgen newtype constants. |
| src/backends/wslc/common/src/lib.rs | Export new wslcsdk_sys module. |
| scripts/generate-wslc-bindings.ps1 | New standalone regeneration script (bindgen CLI + libclang + MSVC/WinSDK include discovery + header extraction from .nupkg). |
| docs/wsl/wslc-sdk-bindings.md | New runbook documenting the generated file, why it’s committed, and how to bump/regenerate safely. |
| docs/wsl/wsl-container-getting-started.md | Link to the new bindings-maintenance documentation. |
| .github/copilot-instructions.md | Document the bindgen-generated WSLC bindings convention and regeneration procedure. |
Comment on lines
+352
to
356
| let mut missing = WslcComponentFlags::WSLC_COMPONENT_FLAG_NONE; | ||
| let hr = sdk.WslcGetMissingComponents(&mut missing); | ||
| if hr != S_OK { | ||
| return Err(sdk_error("WslcGetMissingComponents failed", hr, "")); | ||
| } |
SohamDas2021
marked this pull request as ready for review
July 22, 2026 18:55
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
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.
📖 Description
Replaces the hand-written WSLC SDK FFI bindings with bindgen-generated bindings so any ABI drift between the SDK headers and our Rust declarations becomes a compile error instead of silent undefined behavior at runtime.
🔗 References
🔍 Validation
✅ Checklist
Cargo.lock, thedependency-feed-checkcheck passes (see docs/pull-requests.md)📋 Issue Type
GitHub Actions runs the PR validation build automatically. The ADO pipeline
(
MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHubActions build; it runs on merge to
main, and Microsoft reviewers with write access can trigger iton a PR with
/azp run. See docs/pull-requests.md.If the
dependency-feed-checkcheck fails on a new dependency, the crate must be added tothe feed before the PR can pass. See docs/pull-requests.md
for the steps.
Microsoft Reviewers: Open in CodeFlow