KyleMayes/clang-sys

linking is not supported for non-msvc windows targets

ognevny opened this issue · 3 comments

in distributions such as msys2 uses rustc for *-pc-windows-gnu* targets. also it provides all needed clang libraries including .dll.a and static library

msys2/mingw doesn't provide .lib files, although they are supported (but it's not recommended to use them)

I'm not familiar with this toolchain, here's what I did:

  1. Installed MSYS2
  2. Ran pacman -S mingw-w64-clang-x86_64-clang-libs in MSYS2
  3. Installed Rust for stable-x86_64-pc-windows-gnu and set it as my default

Then, I added a search directory for the MSYS2 installation of libclang ("C:\\MSYS*\\clang*\\lib").
This made it so that clang-sys could find the libclang.dll that was installed in MSYS2.

However, then clang-sys was trying to link to it like -lclang.dll, so I added code to strip off the .dll at the end.
This made cargo test in clang-sys pass (dynamic linking, which is the default).

However, linking at runtime (cargo test --features runtime in clang-sys) is failing for me with this error:
C:\\msys64\\clang64\\bin\\libclang.dll could not be opened: LoadLibraryExW failed

I'm not sure if this is expected (i.e., if loading DLLs at runtime is thing that works with MinGW / MSYS2).

  1. Installed Rust for stable-x86_64-pc-windows-gnu and set it as my default

it's recommended to use rust package from msys2

I'm not sure if this is expected (i.e., if loading DLLs at runtime is thing that works with MinGW / MSYS2).

it should work

I spent a while messing around with MSYS2 and I was able to get both runtime and dynamic linking working with the master branch of clang-sys and versions of Rust and libclang installed via MSYS (i.e., pacman).

Well, for about a minute, then I ran cargo clean and reran cargo test and it broke again.

I'm not sure anything is deficient with clang-sys on this front, but I don't really know what I'm doing.