Skip to content

Set LIBCLANG_PATH and verify the Windows SDK in rb msvc - #9

Merged
hsbt merged 2 commits into
masterfrom
msvc-libclang-and-sdk-check
Jul 30, 2026
Merged

Set LIBCLANG_PATH and verify the Windows SDK in rb msvc#9
hsbt merged 2 commits into
masterfrom
msvc-libclang-and-sdk-check

Conversation

@hsbt

@hsbt hsbt commented Jul 30, 2026

Copy link
Copy Markdown
Member

An rb-sys Rust extension gem fails to build under rb msvc at random. bindgen probes the Visual Studio install for libclang.dll without consulting PATH, and a VS install carries both an ARM64 and an x64 copy, so which one it reaches is not deterministic. The ARM64 one fails on an x64 host. Three consecutive cargo build runs in a fresh directory failed with LIBCLANG_PATH unset and succeeded with it set, so activation now sets it. A value the user already has is left alone.

The second change closes a separate gap. vswhere -requires confirms the MSVC component is installed but not that its Windows SDK libraries are on disk. A machine in that state reported linker `link.exe` not found, which a coreutils link.exe on PATH then turned into an unrelated-looking argument error. Activation now checks kernel32.lib under the reported WindowsSdkDir and refuses with an actionable message.

$ rb msvc enable powershell | Select-String LIBCLANG
$env:LIBCLANG_PATH = 'C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\VC\Tools\Llvm\x64\bin'

hsbt and others added 2 commits July 30, 2026 15:34
bindgen probes the Visual Studio install for libclang.dll without consulting PATH and picks between the ARM64 and x64 copies non-deterministically, so an rb-sys gem build fails intermittently on an x64 host. Separately, vswhere's -requires confirms the MSVC component is installed but not that its Windows SDK libraries are on disk, which otherwise surfaces much later as a linker error with no obvious cause.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The stub VsDevCmd.bat now sits at the layout position a real one occupies, so the installationPath derived from it resolves the sibling VC\Tools\Llvm tree and the x64-over-ARM64 selection is pinned rather than assumed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hsbt
hsbt merged commit 446a6b9 into master Jul 30, 2026
3 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.

1 participant