Skip to content

feat: add linker args for VHF lib to wdk-build#653

Open
Alan632 wants to merge 4 commits intomicrosoft:mainfrom
Alan632:vhf_lib_linker_args
Open

feat: add linker args for VHF lib to wdk-build#653
Alan632 wants to merge 4 commits intomicrosoft:mainfrom
Alan632:vhf_lib_linker_args

Conversation

@Alan632
Copy link
Copy Markdown
Contributor

@Alan632 Alan632 commented May 1, 2026

Description

Add linker arguments for the VHF library (feature gated) to the build script output for each driver type so drivers using the VHF don't have to hardcode the output in their own build scripts.

wdk-build/lib.rs

  • For each driver type (WDM/KMDF/UMDF) add the correct Vhf lib linker arguments, gated by the "vhf" feature flag.

wdk-build/Cargo.toml

  • Add the vhf feature

Verification

Built a driver and ensured vhf linker args were still in build output after removing the hardcoded line in the driver's build.rs.

image

@Alan632 Alan632 self-assigned this May 1, 2026
Copilot AI review requested due to automatic review settings May 1, 2026 23:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an opt-in vhf feature to wdk-build so driver crates can automatically link the appropriate Virtual HID Framework (VHF) import library without hardcoding linker directives in their own build.rs.

Changes:

  • Add a vhf Cargo feature to wdk-build.
  • When vhf is enabled, emit VhfKm.lib for WDM/KMDF builds and VhfUm.lib for UMDF builds via build script output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/wdk-build/src/lib.rs Emits VHF linker input per driver type under #[cfg(feature = "vhf")].
crates/wdk-build/Cargo.toml Defines the new vhf feature flag.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.69%. Comparing base (efa6c11) to head (70305e3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #653   +/-   ##
=======================================
  Coverage   78.69%   78.69%           
=======================================
  Files          25       25           
  Lines        5234     5234           
  Branches     5234     5234           
=======================================
  Hits         4119     4119           
  Misses        995      995           
  Partials      120      120           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Alan632 Alan632 marked this pull request as ready for review May 4, 2026 17:47
// Link against VhfKm.lib (Virtual HID Framework, kernel-mode) when
// the "vhf" feature is enabled. Required by drivers that create
// virtual HID devices.
#[cfg(feature = "vhf")]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't need to introduce a new feature to wdk-build for this. vhf headers are tied to the HID API subset, and so linking of the vhf libraries should also be tied to that API subset. Look at how the API subsets are threaded thru from the features in wdk-sys and see how we can maybe have this automatically link in the relevant libraries.

Keep in mind that linker directives must still happen only for the final binary

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.

4 participants