rust-lang / rust-lang/rust-bindgen
Windows keeps using MSVC, even when `CC` and `CXX` are set explicitly and empty `PATH`
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
nanodbc\nanodbc>set PATH="C:%HOMEPATH%\.cargo\bin"
nanodbc\nanodbc>set CC="%LIBCLANG_PATH%\clang.exe"
nanodbc\nanodbc>set CXX="%LIBCLANG_PATH%\clang++.exe"
nanodbc\nanodbc>%CC% --version
clang version 18.1.8
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
nanodbc\nanodbc>bindgen nanodbc.h -o bindings.rs
[omitted most output for brevity]
pe '__std_exception_data'\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\include\\vcruntime_exception.h:39:13: error: must use 'struct' tag to refer to type '__std_exception_data'\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\include\\vcruntime_exception.h:45:8: error: expected identifier or '('\nC:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.40.33807\\include\\exception:36:1: error: unknown type name 'namespace'\nfatal error: too many errors emitted, stopping now [-ferror-limit=]\n")
Same issue as this guy had 4 years ago #1844
Trying with the nuclear option:
:: clear all vars
nanodbc\nanodbc>for /f "usebackq delims==" %f in (`set`) do (set %f=)
nanodbc\nanodbc>set HOMEPATH :: specific to me
nanodbc\nanodbc>set LIBCLANG_PATH="C:\Program Files\LLVM\bin"
nanodbc\nanodbc>set PATH="C:%HOMEPATH%\.cargo\bin"
nanodbc\nanodbc>set CC="%LIBCLANG_PATH%\clang.exe"
nanodbc\nanodbc>set CXX="%LIBCLANG_PATH%\clang++.exe"
nanodbc\nanodbc>dir %LIBCLANG_PATH%\*clang.dll
Volume in drive C is OS
Volume Serial Number is D2B2-BE47
Directory of C:\Program Files\LLVM\bin
2024-06-19 03:23 AM 100,587,008 libclang.dll
1 File(s) 100,587,008 bytes
0 Dir(s) 19,601,973,248 bytes free
nanodbc\nanodbc>bindgen nanodbc.h -o bindings.rs
thread 'main' panicked at C:%HOMEPATH%\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bindgen-0.69.4\lib.rs:622:31:
Unable to find libclang: "couldn't find any valid shared libraries matching: ['clang.dll', 'libclang.dll'], set the `LIBCLANG_PATH` environment variable to a path where one of these files can be found (invalid: [])"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the bindgen CLI invocation against nanodbc.h on Windows with CC, CXX, PATH, and LIBCLANG_PATH set as shown. Trace how bindgen discovers and invokes Clang, then verify that explicit compiler variables are honored and that the reported libclang lookup failure is resolved without relying on MSVC.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100