I have LLVM installed via MS Build Tools Installer (components C++ Clang Compiler for Windows (16.0.5) and MSBuild support for LLVM (clang-cl) toolset) and have both ARM64 and x64 versions present:
clang-sys = { version = "1.7.0", features = ["runtime"] }
And
fn main() {
clang_sys::load().unwrap();
}
Will fail with the following error:
called `Result::unwrap()` on an `Err` value: "the `libclang` shared library at C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\Llvm\\ARM64\\bin\\libclang.dll could not be opened: LoadLibraryExW failed"
It is indeed an ARM64 library and it's not possible to load it in x64 Windows:
Dump of file C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\Llvm\\ARM64\\bin\\libclang.dll
PE signature found
File Type: DLL
FILE HEADER VALUES
AA64 machine (ARM64)
[...]
I'm not really familiary with the clang/LLVM ecosystem, but I'm happy to try and provide a fix.
1) What would be the proper place for the fix? dynamic.rsfn validate_library?
2) Is there a way to determine the target architecture (like target_os macro)?
I've improved the library detection on Windows to take into account the machine type of the library, so ARM64 DLLs should get ignored when targeting x86-64 and vice-versa (released in v1.8.1).
I have LLVM installed via MS Build Tools Installer (components C++ Clang Compiler for Windows (16.0.5) and MSBuild support for LLVM (clang-cl) toolset) and have both ARM64 and x64 versions present:
Following paths to load the
libclang.dll
are available:A pretty simple project with
And
Will fail with the following error:
It is indeed an ARM64 library and it's not possible to load it in x64 Windows:
I'm not really familiary with the clang/LLVM ecosystem, but I'm happy to try and provide a fix. 1) What would be the proper place for the fix?
dynamic.rs
fn validate_library
? 2) Is there a way to determine the target architecture (liketarget_os
macro)?